Index: vtcross/trunk/src/lib/socketcomm/socketcomm.cpp
===================================================================
--- vtcross/trunk/src/lib/socketcomm/socketcomm.cpp	(revision 222)
+++ vtcross/trunk/src/lib/socketcomm/socketcomm.cpp	(revision 227)
@@ -41,7 +41,7 @@
     // Messages are termination with a "\0" to denote EOM.
     ssize_t msgLength = recv(socketFD, msgBuffer, 256, MSG_PEEK);
-    if (msgLength < 0)
+    if(msgLength < 0)
         ERROR(1, "Error reading from socket.\n");
-    if (msgLength == 0)
+    if(msgLength == 0)
         ERROR(1, "Remote component closed connection.\n");
 
@@ -54,7 +54,7 @@
     // Read the message into msgBuffer
     msgLength = recv(socketFD, msgBuffer, i + 1, 0);
-    if (msgLength < 0)
+    if(msgLength < 0)
         ERROR(1, "Error reading from socket.\n");
-    if (msgLength == 0)
+    if(msgLength == 0)
         ERROR(1, "Remote component closed connection.\n");
 }
Index: vtcross/trunk/src/shell/CognitiveRadioShell.cpp
===================================================================
--- vtcross/trunk/src/shell/CognitiveRadioShell.cpp	(revision 223)
+++ vtcross/trunk/src/shell/CognitiveRadioShell.cpp	(revision 227)
@@ -129,5 +129,5 @@
         SendMessage(socketfd, utils[i].goal.c_str());
         sprintf(var,"%f", utils[i].target);
-        SendMessage(socketfd,var);
+        SendMessage(socketfd, var);
     }
 
@@ -136,18 +136,18 @@
     SendMessage(socketfd,counter);
     for(i = 0; i < radio_info->numParameters; i++) {
-        SendMessage(socketfd,params[i].name.c_str());
-        SendMessage(socketfd,params[i].units.c_str());
-        sprintf(var,"%f",params[i].min);
+        SendMessage(socketfd, params[i].name.c_str());
+        SendMessage(socketfd, params[i].units.c_str());
+        sprintf(var, "%f", params[i].min);
         SendMessage(socketfd,var);
-        sprintf(var,"%f",params[i].max);
-        SendMessage(socketfd,var);
-        sprintf(var,"%f",params[i].step);
-        SendMessage(socketfd,var);
-
-        sprintf(counter,"%i",params[i].numAffects); 
-        SendMessage(socketfd,counter);
+        sprintf(var, "%f", params[i].max);
+        SendMessage(socketfd, var);
+        sprintf(var, "%f", params[i].step);
+        SendMessage(socketfd, var);
+
+        sprintf(counter, "%i", params[i].numAffects); 
+        SendMessage(socketfd, counter);
         for(j = 0; j < params[i].numAffects; j++) {
-            SendMessage(socketfd,params[i].affection_list[j].u->name.c_str());
-            SendMessage(socketfd,params[i].affection_list[j].relation.c_str());
+            SendMessage(socketfd, params[i].affection_list[j].u->name.c_str());
+            SendMessage(socketfd, params[i].affection_list[j].relation.c_str());
         }
     }
@@ -155,13 +155,13 @@
     // observables
     sprintf(counter,"%i",radio_info->numObservables);
-    SendMessage(socketfd,counter);
+    SendMessage(socketfd, counter);
     for(i = 0; i < radio_info->numObservables; i++) {
-        SendMessage(socketfd,observables[i].name.c_str());
+        SendMessage(socketfd, observables[i].name.c_str());
 		
-        sprintf(counter,"%i",observables[i].numAffects); 
-        SendMessage(socketfd,counter);
+        sprintf(counter, "%i", observables[i].numAffects); 
+        SendMessage(socketfd, counter);
         for(j = 0; j < observables[i].numAffects; j++) {
-            SendMessage(socketfd,observables[i].affection_list[j].u->name.c_str());
-            SendMessage(socketfd,observables[i].affection_list[j].relation.c_str());
+            SendMessage(socketfd, observables[i].affection_list[j].u->name.c_str());
+            SendMessage(socketfd, observables[i].affection_list[j].relation.c_str());
         }
     }
@@ -173,7 +173,8 @@
 
     if(strcmp(buffer, "receive_config_ack") != 0) {
-        LOG("Cognitive Radio Shell:: Unexpected response: %s\n",buffer);
+        LOG("Cognitive Radio Shell:: Unexpected response: %s\n", buffer);
         return 0;
     }
+
     return 1;
 
@@ -453,7 +454,5 @@
 {
     char buffer[256];
-    uint32_t numObservables,numParameters;
     char counter[55];
-    uint16_t i;
     char var[50];
 
@@ -461,17 +460,17 @@
     LOG("Cognitive Radio Shell:: Got request for optimization.\n");
     memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD,buffer);
-    numObservables = atoi(buffer);
+    ReadMessage(commandSocketFD, buffer);
+    uint32_t numObservables = atoi(buffer);
   
-	LOG("Cognitive Radio Shell:: Attempting to get %i observables.\n",numObservables);
-    Observable * o = new Observable[numObservables];
+	LOG("Cognitive Radio Shell:: Attempting to get %i observables.\n", numObservables);
+    Observable *o = new Observable[numObservables];
  
-    for (i = 0; i < numObservables; i++){
+    for(size_t i = 0; i < numObservables; i++) {
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         o[i].name = std::string(buffer);
     
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         o[i].value = atof(buffer);
     }
@@ -483,11 +482,11 @@
 
 	LOG("Cognitive Radio Shell:: Passing on observables to Cognitive Engine\n");
-    SendMessage(ceSocketFD,"get_solution");
-    sprintf(counter,"%i",numObservables);
-    SendMessage(ceSocketFD,counter);
-    for(i = 0; i < numObservables; i++) {
-        SendMessage(ceSocketFD,o[i].name.c_str());
-        sprintf(var,"%f",o[i].value);
-	    SendMessage(ceSocketFD,var);
+    SendMessage(ceSocketFD, "get_solution");
+    sprintf(counter, "%i", numObservables);
+    SendMessage(ceSocketFD, counter);
+    for(size_t i = 0; i < numObservables; i++) {
+        SendMessage(ceSocketFD, o[i].name.c_str());
+        sprintf(var, "%f", o[i].value);
+	    SendMessage(ceSocketFD, var);
     }
 
@@ -496,16 +495,16 @@
     /* Receive Set of Parameters */
     memset(buffer, 0, 256);
-    ReadMessage(ceSocketFD,buffer);
-    numParameters = atoi(buffer);
+    ReadMessage(ceSocketFD, buffer);
+    uint32_t numParameters = atoi(buffer);
    
-    Parameter * p = new Parameter[numParameters];
+    Parameter *p = new Parameter[numParameters];
  
-    for (i = 0; i < numParameters; i++){
+    for(size_t i = 0; i < numParameters; i++) {
         memset(buffer, 0, 256);
-        ReadMessage(ceSocketFD,buffer);
+        ReadMessage(ceSocketFD, buffer);
         p[i].name = std::string(buffer);
     
         memset(buffer, 0, 256);
-        ReadMessage(ceSocketFD,buffer);
+        ReadMessage(ceSocketFD, buffer);
         p[i].value = atof(buffer);
     }
@@ -515,11 +514,14 @@
 	LOG("Cognitive Radio Shell:: Sending optimized parameters to Application.\n");
     memset(counter, 0, 55);
-    sprintf(counter,"%i",numParameters);
-    SendMessage(commandSocketFD,counter);
-    for(i = 0; i < numParameters; i++) {
-        SendMessage(commandSocketFD,p[i].name.c_str());
-        sprintf(var,"%f",p[i].value);
-	    SendMessage(commandSocketFD,var);
-    }
+    sprintf(counter, "%i", numParameters);
+    SendMessage(commandSocketFD, counter);
+    for(size_t i = 0; i < numParameters; i++) {
+        SendMessage(commandSocketFD, p[i].name.c_str());
+        sprintf(var, "%f", p[i].value);
+	    SendMessage(commandSocketFD, var);
+    }
+
+    delete [] o;
+    delete [] p;
 }
 
@@ -532,17 +534,17 @@
     ReadMessage(socketFD, buffer);
 
-    if(strcmp(buffer,"register_engine_cognitive") == 0) { 
+    if(strcmp(buffer, "register_engine_cognitive") == 0) { 
         RegisterCognitiveEngine(socketFD);
-    } else if(strcmp(buffer,"deregister_engine_cognitive") == 0) {
+    } else if(strcmp(buffer, "deregister_engine_cognitive") == 0) {
         DeregisterCognitiveEngine(socketFD);
-    } else if(strcmp(buffer,"register_engine_policy") == 0) {
+    } else if(strcmp(buffer, "register_engine_policy") == 0) {
         RegisterPolicyEngine(socketFD);
-    } else if(strcmp(buffer,"deregister_engine_policy") == 0) {
+    } else if(strcmp(buffer, "deregister_engine_policy") == 0) {
         DeregisterPolicyEngine(socketFD);
-    } else if(strcmp(buffer,"register_sml") == 0) {
+    } else if(strcmp(buffer, "register_sml") == 0) {
         RegisterSML(socketFD);
-    } else if(strcmp(buffer,"deregister_sml") == 0) {
+    } else if(strcmp(buffer, "deregister_sml") == 0) {
         DeregisterSML(socketFD);
-    } else if(strcmp(buffer,"request_optimization") == 0) {
+    } else if(strcmp(buffer, "request_optimization") == 0) {
         /* Receive optimization request and current environment */
         GetOptimalParameters(socketFD);  
Index: vtcross/trunk/src/libvtcross/libvtcross.cpp
===================================================================
--- vtcross/trunk/src/libvtcross/libvtcross.cpp	(revision 226)
+++ vtcross/trunk/src/libvtcross/libvtcross.cpp	(revision 227)
@@ -17,4 +17,5 @@
 #include "vtcross/libvtcross.h"
 
+
 uint32_t
 ConnectToRemoteComponent()
@@ -26,4 +27,5 @@
 }
 
+
 /* Given a certain set of observables, ask the radio to find the optimum radio
  * parameters and return them. 
@@ -31,13 +33,18 @@
  * TODO I'm a little confused about this function... why would anyone need to
  * use this?  Shouldn't this be internal to the radio operation? 
+ *
+ * TODO this function is returning a pointer to allocated memory, which is fine,
+ * but we need to document this and make sure the caller is deallocating the
+ * memory when it is done using it.
  */
-Parameter* GetOptimalParameters(Observable *radioObservables, uint32_t numObservables) {
-    uint32_t i,socketfd,numParameters;
+Parameter* 
+GetOptimalParameters(Observable *radioObservables, uint32_t numObservables)
+{
     char var[50];
     char counter[55];
 	char buffer[256];
 
-    socketfd = ConnectToRemoteComponent();
-    SendMessage(socketfd,"request_optimization");
+    uint32_t socketFD = ConnectToRemoteComponent();
+    SendMessage(socketFD, "request_optimization");
 
     /* Get number of observables to send.  This information needs to be 
@@ -46,25 +53,25 @@
 
     // Send Observables
-    sprintf(counter,"%i",numObservables);
-    SendMessage(socketfd,counter);
-    for(i = 0; i < numObservables; i++) {
-        SendMessage(socketfd,radioObservables[i].name.c_str());
-        sprintf(var,"%f",radioObservables[i].value);
-        SendMessage(socketfd,var);	
+    sprintf(counter, "%i", numObservables);
+    SendMessage(socketFD, counter);
+    for(size_t i = 0; i < numObservables; i++) {
+        SendMessage(socketFD, radioObservables[i].name.c_str());
+        sprintf(var, "%f", radioObservables[i].value);
+        SendMessage(socketFD, var);	
     }
 
     /* Receive Set of Parameters */
     memset(buffer, 0, 256);
-    ReadMessage(socketfd, buffer);
-    numParameters = atoi(buffer);
-    Parameter * pList = new Parameter[numParameters];
+    ReadMessage(socketFD, buffer);
+    int32_t numParameters = atoi(buffer);
+    Parameter *pList = new Parameter[numParameters];
     
-    for(size_t i = 0; i < numParameters; i++) {
+    for(ssize_t i = 0; i < numParameters; i++) {
         memset(buffer, 0, 256);
-        ReadMessage(socketfd, buffer);
+        ReadMessage(socketFD, buffer);
         pList[i].name = std::string(buffer);
         
 		memset(buffer, 0, 256);
-        ReadMessage(socketfd, buffer);
+        ReadMessage(socketFD, buffer);
         pList[i].value = atof(buffer);
     }   
@@ -72,2 +79,3 @@
     return pList;
 }
+
