Index: vtcross/trunk/src/include/vtcross/components.h
===================================================================
--- vtcross/trunk/src/include/vtcross/components.h	(revision 195)
+++ vtcross/trunk/src/include/vtcross/components.h	(revision 203)
@@ -56,4 +56,35 @@
 
 
+        /* Wait for a command signal containing task instructions.
+         */
+        virtual void WaitForSignal() = 0;
+
+
+        /* Completely shutdown the radio and all operations.
+         */
+        virtual void Shutdown() = 0;
+
+
+        /* Reset the radio and reload all configuration files.
+         *
+         * TODO are we remembering experiences in CEs?
+         */
+        virtual void Reset() = 0;
+
+
+        /* Register or deregister a component with the primary radio shell.
+         */
+        virtual void RegisterComponent() = 0;
+        virtual void DeregisterComponent() = 0;
+};
+
+
+/* Engine abstract base class from which all engine component types should
+ * inherit (e.g. cognitive and policy engines). Inherits all functions from the
+ * ABC Component publically.
+ */
+class Engine : public Component
+{
+    public:
         /* Connect to the remote control component, which will always be either
          * the VTCROSS shell or SML.  Based on the status of the SML_present
@@ -64,37 +95,7 @@
          */
         virtual void ConnectToRemoteComponent(const char* serverName, \
-                const char* serverPort) = 0;
-
-        /* Wait for a command signal containing task instructions.
-         */
-        virtual void WaitForSignal() = 0;
-
-
-        /* Completely shutdown the radio and all operations.
-         */
-        virtual void Shutdown() = 0;
-
-
-        /* Reset the radio and reload all configuration files.
-         *
-         * TODO are we remembering experiences in CEs?
-         */
-        virtual void Reset() = 0;
-
-
-        /* Register or deregister a component with the primary radio shell.
-         */
-        virtual void RegisterComponent() = 0;
-        virtual void DeregisterComponent() = 0;
-};
-
-
-/* Engine abstract base class from which all engine component types should
- * inherit (e.g. cognitive and policy engines). Inherits all functions from the
- * ABC Component publically.
- */
-class Engine : public Component
-{
-    public:
+                const char* serverPort, const bool SML) = 0;
+
+
         /* Register or deregister services that this engine provides with the
          * service management layer.
@@ -115,7 +116,16 @@
         ~ServiceManagementLayer();
 
+        /* Overloaded constructor that creates an SML and connects it to the
+         * shell with the passed hostname and port.
+         */
+        ServiceManagementLayer(const char* serverName, const char* serverPort);
+
+        /* Connect and register with the shell component at the passed hostname
+         * and port.
+         */
+        void ConnectToShell(const char* serverName, \
+                const char* serverPort);
+
         void SendComponentType();
-        void ConnectToRemoteComponent(const char* serverName, \
-                const char* serverPort);
         void WaitForSignal();
         void Shutdown();
@@ -185,5 +195,5 @@
         void SendComponentType();
         void ConnectToRemoteComponent(const char* serverName, \
-                const char* serverPort);
+                const char* serverPort, const bool SML);
         void WaitForSignal();
         void Shutdown();
@@ -235,5 +245,5 @@
         void SendComponentType();
         void ConnectToRemoteComponent(const char* serverName, \
-                const char* serverPort);
+                const char* serverPort, const bool SML);
         void WaitForSignal();
         void Shutdown();
Index: vtcross/trunk/src/policy_engines/PolicyEngine.cpp
===================================================================
--- vtcross/trunk/src/policy_engines/PolicyEngine.cpp	(revision 202)
+++ vtcross/trunk/src/policy_engines/PolicyEngine.cpp	(revision 203)
@@ -40,7 +40,5 @@
     LOG("Creating Policy Engine.\n");
 
-    SML_present = SML;
-    
-    ConnectToRemoteComponent(serverName, serverPort);
+    ConnectToRemoteComponent(serverName, serverPort, SML);
 
     LoadPolicies();
@@ -58,9 +56,11 @@
 void
 PolicyEngine::ConnectToRemoteComponent(const char* serverName, \
-        const char* serverPort)
+        const char* serverPort, const bool SML)
 {
     commandSocketFD = ClientSocket(serverName, serverPort);
 
-    if(SML_present) {
+    SML_present = SML;
+
+    if(SML) {
         RegisterServices();
         LOG("Policy Engine connected to SML at %s.\n", serverName);
@@ -115,7 +115,5 @@
                 close(commandSocketFD);
 
-                SML_present = true;
-
-                ConnectToRemoteComponent(serverName, serverPort);
+                ConnectToRemoteComponent(serverName, serverPort, true);
             }
         }
@@ -140,7 +138,5 @@
                 close(commandSocketFD);
 
-                SML_present = false;
-
-                ConnectToRemoteComponent(serverName, serverPort);
+                ConnectToRemoteComponent(serverName, serverPort, false);
             }
         }
@@ -179,8 +175,4 @@
     else
         DeregisterComponent();
-
-    SML_present = false;
-    commandSocketFD = -1;
-    LoadPolicies();
 }
 
@@ -202,4 +194,5 @@
     shutdown(commandSocketFD, 2);
     close(commandSocketFD);
+    commandSocketFD = -1;
     LOG("Policy Engine:: Shell socket closed.\n");
 }
@@ -228,4 +221,5 @@
     shutdown(commandSocketFD, 2);
     close(commandSocketFD);
+    commandSocketFD = -1;
     LOG("Policy Engine:: SML socket closed.\n");
 }
