Index: vtcross/trunk/src/cognitive_engines/CognitiveEngine.cpp
===================================================================
--- vtcross/trunk/src/cognitive_engines/CognitiveEngine.cpp	(revision 230)
+++ vtcross/trunk/src/cognitive_engines/CognitiveEngine.cpp	(revision 231)
@@ -22,4 +22,5 @@
 #include "vtcross/cbr.h"
 
+// TODO this is really bad; need to move to a proper cbr.h
 #include "cbr.c"
 
@@ -28,6 +29,6 @@
 
 
-
 static cbr myCBR;
+
 
 CognitiveEngine::CognitiveEngine()
@@ -41,5 +42,5 @@
 CognitiveEngine::~CognitiveEngine()
 {
-	cbr_free(myCBR);
+    cbr_free(myCBR);
     delete [] pList;
     delete [] oList;
@@ -49,5 +50,5 @@
 
 
-CognitiveEngine::CognitiveEngine(const char* serverName, const char* serverPort, \
+CognitiveEngine::CognitiveEngine(const char *serverName, const char *serverPort, \
         const bool SML)
 {
@@ -72,6 +73,6 @@
 
 void
-CognitiveEngine::ConnectToRemoteComponent(const char* serverName, \
-        const char* serverPort, const bool SML)
+CognitiveEngine::ConnectToRemoteComponent(const char *serverName, \
+        const char *serverPort, const bool SML)
 {
     commandSocketFD = ClientSocket(serverName, serverPort);
@@ -98,13 +99,13 @@
 { 
    LOG("Cognitive Engine:: Receiving feedback.\n");
-	
-	uint32_t numberColumns = 
-		radioInfo->numParameters +
-		radioInfo->numUtilities;
-
-	uint32_t obsColumns = radioInfo->numObservables + 1;
-
-	float valList[numberColumns];
-	float obsVals[numberColumns];
+    
+    uint32_t numberColumns = 
+        radioInfo->numParameters +
+        radioInfo->numUtilities;
+
+    uint32_t obsColumns = radioInfo->numObservables + 1;
+
+    float valList[numberColumns];
+    float obsVals[numberColumns];
     char *nameList[numberColumns];
     char *obsList[obsColumns];
@@ -112,5 +113,5 @@
     size_t columnObsIndex = 0;
     for (size_t i = 0; i < radioInfo->numObservables; i++){
-		obsList[columnObsIndex] = (char*)observables[i].name.c_str();
+        obsList[columnObsIndex] = (char*)observables[i].name.c_str();
         columnObsIndex++;
     }  
@@ -119,38 +120,38 @@
     size_t columnIndex = 0;
     for (size_t i = 0; i < radioInfo->numParameters; i++){
-		nameList[columnIndex] = (char*)parameters[i].name.c_str();
+        nameList[columnIndex] = (char*)parameters[i].name.c_str();
         columnIndex++;
     }   
     for (size_t i = 0; i < radioInfo->numUtilities; i++){
-		nameList[columnIndex] = (char*)uList[i].name.c_str();
+        nameList[columnIndex] = (char*)uList[i].name.c_str();
         columnIndex++;
     }   
 
-	size_t obsValueIndex = 0;
+    size_t obsValueIndex = 0;
     for(size_t i = 0; i < radioInfo->numObservables; i++) {
-		obsVals[obsValueIndex] = observables[i].value;
-		obsValueIndex++;
-	}
-	// Calculate Utility
-	float newUtilityValue = 0;
+        obsVals[obsValueIndex] = observables[i].value;
+        obsValueIndex++;
+    }
+
+    /* Calculate Utility */
+    float newUtilityValue = 0;
 
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
-		newUtilityValue = newUtilityValue + (uList[i].target - observables[i].value);
-	}
-	obsVals[obsValueIndex] = newUtilityValue;
-
-	size_t returnValueIndex = 0;
+        newUtilityValue = newUtilityValue + (uList[i].target - observables[i].value);
+    }
+    obsVals[obsValueIndex] = newUtilityValue;
+
+    size_t returnValueIndex = 0;
     for(size_t i = 0; i < radioInfo->numParameters; i++) {
-		valList[returnValueIndex] = parameters[i].value;
-		returnValueIndex++;
-	}
+        valList[returnValueIndex] = parameters[i].value;
+        returnValueIndex++;
+    }
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
-		valList[returnValueIndex] = uList[i].target;
-		returnValueIndex++;
-	}
-
-
-	cbr_update(myCBR, nameList, obsList, valList, obsVals, 
-			numberColumns, obsColumns);
+        valList[returnValueIndex] = uList[i].target;
+        returnValueIndex++;
+    }
+
+    cbr_update(myCBR, nameList, obsList, valList, obsVals, 
+            numberColumns, obsColumns);
 }
 
@@ -177,5 +178,5 @@
             /* Receive Set of current Parameters */
             memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
+            ReadMessage(commandSocketFD, buffer);
             uint32_t numParameters = atoi(buffer);
    
@@ -193,4 +194,30 @@
 
             /* Receive Set of Observables */
+            memset(buffer, 0, 256);
+            ReadMessage(commandSocketFD, buffer);
+            uint32_t numObservables = atoi(buffer);
+   
+            Observable *o = new Observable[numObservables];
+ 
+            for(size_t i = 0; i < numObservables; i++) {
+                memset(buffer, 0, 256);
+                ReadMessage(commandSocketFD, buffer);
+                o[i].name = std::string(buffer);
+    
+                memset(buffer, 0, 256);
+                ReadMessage(commandSocketFD, buffer);
+                o[i].value = atof(buffer);
+            }  
+
+            ReceiveFeedback(o,p);
+
+            delete [] o;
+            delete [] p;
+        } 
+        else if(strcmp(buffer, "request_optimization") == 0) {
+            
+            /* Receive Set of Observables */
+            LOG("\nCognitive Engine:: Receiving Observable Parameters\n");
+
             memset(buffer, 0, 256);
             ReadMessage(commandSocketFD,buffer);
@@ -209,35 +236,9 @@
             }  
 
-			ReceiveFeedback(o,p);
-
-            delete [] o;
-            delete [] p;
-		} 
-		else if(strcmp(buffer, "request_optimization") == 0) {
-            
-            /* Receive Set of Observables */
-			LOG("\nCognitive Engine:: Receiving Observable Parameters\n");
+            /* Receive Set of current Parameters */
+            LOG("Cognitive Engine:: Receiving Current Transmission Parameters\n");
 
             memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
-            uint32_t numObservables = atoi(buffer);
-   
-            Observable *o = new Observable[numObservables];
- 
-            for(size_t i = 0; i < numObservables; i++) {
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].name = std::string(buffer);
-    
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].value = atof(buffer);
-            }  
-
-            /* Receive Set of current Parameters */
-			LOG("Cognitive Engine:: Receiving Current Transmission Parameters\n");
-
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
+            ReadMessage(commandSocketFD, buffer);
             uint32_t numCurrentParameters = atoi(buffer);
    
@@ -253,23 +254,23 @@
                 cp[i].value = atof(buffer);
             }  
-			LOG("Cognitive Engine:: Processing parameters....\n");
+            LOG("Cognitive Engine:: Processing parameters....\n");
 
             Parameter *solutionSet;
-			
-			solutionSet = GetSolution(o,cp);
+            
+            solutionSet = GetSolution(o,cp);
 
             // TODO need to actually do something with the observables here
            
-			LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n");
-			char numParametersChar[10];
-			char solutionValue[50];
-			sprintf(numParametersChar,"%i",radioInfo->numParameters);
-			SendMessage(commandSocketFD,numParametersChar);
+            LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n");
+            char numParametersChar[10];
+            char solutionValue[50];
+            sprintf(numParametersChar, "%i", radioInfo->numParameters);
+            SendMessage(commandSocketFD, numParametersChar);
             for(size_t i = 0; i < radioInfo->numParameters; i++) {
-                SendMessage(commandSocketFD,solutionSet[i].name.c_str());
+                SendMessage(commandSocketFD, solutionSet[i].name.c_str());
                 memset(solutionValue, 0, 50);
-			    sprintf(solutionValue,"%f",solutionSet[i].value);
-                SendMessage(commandSocketFD,solutionValue);
-			}
+                sprintf(solutionValue, "%f", solutionSet[i].value);
+                SendMessage(commandSocketFD, solutionValue);
+            }
 
             delete [] o;
@@ -430,22 +431,22 @@
     /* Receive Set of Utilities */
     memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD,buffer);
+    ReadMessage(commandSocketFD, buffer);
     radioInfo->numUtilities = atoi(buffer);
     
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         uList[i].name = std::string(buffer);
    
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         uList[i].units = std::string(buffer);
 
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         uList[i].goal = std::string(buffer);
     
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         uList[i].target = atof(buffer);
     }
@@ -484,6 +485,7 @@
             memset(buffer, 0, 256);
             ReadMessage(commandSocketFD,buffer);
+            // TODO for + if{break} = while?
             for(size_t k = 0; k < radioInfo->numUtilities; k++) {
-	        if(uList[k].name == std::string(buffer)){    
+                if(uList[k].name == std::string(buffer)) {    
                     pList[i].affection_list[j].u = &uList[k];   
                     break;
@@ -492,5 +494,5 @@
 
             memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
+            ReadMessage(commandSocketFD, buffer);
             pList[i].affection_list[j].relation = std::string(buffer);   
         }
@@ -499,21 +501,22 @@
     /* Receive Set of Observables */
     memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD,buffer);
+    ReadMessage(commandSocketFD, buffer);
     radioInfo->numObservables = atoi(buffer);
     
     for(size_t i = 0; i < radioInfo->numObservables; i++) {
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         oList[i].name = std::string(buffer);
     
         memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
+        ReadMessage(commandSocketFD, buffer);
         oList[i].numAffects = atoi(buffer);
     
         for(size_t j = 0; j < oList[i].numAffects; j++) {
             memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
+            ReadMessage(commandSocketFD, buffer);
+            // TODO for + if{break} = while?
             for(size_t k = 0; k < radioInfo->numUtilities; k++) {
-	        if(uList[k].name == std::string(buffer)){    
+                if(uList[k].name == std::string(buffer)){    
                     oList[i].affection_list[j].u = &uList[k];   
                     break;
@@ -522,5 +525,5 @@
  
             memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
+            ReadMessage(commandSocketFD, buffer);
             oList[i].affection_list[j].relation = std::string(buffer);   
         }
@@ -529,5 +532,5 @@
     SendMessage(commandSocketFD, "receive_config_ack");
 
-	BuildCognitiveEngine();
+    BuildCognitiveEngine();
 }
 
@@ -541,8 +544,8 @@
     /* Receive number of experience entries */
     memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD,buffer);
+    ReadMessage(commandSocketFD, buffer);
     numberExp = atoi(buffer);
 
-    LOG("Cognitive Engine:: Waiting for %i number of entries.\n",numberExp);
+    LOG("Cognitive Engine:: Waiting for %i number of entries.\n", numberExp);
  
     SendMessage(commandSocketFD, "receive_exp_ack");
@@ -558,109 +561,107 @@
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
         searchNames[i] = (char*)observables[i].name.c_str();
-	}
+    }
 
     float searchVals[radioInfo->numUtilities];
 
-	for(size_t i = 0; i < radioInfo->numUtilities; i++) {
-		searchVals[i] = uList[i].target;
+    for(size_t i = 0; i < radioInfo->numUtilities; i++) {
+        searchVals[i] = uList[i].target;
     }
 
     uint32_t numberColumns = 
-		radioInfo->numUtilities +
-		radioInfo->numParameters +
-		radioInfo->numObservables + 1;
-	
-	float returnValues[numberColumns];
-	
-	int searchOps[radioInfo->numUtilities];
+        radioInfo->numUtilities +
+        radioInfo->numParameters +
+        radioInfo->numObservables + 1;
+    
+    float returnValues[numberColumns];
+    
+    int searchOps[radioInfo->numUtilities];
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
 
         /* If the goal is to maximum, set the search operation to
-		 * return values greater than the target.
-		 *
-		 * If the goal is to minimize, set the search operation to
-		 * return values less than the target.
-		 */
-
-		if(strcmp(uList[i].goal.c_str(),"max") == 0) {
-		    searchOps[i] = GT;
-		} else if(strcmp(uList[i].goal.c_str(),"min") == 0) {
-			searchOps[i] = LT;
-		}
-	}
-
-	/* CBR specific call */
-	uint32_t rc = cbr_search(myCBR, searchNames, searchOps, searchVals,
-			radioInfo->numUtilities, returnValues);
-
-	if(rc == 0){
+         * return values greater than the target.
+         *
+         * If the goal is to minimize, set the search operation to
+         * return values less than the target.
+         */
+        if(strcmp(uList[i].goal.c_str(), "max") == 0) {
+            searchOps[i] = GT;
+        } else if(strcmp(uList[i].goal.c_str(), "min") == 0) {
+            searchOps[i] = LT;
+        }
+    }
+
+    /* CBR specific call */
+    uint32_t rc = cbr_search(myCBR, searchNames, searchOps, searchVals,
+            radioInfo->numUtilities, returnValues);
+
+    if(rc == 0){
         /* Adapt the returned parameters to meet the objective */
-	    
         WARNING("Cognitive Engine:: Found\n");
 
-		// Should do a random adaptation.. 
-		if(returnValues[numberColumns-1] < 0) {
-			returnValues[2] = returnValues[2] - 15;
-			returnValues[3] = returnValues[3] - 2;
+        /* Should do a random adaptation.. */
+        if(returnValues[numberColumns-1] < 0) {
+            returnValues[2] = returnValues[2] - 15;
+            returnValues[3] = returnValues[3] - 2;
         } else {
-			returnValues[2] = returnValues[2] + 15;
-			returnValues[3] = returnValues[3] + 2;
-		}
-    } else if(rc == 31337){
+            returnValues[2] = returnValues[2] + 15;
+            returnValues[3] = returnValues[3] + 2;
+        }
+    } else if(rc == 31337) {
         WARNING("Cognitive Engine:: Not Found.\n");
-		/* No rows in the CBR, pick default parameters */
-		// Currently this is hard coded and implementation specific!
-	    returnValues[2] = currentParameters[0].value + 5;
-	    returnValues[3] = currentParameters[1].value + 10;
+        /* No rows in the CBR, pick default parameters */
+        /* Currently this is hard coded and implementation specific! */
+        returnValues[2] = currentParameters[0].value + 5;
+        returnValues[3] = currentParameters[1].value + 10;
         
-	} else {
+    } else {
         WARNING("Cognitive Engine:: Search return an invalid value.\n");
-	}
-
-	size_t returnValueIndex = 0;
+    }
+
+    size_t returnValueIndex = 0;
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
-		uList[i].value = returnValues[returnValueIndex];
-		returnValueIndex++;
-	}
+        uList[i].value = returnValues[returnValueIndex];
+        returnValueIndex++;
+    }
     for(size_t i = 0; i < radioInfo->numParameters; i++) {
-		pList[i].value = returnValues[returnValueIndex];
-		returnValueIndex++;
-	}
+        pList[i].value = returnValues[returnValueIndex];
+        returnValueIndex++;
+    }
     for(size_t i = 0; i < radioInfo->numObservables; i++) {
-		oList[i].value = returnValues[returnValueIndex];
-		returnValueIndex++;
-	}
+        oList[i].value = returnValues[returnValueIndex];
+        returnValueIndex++;
+    }
     returnValues[returnValueIndex] = 0;
 
     char *allNames[numberColumns];
-	size_t allNameIndex = 0;
+    size_t allNameIndex = 0;
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
         allNames[allNameIndex] = (char*)uList[i].name.c_str();
-		returnValues[allNameIndex] = uList[i].target;
-		allNameIndex++;
-	}
+        returnValues[allNameIndex] = uList[i].target;
+        allNameIndex++;
+    }
     for(size_t i = 0; i < radioInfo->numParameters; i++) {
         allNames[allNameIndex] = (char*)pList[i].name.c_str();
-		allNameIndex++;
-	}
+        allNameIndex++;
+    }
     for(size_t i = 0; i < radioInfo->numObservables; i++) {
         allNames[allNameIndex] = (char*)oList[i].name.c_str();
-		returnValues[allNameIndex] = 0;
-		allNameIndex++;
-	}
+        returnValues[allNameIndex] = 0;
+        allNameIndex++;
+    }
     allNames[allNameIndex] = "utility";
 
-	// Add row to CBR. 
-	cbr_add_row(myCBR, allNames, returnValues, returnValueIndex+1);
-
-	return pList;
-
+    // Add row to CBR. 
+    cbr_add_row(myCBR, allNames, returnValues, returnValueIndex+1);
+
+    return pList;
 }
 
 
 Parameter* 
-CognitiveEngine::GetSolution(Observable *observables, Parameter *currentParameters, std::string service)
-{
-    LOG("Cognitive Engine:: Generating solution for %s service.\n",service.c_str());
+CognitiveEngine::GetSolution(Observable *observables, \
+        Parameter *currentParameters, std::string service)
+{
+    LOG("Cognitive Engine:: Generating solution for %s service.\n", service.c_str());
 
     return pList;
@@ -679,11 +680,11 @@
 CognitiveEngine::BuildCognitiveEngine()
 {
-	char filename[] = {"ex1"};
-	char tablename[] = {"data"};
+    char filename[] = {"ex1"};
+    char tablename[] = {"data"};
 
     uint32_t numberColumns = 
-		radioInfo->numUtilities +
-		radioInfo->numParameters +
-		radioInfo->numObservables + 1;
+        radioInfo->numUtilities +
+        radioInfo->numParameters +
+        radioInfo->numObservables + 1;
 
     char *cols[numberColumns];
@@ -691,13 +692,13 @@
     size_t columnIndex = 0;
     for (size_t i = 0; i < radioInfo->numUtilities; i++){
-		cols[columnIndex] = (char*)uList[i].name.c_str();
+        cols[columnIndex] = (char*)uList[i].name.c_str();
         columnIndex++;
     }   
     for (size_t i = 0; i < radioInfo->numParameters; i++){
-		cols[columnIndex] = (char*)pList[i].name.c_str();
+        cols[columnIndex] = (char*)pList[i].name.c_str();
         columnIndex++;
     }   
     for (size_t i = 0; i < radioInfo->numObservables; i++){
-		cols[columnIndex] = (char*)oList[i].name.c_str();
+        cols[columnIndex] = (char*)oList[i].name.c_str();
         columnIndex++;
     }   
Index: vtcross/trunk/src/include/vtcross/socketcomm.h
===================================================================
--- vtcross/trunk/src/include/vtcross/socketcomm.h	(revision 216)
+++ vtcross/trunk/src/include/vtcross/socketcomm.h	(revision 231)
@@ -18,10 +18,9 @@
 /* TODO
  */
-void ReadMessage(int32_t socketFD, char* msgBuffer);
+void ReadMessage(int32_t socketFD, char *msgBuffer);
 
 /* TODO
  */
-//int32_t SendMessage(int32_t socketFD, char* message);
-int32_t SendMessage(int32_t socketFD, const char* message) ;
+int32_t SendMessage(int32_t socketFD, const char *message) ;
 
 /* TODO
@@ -38,5 +37,5 @@
  * to do.
  */
-int32_t ClientSocket(const char* serverName, const char* portNumber);
+int32_t ClientSocket(const char  *serverName, const char *portNumber);
 
 /* TODO
Index: vtcross/trunk/src/include/vtcross/components.h
===================================================================
--- vtcross/trunk/src/include/vtcross/components.h	(revision 230)
+++ vtcross/trunk/src/include/vtcross/components.h	(revision 231)
@@ -293,8 +293,10 @@
         int32_t commandSocketFD;
         
-        Utility * uList;
-        Parameter * pList;
-        Observable * oList;
-        struct Radio_Info * radioInfo;
+        // TODO Need a description for these fields.  Are these radio utilites,
+        // parameters, and observables global to the whole system?
+        Utility *uList;
+        Parameter *pList;
+        Observable *oList;
+        struct Radio_Info *radioInfo;
 };
 
Index: vtcross/trunk/src/shell/CognitiveRadioShell.cpp
===================================================================
--- vtcross/trunk/src/shell/CognitiveRadioShell.cpp	(revision 230)
+++ vtcross/trunk/src/shell/CognitiveRadioShell.cpp	(revision 231)
@@ -111,64 +111,63 @@
 
 
+// TODO what is the point of always returning a 1?
 bool
-CognitiveRadioShell::SendRadioConfiguration(int32_t socketfd)
+CognitiveRadioShell::SendRadioConfiguration(int32_t socketFD)
 {
     LOG("Cognitive Radio Shell:: Sending radio configuration to Cognitive Engine.\n");
-    uint32_t i,j;
+
     char counter[55];
     char var[50];
 
-    // utilities
-    // Send number of utilities
-    sprintf(counter,"%d",radio_info->numUtilities);
-    SendMessage(socketfd,counter);
-    // send utility	
-    for(i = 0; i < radio_info->numUtilities; i++) {
-        SendMessage(socketfd, utils[i].name.c_str());
-        SendMessage(socketfd, utils[i].units.c_str());
-        SendMessage(socketfd, utils[i].goal.c_str());
+    /* Send utilities */
+    sprintf(counter, "%d", radio_info->numUtilities);
+    SendMessage(socketFD, counter);
+    for(size_t i = 0; i < radio_info->numUtilities; i++) {
+        SendMessage(socketFD, utils[i].name.c_str());
+        SendMessage(socketFD, utils[i].units.c_str());
+        SendMessage(socketFD, utils[i].goal.c_str());
         sprintf(var,"%f", utils[i].target);
-        SendMessage(socketfd, var);
-    }
-
-    // parameters
+        SendMessage(socketFD, var);
+    }
+
+    /* Send parameters */
     sprintf(counter,"%i",radio_info->numParameters);
-    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());
+    SendMessage(socketFD,counter);
+    for(size_t 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,var);
+        SendMessage(socketFD,var);
         sprintf(var, "%f", params[i].max);
-        SendMessage(socketfd, var);
+        SendMessage(socketFD, var);
         sprintf(var, "%f", params[i].step);
-        SendMessage(socketfd, var);
+        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, counter);
+        for(size_t 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());
         }
     }
 
-    // observables
+    /* Send observables */
     sprintf(counter,"%i",radio_info->numObservables);
-    SendMessage(socketfd, counter);
-    for(i = 0; i < radio_info->numObservables; i++) {
-        SendMessage(socketfd, observables[i].name.c_str());
+    SendMessage(socketFD, counter);
+    for(size_t i = 0; i < radio_info->numObservables; i++) {
+        SendMessage(socketFD, observables[i].name.c_str());
 		
         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, counter);
+        for(size_t 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());
         }
     }
 	
-    // Receive ACK for utils
+    /* Receive ACK for radio configuration */
     char buffer[256];
     memset(buffer, 0, 256); 
-    ReadMessage(socketfd, buffer);
+    ReadMessage(socketFD, buffer);
 
     if(strcmp(buffer, "receive_config_ack") != 0) {
@@ -178,5 +177,4 @@
 
     return 1;
-
 }
 
@@ -189,5 +187,5 @@
 	char numberExpString[50];
 
-    sprintf(numberExpString,"%i",numberExp);
+    sprintf(numberExpString, "%i", numberExp);
     SendMessage(socketFD, numberExpString); 
 
@@ -196,7 +194,9 @@
     ReadMessage(socketFD, buffer);
     if(strcmp(buffer, "receive_exp_ack") != 0) {
-        LOG("Cognitive Radio Shell:: Unexpected response: %s\n",buffer);
+        // TODO perhaps this should be a WARNING instead of a LOG?
+        LOG("Cognitive Radio Shell:: Unexpected response: %s\n", buffer);
         return 0;
     }
+
     return 1;
 }
@@ -446,5 +446,4 @@
 
     return 1;
-
 }
 
@@ -454,5 +453,4 @@
 {
     char buffer[256];
-    uint32_t numObservables,numParameters,numCurrentParameters;
     char counter[55];
     char var[50];
@@ -462,5 +460,5 @@
     memset(buffer, 0, 256);
     ReadMessage(commandSocketFD, buffer);
-    numObservables = atoi(buffer);
+    uint32_t numObservables = atoi(buffer);
   
 	LOG("Cognitive Radio Shell:: Attempting to get %i observables.\n", numObservables);
@@ -476,8 +474,9 @@
         o[i].value = atof(buffer);
     }
+
 	/* Receive Set of Current Parameters */
     memset(buffer, 0, 256);
     ReadMessage(commandSocketFD,buffer);
-    numCurrentParameters = atoi(buffer);
+    uint32_t numCurrentParameters = atoi(buffer);
   
 	LOG("Cognitive Radio Shell:: Attempting to get %i parameters.\n",numCurrentParameters);
@@ -492,9 +491,9 @@
         cp[i].value = atof(buffer);
     }
+
     /* Send to Cognitive Engine 
 	 * TODO: With multiple CEs we need to make a decision about where
 	 * to send this information
 	 */
-
 	if(!SML_present) { 
 	    LOG("Cognitive Radio Shell:: Passing on observables to Cognitive Engine\n");
@@ -522,5 +521,5 @@
     memset(buffer, 0, 256);
     ReadMessage(ceSocketFD, buffer);
-    numParameters = atoi(buffer);
+    uint32_t numParameters = atoi(buffer);
    
     Parameter *p = new Parameter[numParameters];
@@ -552,9 +551,9 @@
 }
 
+// TODO point of always returning 1?
 bool
 CognitiveRadioShell::UpdateParameterPerformance(int32_t socketFD)
 {
     char counter[55];
-    uint32_t numObservables,numParameters;
     char var[50];
     char buffer[256];
@@ -563,5 +562,5 @@
     memset(buffer, 0, 256);
     ReadMessage(commandSocketFD,buffer);
-    numParameters = atoi(buffer);
+    uint32_t numParameters = atoi(buffer);
   
     Parameter *p = new Parameter[numParameters];
@@ -579,5 +578,5 @@
     memset(buffer, 0, 256);
     ReadMessage(commandSocketFD, buffer);
-    numObservables = atoi(buffer);
+    uint32_t numObservables = atoi(buffer);
   
     Observable *o = new Observable[numObservables];
@@ -593,8 +592,7 @@
     }
 
-
     SendMessage(ceSocketFD, "update_performance");
    
-    // Send Parameters 
+    /* Send Parameters */
     memset(counter, 0, 55);
     sprintf(counter, "%i", numParameters);
@@ -607,5 +605,5 @@
     }   
     
-    // Send Observables
+    /* Send Observables */
     sprintf(counter, "%i", numObservables);
     SendMessage(ceSocketFD, counter);
@@ -615,7 +613,12 @@
         SendMessage(ceSocketFD, var); 
     }   
+
+    delete [] p;
+    delet [] o;
     
     return 1;
 }
+
+
 void
 CognitiveRadioShell::HandleMessage(int32_t socketFD)
@@ -625,4 +628,5 @@
     ReadMessage(socketFD, buffer);
 
+    // TODO trying to read this code lock makes my eyes bleed
     if(strcmp(buffer, "register_engine_cognitive") == 0) { 
         RegisterCognitiveEngine(socketFD);
@@ -639,20 +643,20 @@
     } else if(strcmp(buffer, "update_performance") == 0) {
         UpdateParameterPerformance(socketFD);
-    } else if(strcmp(buffer,"get_number_utilities") == 0) {
+    } else if(strcmp(buffer, "get_number_utilities") == 0) {
 		char numUtilities[20];
-		sprintf(numUtilities,"%i",radio_info->numUtilities);
-        SendMessage(commandSocketFD,numUtilities);
-    } else if(strcmp(buffer,"get_number_observables") == 0) {
+		sprintf(numUtilities, "%i", radio_info->numUtilities);
+        SendMessage(commandSocketFD, numUtilities);
+    } else if(strcmp(buffer, "get_number_observables") == 0) {
 		char numObservables[20];
-		sprintf(numObservables,"%i",radio_info->numObservables);
-        SendMessage(commandSocketFD,numObservables);
-    } else if(strcmp(buffer,"get_number_parameters") == 0) {
+		sprintf(numObservables, "%i", radio_info->numObservables);
+        SendMessage(commandSocketFD, numObservables);
+    } else if(strcmp(buffer, "get_number_parameters") == 0) {
 		char numParameters[20];
-		sprintf(numParameters,"%i",radio_info->numParameters);
-        SendMessage(commandSocketFD,numParameters);
-    } else if(strcmp(buffer,"request_optimization") == 0) {
+		sprintf(numParameters, "%i", radio_info->numParameters);
+        SendMessage(commandSocketFD, numParameters);
+    } else if(strcmp(buffer, "request_optimization") == 0) {
         /* Receive optimization request and current environment */
         GetOptimalParameters(socketFD);  
-    } else if(strcmp(buffer,"request_optimization_service") == 0) {
+    } else if(strcmp(buffer, "request_optimization_service") == 0) {
         /* Receive optimization request and current environment */
         //GetOptimalParametersService(socketFD);  
Index: vtcross/trunk/src/libvtcross/libvtcross_demo.cpp
===================================================================
--- vtcross/trunk/src/libvtcross/libvtcross_demo.cpp	(revision 230)
+++ vtcross/trunk/src/libvtcross/libvtcross_demo.cpp	(revision 231)
@@ -23,51 +23,49 @@
 main(int32_t argc, char *argv[])
 {
+	for(size_t i = 0; i < 10; i++) {
+        Observable *o = new Observable[2];
+        Parameter *currentParameters = new Parameter[2];
+        Parameter *p;
 
-	for(size_t i = 0; i < 10; i++) {
-    Observable *o = new Observable[2];
-    Parameter *currentParameters = new Parameter[2];
-    Parameter * p;
+        uint32_t numParameters;
+        uint32_t numObservables;
+        uint32_t numUtilities;
 
-	uint32_t numParameters;
-	uint32_t numObservables;
-	uint32_t numUtilities;
+        o[0].name = "throughput";
+        o[0].value = 150.00;
+        o[1].name = "PER";
+        o[1].value = 12.00;
 
-    o[0].name = "throughput";
-	o[0].value = 150.00;
-    o[1].name = "PER";
-	o[1].value = 12.00;
+        if(i == 0) {
+            currentParameters[0].name = "bandwidth";
+            currentParameters[0].value = 300.0;
+            currentParameters[1].name = "tx_power";
+            currentParameters[1].value = 10.0;
+        } else {
+            currentParameters[0].value = p[0].value;
+            currentParameters[1].value = p[1].value;
+        }
 
-	if(i == 0) {
-    currentParameters[0].name = "bandwidth";
-    currentParameters[0].value = 300.0;
-    currentParameters[1].name = "tx_power";
-    currentParameters[1].value = 10.0;
+        p = GetOptimalParameters(o,2,currentParameters,2);
+        numParameters = GetNumParameters();
+        numObservables = GetNumObservables();
+        numUtilities = GetNumUtilities();
 
-	} else {
-    currentParameters[0].value = p[0].value;
-    currentParameters[1].value = p[1].value;
-	}
-    p = GetOptimalParameters(o,2,currentParameters,2);
-    numParameters = GetNumParameters();
-    numObservables = GetNumObservables();
-    numUtilities = GetNumUtilities();
+        LOG("Application:: Received the following parameters.\n");
+        
+        for(size_t i = 0; i < numParameters; i++) {
+            LOG("%s:: %f\n", p[i].name.c_str(), p[i].value);
+        }
 
-	printf("Application:: Received the following parameters.\n");
-	
-	for(size_t i = 0; i < numParameters; i++) {
-		printf("%s:: %f\n",p[i].name.c_str(),p[i].value);
+        /* Try them out! Do they work? */
+        o[0].value = 0.5*p[0].value + .1*p[1].value;
+        o[1].value = 15-p[1].value;
+
+        UpdateParameterPerformance(p, numParameters, o, numObservables);	
+        
+        delete [] p; 
+        delete [] o; 
 	}
 
-	// Try them out! Do they work?
-    
-    o[0].value = 0.5*p[0].value + .1*p[1].value;
-    o[1].value = 15-p[1].value;
-
-	UpdateParameterPerformance(p,numParameters,o,numObservables);	
-	
-	
-	delete [] p; 
-    delete [] o; 
-	}
 	return 0;
 }
Index: vtcross/trunk/src/libvtcross/libvtcross.cpp
===================================================================
--- vtcross/trunk/src/libvtcross/libvtcross.cpp	(revision 230)
+++ vtcross/trunk/src/libvtcross/libvtcross.cpp	(revision 231)
@@ -21,22 +21,21 @@
 ConnectToRemoteComponent()
 {
-   	uint32_t socket; 
-    socket = ClientSocket("localhost", "40000");
-    
-    return socket;
+    // TODO why is this hardcoded like this??
+   	return ClientSocket("localhost", "40000");
 }
 
+// TODO the following three functions all do exactly the same thing.  Why not
+// simply combine them?
 uint32_t
 GetNumObservables()
 {
-	uint32_t socketfd, numObservables;
     char buffer[256];
 
-    socketfd = ConnectToRemoteComponent();
-    SendMessage(socketfd,"get_number_observables");
+    uint32_t socketfd = ConnectToRemoteComponent();
+    SendMessage(socketfd, "get_number_observables");
     
     memset(buffer, 0, 256);
     ReadMessage(socketfd, buffer);
-    numObservables = atoi(buffer);
+    uint32_t numObservables = atoi(buffer);
 	
 	return numObservables; 
@@ -46,13 +45,12 @@
 GetNumUtilities()
 {
-	uint32_t socketfd, numUtilities;
     char buffer[256];
 
-    socketfd = ConnectToRemoteComponent();
-    SendMessage(socketfd,"get_number_utilities");
+    uint32_t socketfd = ConnectToRemoteComponent();
+    SendMessage(socketfd, "get_number_utilities");
     
     memset(buffer, 0, 256);
     ReadMessage(socketfd, buffer);
-    numUtilities = atoi(buffer);
+    uint32_t numUtilities = atoi(buffer);
 	
 	return numUtilities; 
@@ -62,16 +60,16 @@
 GetNumParameters()
 {
-	uint32_t socketfd, numParameters;
     char buffer[256];
 
-    socketfd = ConnectToRemoteComponent();
-    SendMessage(socketfd,"get_number_parameters");
+    uint32_t socketfd = ConnectToRemoteComponent();
+    SendMessage(socketfd, "get_number_parameters");
     
     memset(buffer, 0, 256);
     ReadMessage(socketfd, buffer);
-    numParameters = atoi(buffer);
+    uint32_t numParameters = atoi(buffer);
 	
 	return numParameters; 
 }
+// end previous TODO
 
 /* Given a certain set of observables, ask the radio to find the optimum radio
@@ -85,7 +83,8 @@
  * memory when it is done using it.
  */
-Parameter* GetOptimalParameters(Observable *radioObservables, uint32_t numObservables,
-		Parameter *currentParameters, uint32_t numCurrentParameters) {
-    uint32_t i,socketfd,numParameters;
+Parameter* 
+GetOptimalParameters(Observable *radioObservables, uint32_t numObservables,
+		Parameter *currentParameters, uint32_t numCurrentParameters)
+{
     char var[50];
     char counter[55];
@@ -99,5 +98,5 @@
      */
 
-    // Send Observables
+    /* Send Observables */
     sprintf(counter, "%i", numObservables);
     SendMessage(socketFD, counter);
@@ -108,10 +107,9 @@
     }
 
-    // Send Parameters 
+    /* Send Parameters */
     memset(counter, 0, 55);
     sprintf(counter, "%i", numCurrentParameters);
     SendMessage(socketFD, counter);
-	
-	for(i = 0; i < numCurrentParameters; i++) {
+	for(size_t i = 0; i < numCurrentParameters; i++) {
         SendMessage(socketFD,currentParameters[i].name.c_str());
         sprintf(var,"%f",currentParameters[i].value);
@@ -122,5 +120,5 @@
     memset(buffer, 0, 256);
     ReadMessage(socketFD, buffer);
-    numParameters = atoi(buffer);
+    uint32_t numParameters = atoi(buffer);
     Parameter *pList = new Parameter[numParameters];
     
@@ -154,7 +152,7 @@
 	
 	for(size_t i = 0; i < numParameters; i++) {
-        SendMessage(socketFD,p[i].name.c_str());
-        sprintf(var,"%f",p[i].value);
-        SendMessage(socketFD,var);	
+        SendMessage(socketFD, p[i].name.c_str());
+        sprintf(var, "%f", p[i].value);
+        SendMessage(socketFD, var);	
     }
     
