diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index b072440..33e71a3 100755
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -104,9 +104,6 @@
 clean-local:
 	$(RM) -r gen-cpp
 
-style-local:
-	$(CPPSTYLE_CMD)
-
 EXTRA_DIST = \
 	src/TestClient.cpp \
 	src/TestServer.cpp \
diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp
index fa468a4..dfe8350 100644
--- a/test/cpp/src/StressTest.cpp
+++ b/test/cpp/src/StressTest.cpp
@@ -40,7 +40,7 @@
 #include <sstream>
 #include <map>
 #if _WIN32
-#include <thrift/windows/TWinsockSingleton.h>
+   #include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -54,18 +54,23 @@
 using namespace test::stress;
 
 struct eqstr {
-  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
+  bool operator()(const char* s1, const char* s2) const {
+    return strcmp(s1, s2) == 0;
+  }
 };
 
 struct ltstr {
-  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
+  bool operator()(const char* s1, const char* s2) const {
+    return strcmp(s1, s2) < 0;
+  }
 };
 
+
 // typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
 typedef map<const char*, int, ltstr> count_map;
 
 class Server : public ServiceIf {
-public:
+ public:
   Server() {}
 
   void count(const char* method) {
@@ -84,46 +89,43 @@
     return counts_;
   }
 
-  int8_t echoByte(const int8_t arg) { return arg; }
-  int32_t echoI32(const int32_t arg) { return arg; }
-  int64_t echoI64(const int64_t arg) { return arg; }
-  void echoString(string& out, const string& arg) {
+  int8_t echoByte(const int8_t arg) {return arg;}
+  int32_t echoI32(const int32_t arg) {return arg;}
+  int64_t echoI64(const int64_t arg) {return arg;}
+  void echoString(string& out, const string &arg) {
     if (arg != "hello") {
       T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
     }
     out = arg;
   }
-  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
-  void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
-  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
+  void echoList(vector<int8_t> &out, const vector<int8_t> &arg) { out = arg; }
+  void echoSet(set<int8_t> &out, const set<int8_t> &arg) { out = arg; }
+  void echoMap(map<int8_t, int8_t> &out, const map<int8_t, int8_t> &arg) { out = arg; }
 
 private:
   count_map counts_;
   Mutex lock_;
+
 };
 
-class ClientThread : public Runnable {
+class ClientThread: public Runnable {
 public:
-  ClientThread(boost::shared_ptr<TTransport> transport,
-               boost::shared_ptr<ServiceClient> client,
-               Monitor& monitor,
-               size_t& workerCount,
-               size_t loopCount,
-               TType loopType)
-    : _transport(transport),
-      _client(client),
-      _monitor(monitor),
-      _workerCount(workerCount),
-      _loopCount(loopCount),
-      _loopType(loopType) {}
+
+  ClientThread(boost::shared_ptr<TTransport>transport, boost::shared_ptr<ServiceClient> client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) :
+    _transport(transport),
+    _client(client),
+    _monitor(monitor),
+    _workerCount(workerCount),
+    _loopCount(loopCount),
+    _loopType(loopType)
+  {}
 
   void run() {
 
     // Wait for all worker threads to start
 
-    {
-      Synchronized s(_monitor);
-      while (_workerCount == 0) {
+    {Synchronized s(_monitor);
+      while(_workerCount == 0) {
         _monitor.wait();
       }
     }
@@ -132,25 +134,13 @@
 
     _transport->open();
 
-    switch (_loopType) {
-    case T_VOID:
-      loopEchoVoid();
-      break;
-    case T_BYTE:
-      loopEchoByte();
-      break;
-    case T_I32:
-      loopEchoI32();
-      break;
-    case T_I64:
-      loopEchoI64();
-      break;
-    case T_STRING:
-      loopEchoString();
-      break;
-    default:
-      cerr << "Unexpected loop type" << _loopType << endl;
-      break;
+    switch(_loopType) {
+    case T_VOID: loopEchoVoid(); break;
+    case T_BYTE: loopEchoByte(); break;
+    case T_I32: loopEchoI32(); break;
+    case T_I64: loopEchoI64(); break;
+    case T_STRING: loopEchoString(); break;
+    default: cerr << "Unexpected loop type" << _loopType << endl; break;
     }
 
     _endTime = Util::currentTime();
@@ -159,8 +149,7 @@
 
     _done = true;
 
-    {
-      Synchronized s(_monitor);
+    {Synchronized s(_monitor);
 
       _workerCount--;
 
@@ -181,7 +170,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int8_t arg = 1;
       int8_t result;
-      result = _client->echoByte(arg);
+      result =_client->echoByte(arg);
       (void)result;
       assert(result == arg);
     }
@@ -191,7 +180,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int32_t arg = 1;
       int32_t result;
-      result = _client->echoI32(arg);
+      result =_client->echoI32(arg);
       (void)result;
       assert(result == arg);
     }
@@ -201,7 +190,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int64_t arg = 1;
       int64_t result;
-      result = _client->echoI64(arg);
+      result =_client->echoI64(arg);
       (void)result;
       assert(result == arg);
     }
@@ -228,26 +217,28 @@
   Monitor _sleep;
 };
 
-class TStartObserver : public apache::thrift::server::TServerEventHandler {
+class TStartObserver : public apache::thrift::server::TServerEventHandler
+{
 public:
-  TStartObserver() : awake_(false) {}
-  virtual void preServe() {
-    apache::thrift::concurrency::Synchronized s(m_);
-    awake_ = true;
-    m_.notifyAll();
-  }
-  void waitForService() {
-    apache::thrift::concurrency::Synchronized s(m_);
-    while (!awake_)
-      m_.waitForever();
-  }
-
-private:
-  apache::thrift::concurrency::Monitor m_;
-  bool awake_;
+   TStartObserver() : awake_(false) {}
+   virtual void preServe()
+   {
+      apache::thrift::concurrency::Synchronized s(m_);
+      awake_ = true;
+      m_.notifyAll();
+   }
+   void waitForService()
+   {
+      apache::thrift::concurrency::Synchronized s(m_);
+      while(!awake_)
+         m_.waitForever();
+   }
+ private:
+   apache::thrift::concurrency::Monitor m_;
+   bool awake_;
 };
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
 #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
@@ -258,7 +249,7 @@
   size_t workerCount = 4;
   size_t clientCount = 20;
   size_t loopCount = 50000;
-  TType loopType = T_VOID;
+  TType loopType  = T_VOID;
   string callName = "echoVoid";
   bool runServer = true;
   bool logRequests = false;
@@ -267,34 +258,28 @@
 
   ostringstream usage;
 
-  usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
-                      "[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
-                      "[--clients=<client-count>] [--loop=<loop-count>]" << endl
-        << "\tclients        Number of client threads to create - 0 implies no clients, i.e. "
-           "server only.  Default is " << clientCount << endl
-        << "\thelp           Prints this help text." << endl
-        << "\tcall           Service method to call.  Default is " << callName << endl
-        << "\tloop           The number of remote thrift calls each client makes.  Default is "
-        << loopCount << endl << "\tport           The port the server and clients should bind to "
-                                "for thrift network connections.  Default is " << port << endl
-        << "\tserver         Run the Thrift server in this process.  Default is " << runServer
-        << endl << "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is "
-        << serverType << endl
-        << "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is "
-        << protocolType << endl
-        << "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests
-        << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
-        << replayRequests << endl << "\tworkers        Number of thread pools workers.  Only valid "
-                                     "for thread-pool server type.  Default is " << workerCount
-        << endl;
+  usage <<
+    argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] [--protocol-type=<protocol-type>] [--workers=<worker-count>] [--clients=<client-count>] [--loop=<loop-count>]" << endl <<
+    "\tclients        Number of client threads to create - 0 implies no clients, i.e. server only.  Default is " << clientCount << endl <<
+    "\thelp           Prints this help text." << endl <<
+    "\tcall           Service method to call.  Default is " << callName << endl <<
+    "\tloop           The number of remote thrift calls each client makes.  Default is " << loopCount << endl <<
+    "\tport           The port the server and clients should bind to for thrift network connections.  Default is " << port << endl <<
+    "\tserver         Run the Thrift server in this process.  Default is " << runServer << endl <<
+    "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is " << serverType << endl <<
+    "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is " << protocolType << endl <<
+    "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests << endl <<
+    "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl <<
+    "\tworkers        Number of thread pools workers.  Only valid for thread-pool server type.  Default is " << workerCount << endl;
 
-  map<string, string> args;
+
+  map<string, string>  args;
 
   for (int ix = 1; ix < argc; ix++) {
 
     string arg(argv[ix]);
 
-    if (arg.compare(0, 2, "--") == 0) {
+    if (arg.compare(0,2, "--") == 0) {
 
       size_t end = arg.find_first_of("=", 2);
 
@@ -306,7 +291,7 @@
         args[key] = "true";
       }
     } else {
-      throw invalid_argument("Unexcepted command line token: " + arg);
+      throw invalid_argument("Unexcepted command line token: "+arg);
     }
   }
 
@@ -356,7 +341,7 @@
 
       } else {
 
-        throw invalid_argument("Unknown server type " + serverType);
+        throw invalid_argument("Unknown server type "+serverType);
       }
     }
 
@@ -364,13 +349,12 @@
       workerCount = atoi(args["workers"].c_str());
     }
 
-  } catch (std::exception& e) {
+  } catch(std::exception& e) {
     cerr << e.what() << endl;
     cerr << usage.str();
   }
 
-  boost::shared_ptr<PlatformThreadFactory> threadFactory
-      = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  boost::shared_ptr<PlatformThreadFactory> threadFactory = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
   boost::shared_ptr<Server> serviceHandler(new Server());
@@ -388,12 +372,15 @@
     // Protocol Factory
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
+    TFileProcessor fileProcessor(serviceProcessor,
+                                 protocolFactory,
+                                 fileTransport);
 
     fileProcessor.process(0, true);
     exit(0);
   }
 
+
   if (runServer) {
 
     boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
@@ -413,34 +400,27 @@
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
-      transportFactory
-          = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+      transportFactory =
+        boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
     boost::shared_ptr<TServer> server;
 
     if (serverType == "simple") {
 
-      server.reset(
-          new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
+      server.reset(new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
 
     } else if (serverType == "threaded") {
 
-      server.reset(
-          new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
+      server.reset(new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
 
     } else if (serverType == "thread-pool") {
 
-      boost::shared_ptr<ThreadManager> threadManager
-          = ThreadManager::newSimpleThreadManager(workerCount);
+      boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
       threadManager->start();
-      server.reset(new TThreadPoolServer(serviceProcessor,
-                                         serverSocket,
-                                         transportFactory,
-                                         protocolFactory,
-                                         threadManager));
+      server.reset(new TThreadPoolServer(serviceProcessor, serverSocket, transportFactory, protocolFactory, threadManager));
     }
 
     boost::shared_ptr<TStartObserver> observer(new TStartObserver);
@@ -466,19 +446,12 @@
 
     set<boost::shared_ptr<Thread> > clientThreads;
 
-    if (callName == "echoVoid") {
-      loopType = T_VOID;
-    } else if (callName == "echoByte") {
-      loopType = T_BYTE;
-    } else if (callName == "echoI32") {
-      loopType = T_I32;
-    } else if (callName == "echoI64") {
-      loopType = T_I64;
-    } else if (callName == "echoString") {
-      loopType = T_STRING;
-    } else {
-      throw invalid_argument("Unknown service call " + callName);
-    }
+    if (callName == "echoVoid") { loopType = T_VOID;}
+    else if (callName == "echoByte") { loopType = T_BYTE;}
+    else if (callName == "echoI32") { loopType = T_I32;}
+    else if (callName == "echoI64") { loopType = T_I64;}
+    else if (callName == "echoString") { loopType = T_STRING;}
+    else {throw invalid_argument("Unknown service call "+callName);}
 
     for (size_t ix = 0; ix < clientCount; ix++) {
 
@@ -487,34 +460,30 @@
       boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
       boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
-          new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
+      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
-         thread != clientThreads.end();
-         thread++) {
+    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) {
       (*thread)->start();
     }
 
     int64_t time00;
     int64_t time01;
 
-    {
-      Synchronized s(monitor);
+    {Synchronized s(monitor);
       threadCount = clientCount;
 
-      cerr << "Launch " << clientCount << " client threads" << endl;
+      cerr << "Launch "<< clientCount << " client threads" << endl;
 
-      time00 = Util::currentTime();
+      time00 =  Util::currentTime();
 
       monitor.notifyAll();
 
-      while (threadCount > 0) {
+      while(threadCount > 0) {
         monitor.wait();
       }
 
-      time01 = Util::currentTime();
+      time01 =  Util::currentTime();
     }
 
     int64_t firstTime = 9223372036854775807LL;
@@ -524,12 +493,9 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
-         ix != clientThreads.end();
-         ix++) {
+    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) {
 
-      boost::shared_ptr<ClientThread> client
-          = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      boost::shared_ptr<ClientThread> client = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;
 
@@ -551,13 +517,13 @@
         maxTime = delta;
       }
 
-      averageTime += delta;
+      averageTime+= delta;
     }
 
     averageTime /= clientCount;
 
-    cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
-         << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+
+    cout <<  "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
 
     count_map count = serviceHandler->getCount();
     count_map::iterator iter;
diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp
index 8f161c0..20320c7 100644
--- a/test/cpp/src/StressTestNonBlocking.cpp
+++ b/test/cpp/src/StressTestNonBlocking.cpp
@@ -43,7 +43,7 @@
 #include <sstream>
 #include <map>
 #if _WIN32
-#include <thrift/windows/TWinsockSingleton.h>
+   #include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -57,18 +57,23 @@
 using namespace test::stress;
 
 struct eqstr {
-  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
+  bool operator()(const char* s1, const char* s2) const {
+    return strcmp(s1, s2) == 0;
+  }
 };
 
 struct ltstr {
-  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
+  bool operator()(const char* s1, const char* s2) const {
+    return strcmp(s1, s2) < 0;
+  }
 };
 
+
 // typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
 typedef map<const char*, int, ltstr> count_map;
 
 class Server : public ServiceIf {
-public:
+ public:
   Server() {}
 
   void count(const char* method) {
@@ -89,73 +94,58 @@
     return counts_;
   }
 
-  int8_t echoByte(const int8_t arg) { return arg; }
-  int32_t echoI32(const int32_t arg) { return arg; }
-  int64_t echoI64(const int64_t arg) { return arg; }
-  void echoString(string& out, const string& arg) {
+  int8_t echoByte(const int8_t arg) {return arg;}
+  int32_t echoI32(const int32_t arg) {return arg;}
+  int64_t echoI64(const int64_t arg) {return arg;}
+  void echoString(string& out, const string &arg) {
     if (arg != "hello") {
       T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
     }
     out = arg;
   }
-  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
-  void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
-  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
+  void echoList(vector<int8_t> &out, const vector<int8_t> &arg) { out = arg; }
+  void echoSet(set<int8_t> &out, const set<int8_t> &arg) { out = arg; }
+  void echoMap(map<int8_t, int8_t> &out, const map<int8_t, int8_t> &arg) { out = arg; }
 
 private:
   count_map counts_;
   Mutex lock_;
+
 };
 
-class ClientThread : public Runnable {
+class ClientThread: public Runnable {
 public:
-  ClientThread(boost::shared_ptr<TTransport> transport,
-               boost::shared_ptr<ServiceClient> client,
-               Monitor& monitor,
-               size_t& workerCount,
-               size_t loopCount,
-               TType loopType)
-    : _transport(transport),
-      _client(client),
-      _monitor(monitor),
-      _workerCount(workerCount),
-      _loopCount(loopCount),
-      _loopType(loopType) {}
+
+  ClientThread(boost::shared_ptr<TTransport>transport, boost::shared_ptr<ServiceClient> client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) :
+    _transport(transport),
+    _client(client),
+    _monitor(monitor),
+    _workerCount(workerCount),
+    _loopCount(loopCount),
+    _loopType(loopType)
+  {}
 
   void run() {
 
     // Wait for all worker threads to start
 
-    {
-      Synchronized s(_monitor);
-      while (_workerCount == 0) {
-        _monitor.wait();
-      }
+    {Synchronized s(_monitor);
+        while(_workerCount == 0) {
+          _monitor.wait();
+        }
     }
 
     _startTime = Util::currentTime();
 
     _transport->open();
 
-    switch (_loopType) {
-    case T_VOID:
-      loopEchoVoid();
-      break;
-    case T_BYTE:
-      loopEchoByte();
-      break;
-    case T_I32:
-      loopEchoI32();
-      break;
-    case T_I64:
-      loopEchoI64();
-      break;
-    case T_STRING:
-      loopEchoString();
-      break;
-    default:
-      cerr << "Unexpected loop type" << _loopType << endl;
-      break;
+    switch(_loopType) {
+    case T_VOID: loopEchoVoid(); break;
+    case T_BYTE: loopEchoByte(); break;
+    case T_I32: loopEchoI32(); break;
+    case T_I64: loopEchoI64(); break;
+    case T_STRING: loopEchoString(); break;
+    default: cerr << "Unexpected loop type" << _loopType << endl; break;
     }
 
     _endTime = Util::currentTime();
@@ -164,8 +154,7 @@
 
     _done = true;
 
-    {
-      Synchronized s(_monitor);
+    {Synchronized s(_monitor);
 
       _workerCount--;
 
@@ -186,7 +175,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int8_t arg = 1;
       int8_t result;
-      result = _client->echoByte(arg);
+      result =_client->echoByte(arg);
       (void)result;
       assert(result == arg);
     }
@@ -196,7 +185,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int32_t arg = 1;
       int32_t result;
-      result = _client->echoI32(arg);
+      result =_client->echoI32(arg);
       (void)result;
       assert(result == arg);
     }
@@ -206,7 +195,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int64_t arg = 1;
       int64_t result;
-      result = _client->echoI64(arg);
+      result =_client->echoI64(arg);
       (void)result;
       assert(result == arg);
     }
@@ -233,7 +222,8 @@
   Monitor _sleep;
 };
 
-int main(int argc, char** argv) {
+
+int main(int argc, char **argv) {
 #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
@@ -244,7 +234,7 @@
   uint32_t workerCount = 4;
   uint32_t clientCount = 20;
   uint32_t loopCount = 1000;
-  TType loopType = T_VOID;
+  TType loopType  = T_VOID;
   string callName = "echoVoid";
   bool runServer = true;
   bool logRequests = false;
@@ -253,34 +243,28 @@
 
   ostringstream usage;
 
-  usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
-                      "[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
-                      "[--clients=<client-count>] [--loop=<loop-count>]" << endl
-        << "\tclients        Number of client threads to create - 0 implies no clients, i.e. "
-           "server only.  Default is " << clientCount << endl
-        << "\thelp           Prints this help text." << endl
-        << "\tcall           Service method to call.  Default is " << callName << endl
-        << "\tloop           The number of remote thrift calls each client makes.  Default is "
-        << loopCount << endl << "\tport           The port the server and clients should bind to "
-                                "for thrift network connections.  Default is " << port << endl
-        << "\tserver         Run the Thrift server in this process.  Default is " << runServer
-        << endl << "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is "
-        << serverType << endl
-        << "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is "
-        << protocolType << endl
-        << "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests
-        << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
-        << replayRequests << endl << "\tworkers        Number of thread pools workers.  Only valid "
-                                     "for thread-pool server type.  Default is " << workerCount
-        << endl;
+  usage <<
+    argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] [--protocol-type=<protocol-type>] [--workers=<worker-count>] [--clients=<client-count>] [--loop=<loop-count>]" << endl <<
+    "\tclients        Number of client threads to create - 0 implies no clients, i.e. server only.  Default is " << clientCount << endl <<
+    "\thelp           Prints this help text." << endl <<
+    "\tcall           Service method to call.  Default is " << callName << endl <<
+    "\tloop           The number of remote thrift calls each client makes.  Default is " << loopCount << endl <<
+    "\tport           The port the server and clients should bind to for thrift network connections.  Default is " << port << endl <<
+    "\tserver         Run the Thrift server in this process.  Default is " << runServer << endl <<
+    "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is " << serverType << endl <<
+    "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is " << protocolType << endl <<
+    "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests << endl <<
+    "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl <<
+    "\tworkers        Number of thread pools workers.  Only valid for thread-pool server type.  Default is " << workerCount << endl;
 
-  map<string, string> args;
+
+  map<string, string>  args;
 
   for (int ix = 1; ix < argc; ix++) {
 
     string arg(argv[ix]);
 
-    if (arg.compare(0, 2, "--") == 0) {
+    if (arg.compare(0,2, "--") == 0) {
 
       size_t end = arg.find_first_of("=", 2);
 
@@ -292,7 +276,7 @@
         args[key] = "true";
       }
     } else {
-      throw invalid_argument("Unexcepted command line token: " + arg);
+      throw invalid_argument("Unexcepted command line token: "+arg);
     }
   }
 
@@ -339,13 +323,12 @@
       workerCount = atoi(args["workers"].c_str());
     }
 
-  } catch (std::exception& e) {
+  } catch(std::exception& e) {
     cerr << e.what() << endl;
     cerr << usage.str();
   }
 
-  boost::shared_ptr<PlatformThreadFactory> threadFactory
-      = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  boost::shared_ptr<PlatformThreadFactory> threadFactory = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
   boost::shared_ptr<Server> serviceHandler(new Server());
@@ -363,12 +346,15 @@
     // Protocol Factory
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
+    TFileProcessor fileProcessor(serviceProcessor,
+                                 protocolFactory,
+                                 fileTransport);
 
     fileProcessor.process(0, true);
     exit(0);
   }
 
+
   if (runServer) {
 
     boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
@@ -377,7 +363,7 @@
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     // Transport Factory
-    boost::shared_ptr<TTransportFactory> transportFactory;
+    boost::shared_ptr<TTransportFactory>      transportFactory;
 
     if (logRequests) {
       // initialize the log file
@@ -385,8 +371,8 @@
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
-      transportFactory
-          = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+      transportFactory =
+        boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
     boost::shared_ptr<Thread> serverThread;
@@ -394,22 +380,17 @@
 
     if (serverType == "simple") {
 
-      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
-          new TNonblockingServer(serviceProcessor, protocolFactory, port)));
-      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
-          new TNonblockingServer(serviceProcessor, protocolFactory, port + 1)));
+      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port)));
+      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port+1)));
 
     } else if (serverType == "thread-pool") {
 
-      boost::shared_ptr<ThreadManager> threadManager
-          = ThreadManager::newSimpleThreadManager(workerCount);
+      boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
       threadManager->start();
-      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
-          new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager)));
-      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
-          new TNonblockingServer(serviceProcessor, protocolFactory, port + 1, threadManager)));
+      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager)));
+      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port+1, threadManager)));
     }
 
     cerr << "Starting the server on port " << port << " and " << (port + 1) << endl;
@@ -433,19 +414,12 @@
 
     set<boost::shared_ptr<Thread> > clientThreads;
 
-    if (callName == "echoVoid") {
-      loopType = T_VOID;
-    } else if (callName == "echoByte") {
-      loopType = T_BYTE;
-    } else if (callName == "echoI32") {
-      loopType = T_I32;
-    } else if (callName == "echoI64") {
-      loopType = T_I64;
-    } else if (callName == "echoString") {
-      loopType = T_STRING;
-    } else {
-      throw invalid_argument("Unknown service call " + callName);
-    }
+    if (callName == "echoVoid") { loopType = T_VOID;}
+    else if (callName == "echoByte") { loopType = T_BYTE;}
+    else if (callName == "echoI32") { loopType = T_I32;}
+    else if (callName == "echoI64") { loopType = T_I64;}
+    else if (callName == "echoString") { loopType = T_STRING;}
+    else {throw invalid_argument("Unknown service call "+callName);}
 
     for (uint32_t ix = 0; ix < clientCount; ix++) {
 
@@ -454,34 +428,30 @@
       boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
       boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
-          new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
+      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
-         thread != clientThreads.end();
-         thread++) {
+    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) {
       (*thread)->start();
     }
 
     int64_t time00;
     int64_t time01;
 
-    {
-      Synchronized s(monitor);
+    {Synchronized s(monitor);
       threadCount = clientCount;
 
-      cerr << "Launch " << clientCount << " client threads" << endl;
+      cerr << "Launch "<< clientCount << " client threads" << endl;
 
-      time00 = Util::currentTime();
+      time00 =  Util::currentTime();
 
       monitor.notifyAll();
 
-      while (threadCount > 0) {
+      while(threadCount > 0) {
         monitor.wait();
       }
 
-      time01 = Util::currentTime();
+      time01 =  Util::currentTime();
     }
 
     int64_t firstTime = 9223372036854775807LL;
@@ -491,12 +461,9 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
-         ix != clientThreads.end();
-         ix++) {
+    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) {
 
-      boost::shared_ptr<ClientThread> client
-          = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      boost::shared_ptr<ClientThread> client = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;
 
@@ -518,13 +485,13 @@
         maxTime = delta;
       }
 
-      averageTime += delta;
+      averageTime+= delta;
     }
 
     averageTime /= clientCount;
 
-    cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
-         << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+
+    cout <<  "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
 
     count_map count = serviceHandler->getCount();
     count_map::iterator iter;
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
old mode 100644
new mode 100755
index a6069de..8c97dc0
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -36,7 +36,7 @@
 #include <boost/filesystem.hpp>
 #include <thrift/cxxfunctional.h>
 #if _WIN32
-#include <thrift/windows/TWinsockSingleton.h>
+   #include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 #include "ThriftTest.h"
@@ -51,27 +51,24 @@
 // Length of argv[0] - Length of script dir
 #define EXECUTABLE_FILE_NAME_LENGTH 19
 
-// extern uint32_t g_socket_syscalls;
+//extern uint32_t g_socket_syscalls;
 
 // Current time, microseconds since the epoch
-uint64_t now() {
+uint64_t now()
+{
   int64_t ret;
   struct timeval tv;
 
   THRIFT_GETTIMEOFDAY(&tv, NULL);
   ret = tv.tv_sec;
-  ret = ret * 1000 * 1000 + tv.tv_usec;
+  ret = ret*1000*1000 + tv.tv_usec;
   return ret;
 }
 
-static void testString_clientReturn(const char* host,
-                                    int port,
-                                    event_base* base,
-                                    TProtocolFactory* protocolFactory,
-                                    ThriftTestCobClient* client) {
-  (void)host;
-  (void)port;
-  (void)protocolFactory;
+static void testString_clientReturn(const char* host, int port, event_base *base, TProtocolFactory* protocolFactory, ThriftTestCobClient* client) {
+  (void) host;
+  (void) port;
+  (void) protocolFactory;
   try {
     string s;
     client->recv_testString(s);
@@ -83,11 +80,7 @@
   event_base_loopbreak(base); // end test
 }
 
-static void testVoid_clientReturn(const char* host,
-                                  int port,
-                                  event_base* base,
-                                  TProtocolFactory* protocolFactory,
-                                  ThriftTestCobClient* client) {
+static void testVoid_clientReturn(const char* host, int port, event_base *base, TProtocolFactory* protocolFactory, ThriftTestCobClient* client) {
   try {
     client->recv_testVoid();
     cout << "testVoid" << endl;
@@ -96,13 +89,7 @@
     delete client;
     boost::shared_ptr<TAsyncChannel> channel(new TEvhttpClientChannel(host, "/", host, port, base));
     client = new ThriftTestCobClient(channel, protocolFactory);
-    client->testString(tcxx::bind(testString_clientReturn,
-                                  host,
-                                  port,
-                                  base,
-                                  protocolFactory,
-                                  tcxx::placeholders::_1),
-                       "Test");
+    client->testString(tcxx::bind(testString_clientReturn, host, port, base, protocolFactory, tcxx::placeholders::_1), "Test");
   } catch (TException& exn) {
     cout << "Error: " << exn.what() << endl;
   }
@@ -110,7 +97,7 @@
 
 int main(int argc, char** argv) {
   string file_path = boost::filesystem::system_complete(argv[0]).string();
-  string dir_path = file_path.substr(0, file_path.size() - EXECUTABLE_FILE_NAME_LENGTH);
+  string dir_path = file_path.substr(0, file_path.size()-EXECUTABLE_FILE_NAME_LENGTH);
 #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
@@ -124,26 +111,17 @@
   bool noinsane = false;
 
   boost::program_options::options_description desc("Allowed options");
-  desc.add_options()("help,h",
-                     "produce help message")("host",
-                                             boost::program_options::value<string>(&host)
-                                                 ->default_value(host),
-                                             "Host to connect")("port",
-                                                                boost::program_options::value<int>(
-                                                                    &port)->default_value(port),
-                                                                "Port number to connect")(
-      "domain-socket",
-      boost::program_options::value<string>(&domain_socket)->default_value(domain_socket),
-      "Domain Socket (e.g. /tmp/ThriftTest.thrift), instead of host and port")(
-      "transport",
-      boost::program_options::value<string>(&transport_type)->default_value(transport_type),
-      "Transport: buffered, framed, http, evhttp")(
-      "protocol",
-      boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
-      "Protocol: binary, compact, json")("ssl", "Encrypted Transport using SSL")(
-      "testloops,n",
-      boost::program_options::value<int>(&numTests)->default_value(numTests),
-      "Number of Tests")("noinsane", "Do not run insanity test");
+  desc.add_options()
+      ("help,h", "produce help message")
+      ("host", boost::program_options::value<string>(&host)->default_value(host), "Host to connect")
+      ("port", boost::program_options::value<int>(&port)->default_value(port), "Port number to connect")
+	  ("domain-socket", boost::program_options::value<string>(&domain_socket)->default_value(domain_socket), "Domain Socket (e.g. /tmp/ThriftTest.thrift), instead of host and port")
+      ("transport", boost::program_options::value<string>(&transport_type)->default_value(transport_type), "Transport: buffered, framed, http, evhttp")
+      ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type), "Protocol: binary, compact, json")
+	  ("ssl", "Encrypted Transport using SSL")
+      ("testloops,n", boost::program_options::value<int>(&numTests)->default_value(numTests), "Number of Tests")
+      ("noinsane", "Do not run insanity test")
+  ;
 
   boost::program_options::variables_map vm;
   boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
@@ -160,17 +138,17 @@
       } else if (protocol_type == "compact") {
       } else if (protocol_type == "json") {
       } else {
-        throw invalid_argument("Unknown protocol type " + protocol_type);
+          throw invalid_argument("Unknown protocol type "+protocol_type);
       }
     }
 
-    if (!transport_type.empty()) {
+	if (!transport_type.empty()) {
       if (transport_type == "buffered") {
       } else if (transport_type == "framed") {
       } else if (transport_type == "http") {
       } else if (transport_type == "evhttp") {
       } else {
-        throw invalid_argument("Unknown transport type " + transport_type);
+          throw invalid_argument("Unknown transport type "+transport_type);
       }
     }
 
@@ -204,7 +182,8 @@
     if (domain_socket != "") {
       socket = boost::shared_ptr<TSocket>(new TSocket(domain_socket));
       port = 0;
-    } else {
+    }
+    else {
       socket = boost::shared_ptr<TSocket>(new TSocket(host, port));
     }
   }
@@ -212,10 +191,10 @@
   if (transport_type.compare("http") == 0) {
     boost::shared_ptr<TTransport> httpSocket(new THttpClient(socket, host, "/service"));
     transport = httpSocket;
-  } else if (transport_type.compare("framed") == 0) {
+  } else if (transport_type.compare("framed") == 0){
     boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
     transport = framedSocket;
-  } else {
+  } else{
     boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket));
     transport = bufferedSocket;
   }
@@ -226,7 +205,7 @@
   } else if (protocol_type.compare("compact") == 0) {
     boost::shared_ptr<TProtocol> compactProtocol(new TCompactProtocol(transport));
     protocol = compactProtocol;
-  } else {
+  } else{
     boost::shared_ptr<TBinaryProtocol> binaryProtocol(new TBinaryProtocol(transport));
     protocol = binaryProtocol;
   }
@@ -239,7 +218,7 @@
   cout << endl;
 
   if (transport_type.compare("evhttp") == 0) {
-    event_base* base = event_base_new();
+    event_base *base = event_base_new();
     cout << "Libevent Version: " << event_get_version() << endl;
     cout << "Libevent Method: " << event_base_get_method(base) << endl;
 #if LIBEVENT_VERSION_NUMBER >= 0x02000000
@@ -248,20 +227,15 @@
 
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    boost::shared_ptr<TAsyncChannel> channel(
-        new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base));
+    boost::shared_ptr<TAsyncChannel> channel(new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base));
     ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get());
-    client->testVoid(tcxx::bind(testVoid_clientReturn,
-                                host.c_str(),
-                                port,
-                                base,
-                                protocolFactory.get(),
-                                tcxx::placeholders::_1));
+    client->testVoid(tcxx::bind(testVoid_clientReturn, host.c_str(), port, base, protocolFactory.get(), tcxx::placeholders::_1));
 
     event_base_loop(base, 0);
     return 0;
   }
 
+
   ThriftTestClient testClient(protocol);
 
   uint64_t time_min = 0;
@@ -282,7 +256,7 @@
     /**
      * CONNECT TEST
      */
-    printf("Test #%d, connect %s:%d\n", test + 1, host.c_str(), port);
+    printf("Test #%d, connect %s:%d\n", test+1, host.c_str(), port);
 
     uint64_t start = now();
 
@@ -306,7 +280,7 @@
     testClient.testString(s, "Test");
     printf(" = \"%s\"\n", s.c_str());
     if (s != "Test")
-      failCount++;
+        failCount++;
 
     /**
      * BYTE TEST
@@ -315,7 +289,7 @@
     uint8_t u8 = testClient.testByte(1);
     printf(" = %d\n", (int)u8);
     if (u8 != 1)
-      failCount++;
+        failCount++;
 
     /**
      * I32 TEST
@@ -324,7 +298,7 @@
     int32_t i32 = testClient.testI32(-1);
     printf(" = %d\n", i32);
     if (i32 != -1)
-      failCount++;
+        failCount++;
 
     /**
      * I64 TEST
@@ -333,7 +307,7 @@
     int64_t i64 = testClient.testI64(-34359738368LL);
     printf(" = %" PRId64 "\n", i64);
     if (i64 != -34359738368LL)
-      failCount++;
+        failCount++;
     /**
      * DOUBLE TEST
      */
@@ -341,7 +315,7 @@
     double dub = testClient.testDouble(-5.2098523);
     printf(" = %f\n", dub);
     if ((dub - (-5.2098523)) > 0.001)
-      failCount++;
+        failCount++;
 
     /**
      * STRUCT TEST
@@ -360,7 +334,7 @@
            in.i32_thing,
            in.i64_thing);
     if (in != out)
-      failCount++;
+    	failCount++;
 
     /**
      * NESTED STRUCT TEST
@@ -381,14 +355,14 @@
            in.i64_thing,
            in2.i32_thing);
     if (in2 != out2)
-      failCount++;
+    	failCount++;
 
     /**
      * MAP TEST
      */
-    map<int32_t, int32_t> mapout;
+    map<int32_t,int32_t> mapout;
     for (int32_t i = 0; i < 5; ++i) {
-      mapout.insert(make_pair(i, i - 10));
+      mapout.insert(make_pair(i, i-10));
     }
     printf("testMap({");
     map<int32_t, int32_t>::const_iterator m_iter;
@@ -402,7 +376,7 @@
       printf("%d => %d", m_iter->first, m_iter->second);
     }
     printf("})");
-    map<int32_t, int32_t> mapin;
+    map<int32_t,int32_t> mapin;
     testClient.testMap(mapin, mapout);
     printf(" = {");
     first = true;
@@ -416,7 +390,7 @@
     }
     printf("}\n");
     if (mapin != mapout)
-      failCount++;
+    	failCount++;
 
     /**
      * STRING MAP TEST
@@ -456,7 +430,7 @@
     }
     printf("}\n");
     if (setin != setout)
-      failCount++;
+    	failCount++;
 
     /**
      * LIST TEST
@@ -491,7 +465,7 @@
     }
     printf("}\n");
     if (listin != listout)
-      failCount++;
+    	failCount++;
 
     /**
      * ENUM TEST
@@ -500,31 +474,31 @@
     Numberz::type ret = testClient.testEnum(Numberz::ONE);
     printf(" = %d\n", ret);
     if (ret != Numberz::ONE)
-      failCount++;
+    	failCount++;
 
     printf("testEnum(TWO)");
     ret = testClient.testEnum(Numberz::TWO);
     printf(" = %d\n", ret);
     if (ret != Numberz::TWO)
-      failCount++;
+    	failCount++;
 
     printf("testEnum(THREE)");
     ret = testClient.testEnum(Numberz::THREE);
     printf(" = %d\n", ret);
     if (ret != Numberz::THREE)
-      failCount++;
+    	failCount++;
 
     printf("testEnum(FIVE)");
     ret = testClient.testEnum(Numberz::FIVE);
     printf(" = %d\n", ret);
     if (ret != Numberz::FIVE)
-      failCount++;
+    	failCount++;
 
     printf("testEnum(EIGHT)");
     ret = testClient.testEnum(Numberz::EIGHT);
     printf(" = %d\n", ret);
     if (ret != Numberz::EIGHT)
-      failCount++;
+    	failCount++;
 
     /**
      * TYPEDEF TEST
@@ -533,7 +507,7 @@
     UserId uid = testClient.testTypedef(309858235082523LL);
     printf(" = %" PRId64 "\n", uid);
     if (uid != 309858235082523LL)
-      failCount++;
+    	failCount++;
 
     /**
      * NESTED MAP TEST
@@ -566,14 +540,16 @@
       truck.i64_thing = 8;
       insane.xtructs.push_back(truck);
       printf("testInsanity()");
-      map<UserId, map<Numberz::type, Insanity> > whoa;
+      map<UserId, map<Numberz::type,Insanity> > whoa;
       testClient.testInsanity(whoa, insane);
       printf(" = {");
-      map<UserId, map<Numberz::type, Insanity> >::const_iterator i_iter;
+      map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
       for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
         printf("%" PRId64 " => {", i_iter->first);
-        map<Numberz::type, Insanity>::const_iterator i2_iter;
-        for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) {
+        map<Numberz::type,Insanity>::const_iterator i2_iter;
+        for (i2_iter = i_iter->second.begin();
+             i2_iter != i_iter->second.end();
+             ++i2_iter) {
           printf("%d => {", i2_iter->first);
           map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
           map<Numberz::type, UserId>::const_iterator um;
@@ -609,25 +585,25 @@
       printf("  void\nFAILURE\n");
       failCount++;
 
-    } catch (Xception& e) {
+    } catch(Xception& e) {
       printf("  {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
     }
 
     try {
-      printf("testClient.testException(\"TException\") =>");
-      testClient.testException("TException");
-      printf("  void\nFAILURE\n");
-      failCount++;
+        printf("testClient.testException(\"TException\") =>");
+        testClient.testException("TException");
+        printf("  void\nFAILURE\n");
+        failCount++;
 
-    } catch (const TException&) {
-      printf("  Caught TException\n");
-    }
+      } catch(const TException&) {
+        printf("  Caught TException\n");
+      }
 
     try {
       printf("testClient.testException(\"success\") =>");
       testClient.testException("success");
       printf("  void\n");
-    } catch (...) {
+    } catch(...) {
       printf("  exception\nFAILURE\n");
       failCount++;
     }
@@ -640,7 +616,7 @@
       testClient.testMultiException(result, "Xception", "test 1");
       printf("  result\nFAILURE\n");
       failCount++;
-    } catch (Xception& e) {
+    } catch(Xception& e) {
       printf("  {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
     }
 
@@ -651,7 +627,7 @@
       printf("  result\nFAILURE\n");
       failCount++;
 
-    } catch (Xception2& e) {
+    } catch(Xception2& e) {
       printf("  {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str());
     }
 
@@ -660,23 +636,23 @@
       Xtruct result;
       testClient.testMultiException(result, "success", "test 3");
       printf("  {{\"%s\"}}\n", result.string_thing.c_str());
-    } catch (...) {
+    } catch(...) {
       printf("  exception\nFAILURE\n");
       failCount++;
     }
 
     /* test oneway void */
     {
-      printf("testClient.testOneway(1) =>");
-      uint64_t startOneway = now();
-      testClient.testOneway(1);
-      uint64_t elapsed = now() - startOneway;
-      if (elapsed > 200 * 1000) { // 0.2 seconds
-        printf("  FAILURE - took %.2f ms\n", (double)elapsed / 1000.0);
-        failCount++;
-      } else {
-        printf("  success - took %.2f ms\n", (double)elapsed / 1000.0);
-      }
+        printf("testClient.testOneway(1) =>");
+        uint64_t startOneway = now();
+        testClient.testOneway(1);
+        uint64_t elapsed = now() - startOneway;
+        if (elapsed > 200 * 1000) { // 0.2 seconds
+            printf("  FAILURE - took %.2f ms\n", (double)elapsed/1000.0);
+            failCount++;
+        } else {
+            printf("  success - took %.2f ms\n", (double)elapsed/1000.0);
+        }
     }
 
     /**
@@ -694,12 +670,13 @@
     i32 = testClient.testI32(-1);
     printf(" = %d\n", i32);
     if (i32 != -1)
-      failCount++;
+        failCount++;
+
 
     uint64_t stop = now();
-    uint64_t tot = stop - start;
+    uint64_t tot = stop-start;
 
-    printf("Total time: %" PRIu64 " us\n", stop - start);
+    printf("Total time: %" PRIu64 " us\n", stop-start);
 
     time_tot += tot;
     if (time_min == 0 || tot < time_min) {
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
old mode 100644
new mode 100755
index 6d2a260..a343221
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -50,7 +50,7 @@
 
 #include <signal.h>
 #if _WIN32
-#include <thrift/windows/TWinsockSingleton.h>
+   #include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -68,12 +68,14 @@
 #define EXECUTABLE_FILE_NAME_LENGTH 19
 
 class TestHandler : public ThriftTestIf {
-public:
+ public:
   TestHandler() {}
 
-  void testVoid() { printf("testVoid()\n"); }
+  void testVoid() {
+    printf("testVoid()\n");
+  }
 
-  void testString(string& out, const string& thing) {
+  void testString(string& out, const string &thing) {
     printf("testString(\"%s\")\n", thing.c_str());
     out = thing;
   }
@@ -98,28 +100,18 @@
     return thing;
   }
 
-  void testStruct(Xtruct& out, const Xtruct& thing) {
-    printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
-           thing.string_thing.c_str(),
-           (int)thing.byte_thing,
-           thing.i32_thing,
-           thing.i64_thing);
+  void testStruct(Xtruct& out, const Xtruct &thing) {
+    printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
     out = thing;
   }
 
   void testNest(Xtruct2& out, const Xtruct2& nest) {
-    const Xtruct& thing = nest.struct_thing;
-    printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n",
-           (int)nest.byte_thing,
-           thing.string_thing.c_str(),
-           (int)thing.byte_thing,
-           thing.i32_thing,
-           thing.i64_thing,
-           nest.i32_thing);
+    const Xtruct &thing = nest.struct_thing;
+    printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
     out = nest;
   }
 
-  void testMap(map<int32_t, int32_t>& out, const map<int32_t, int32_t>& thing) {
+  void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) {
     printf("testMap({");
     map<int32_t, int32_t>::const_iterator m_iter;
     bool first = true;
@@ -135,8 +127,7 @@
     out = thing;
   }
 
-  void testStringMap(map<std::string, std::string>& out,
-                     const map<std::string, std::string>& thing) {
+  void testStringMap(map<std::string, std::string> &out, const map<std::string, std::string> &thing) {
     printf("testMap({");
     map<std::string, std::string>::const_iterator m_iter;
     bool first = true;
@@ -152,7 +143,7 @@
     out = thing;
   }
 
-  void testSet(set<int32_t>& out, const set<int32_t>& thing) {
+  void testSet(set<int32_t> &out, const set<int32_t> &thing) {
     printf("testSet({");
     set<int32_t>::const_iterator s_iter;
     bool first = true;
@@ -168,7 +159,7 @@
     out = thing;
   }
 
-  void testList(vector<int32_t>& out, const vector<int32_t>& thing) {
+  void testList(vector<int32_t> &out, const vector<int32_t> &thing) {
     printf("testList({");
     vector<int32_t>::const_iterator l_iter;
     bool first = true;
@@ -194,22 +185,23 @@
     return thing;
   }
 
-  void testMapMap(map<int32_t, map<int32_t, int32_t> >& mapmap, const int32_t hello) {
+  void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) {
     printf("testMapMap(%d)\n", hello);
 
-    map<int32_t, int32_t> pos;
-    map<int32_t, int32_t> neg;
+    map<int32_t,int32_t> pos;
+    map<int32_t,int32_t> neg;
     for (int i = 1; i < 5; i++) {
-      pos.insert(make_pair(i, i));
-      neg.insert(make_pair(-i, -i));
+      pos.insert(make_pair(i,i));
+      neg.insert(make_pair(-i,-i));
     }
 
     mapmap.insert(make_pair(4, pos));
     mapmap.insert(make_pair(-4, neg));
+
   }
 
-  void testInsanity(map<UserId, map<Numberz::type, Insanity> >& insane, const Insanity& argument) {
-    (void)argument;
+  void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) {
+    (void) argument;
     printf("testInsanity()\n");
 
     Xtruct hello;
@@ -245,11 +237,13 @@
 
     printf("return");
     printf(" = {");
-    map<UserId, map<Numberz::type, Insanity> >::const_iterator i_iter;
+    map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
     for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
       printf("%" PRId64 " => {", i_iter->first);
-      map<Numberz::type, Insanity>::const_iterator i2_iter;
-      for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) {
+      map<Numberz::type,Insanity>::const_iterator i2_iter;
+      for (i2_iter = i_iter->second.begin();
+           i2_iter != i_iter->second.end();
+           ++i2_iter) {
         printf("%d => {", i2_iter->first);
         map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
         map<Numberz::type, UserId>::const_iterator um;
@@ -263,11 +257,7 @@
         vector<Xtruct>::const_iterator x;
         printf("{");
         for (x = xtructs.begin(); x != xtructs.end(); ++x) {
-          printf("{\"%s\", %d, %d, %" PRId64 "}, ",
-                 x->string_thing.c_str(),
-                 (int)x->byte_thing,
-                 x->i32_thing,
-                 x->i64_thing);
+          printf("{\"%s\", %d, %d, %" PRId64 "}, ", x->string_thing.c_str(), (int)x->byte_thing, x->i32_thing, x->i64_thing);
         }
         printf("}");
 
@@ -276,18 +266,14 @@
       printf("}, ");
     }
     printf("}\n");
+
+
   }
 
-  void testMulti(Xtruct& hello,
-                 const int8_t arg0,
-                 const int32_t arg1,
-                 const int64_t arg2,
-                 const std::map<int16_t, std::string>& arg3,
-                 const Numberz::type arg4,
-                 const UserId arg5) {
-    (void)arg3;
-    (void)arg4;
-    (void)arg5;
+  void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string>  &arg3, const Numberz::type arg4, const UserId arg5) {
+    (void) arg3;
+    (void) arg4;
+    (void) arg5;
 
     printf("testMulti()\n");
 
@@ -297,7 +283,9 @@
     hello.i64_thing = (int64_t)arg2;
   }
 
-  void testException(const std::string& arg) throw(Xception, apache::thrift::TException) {
+  void testException(const std::string &arg)
+    throw(Xception, apache::thrift::TException)
+  {
     printf("testException(%s)\n", arg.c_str());
     if (arg.compare("Xception") == 0) {
       Xception e;
@@ -314,9 +302,7 @@
     }
   }
 
-  void testMultiException(Xtruct& result,
-                          const std::string& arg0,
-                          const std::string& arg1) throw(Xception, Xception2) {
+  void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) {
 
     printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
 
@@ -343,23 +329,28 @@
   }
 };
 
+
 class TestProcessorEventHandler : public TProcessorEventHandler {
   virtual void* getContext(const char* fn_name, void* serverContext) {
-    (void)serverContext;
+    (void) serverContext;
     return new std::string(fn_name);
   }
   virtual void freeContext(void* ctx, const char* fn_name) {
-    (void)fn_name;
+    (void) fn_name;
     delete static_cast<std::string*>(ctx);
   }
-  virtual void preRead(void* ctx, const char* fn_name) { communicate("preRead", ctx, fn_name); }
+  virtual void preRead(void* ctx, const char* fn_name) {
+    communicate("preRead", ctx, fn_name);
+  }
   virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void)bytes;
+    (void) bytes;
     communicate("postRead", ctx, fn_name);
   }
-  virtual void preWrite(void* ctx, const char* fn_name) { communicate("preWrite", ctx, fn_name); }
+  virtual void preWrite(void* ctx, const char* fn_name) {
+    communicate("preWrite", ctx, fn_name);
+  }
   virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void)bytes;
+    (void) bytes;
     communicate("postWrite", ctx, fn_name);
   }
   virtual void asyncComplete(void* ctx, const char* fn_name) {
@@ -374,6 +365,7 @@
   }
 };
 
+
 class TestHandlerAsync : public ThriftTestCobSvIf {
 public:
   TestHandlerAsync(boost::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
@@ -384,8 +376,7 @@
     cob();
   }
 
-  virtual void testString(tcxx::function<void(std::string const& _return)> cob,
-                          const std::string& thing) {
+  virtual void testString(tcxx::function<void(std::string const& _return)> cob, const std::string& thing) {
     std::string res;
     _delegate->testString(res, thing);
     cob(res);
@@ -423,37 +414,31 @@
     cob(res);
   }
 
-  virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob,
-                       const std::map<int32_t, int32_t>& thing) {
+  virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t>  const& _return)> cob, const std::map<int32_t, int32_t> & thing) {
     std::map<int32_t, int32_t> res;
     _delegate->testMap(res, thing);
     cob(res);
   }
 
-  virtual void testStringMap(
-      tcxx::function<void(std::map<std::string, std::string> const& _return)> cob,
-      const std::map<std::string, std::string>& thing) {
+  virtual void testStringMap(tcxx::function<void(std::map<std::string, std::string>  const& _return)> cob, const std::map<std::string, std::string> & thing) {
     std::map<std::string, std::string> res;
     _delegate->testStringMap(res, thing);
     cob(res);
   }
 
-  virtual void testSet(tcxx::function<void(std::set<int32_t> const& _return)> cob,
-                       const std::set<int32_t>& thing) {
+  virtual void testSet(tcxx::function<void(std::set<int32_t>  const& _return)> cob, const std::set<int32_t> & thing) {
     std::set<int32_t> res;
     _delegate->testSet(res, thing);
     cob(res);
   }
 
-  virtual void testList(tcxx::function<void(std::vector<int32_t> const& _return)> cob,
-                        const std::vector<int32_t>& thing) {
+  virtual void testList(tcxx::function<void(std::vector<int32_t>  const& _return)> cob, const std::vector<int32_t> & thing) {
     std::vector<int32_t> res;
     _delegate->testList(res, thing);
     cob(res);
   }
 
-  virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob,
-                        const Numberz::type thing) {
+  virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob, const Numberz::type thing) {
     Numberz::type res = _delegate->testEnum(thing);
     cob(res);
   }
@@ -463,56 +448,39 @@
     cob(res);
   }
 
-  virtual void testMapMap(
-      tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
-      const int32_t hello) {
+  virtual void testMapMap(tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> >  const& _return)> cob, const int32_t hello) {
     std::map<int32_t, std::map<int32_t, int32_t> > res;
     _delegate->testMapMap(res, hello);
     cob(res);
   }
 
-  virtual void testInsanity(
-      tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
-      const Insanity& argument) {
+  virtual void testInsanity(tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> >  const& _return)> cob, const Insanity& argument) {
     std::map<UserId, std::map<Numberz::type, Insanity> > res;
     _delegate->testInsanity(res, argument);
     cob(res);
-  }
+ }
 
-  virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob,
-                         const int8_t arg0,
-                         const int32_t arg1,
-                         const int64_t arg2,
-                         const std::map<int16_t, std::string>& arg3,
-                         const Numberz::type arg4,
-                         const UserId arg5) {
+  virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> & arg3, const Numberz::type arg4, const UserId arg5) {
     Xtruct res;
     _delegate->testMulti(res, arg0, arg1, arg2, arg3, arg4, arg5);
     cob(res);
   }
 
-  virtual void testException(
-      tcxx::function<void()> cob,
-      tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
-      const std::string& arg) {
+  virtual void testException(tcxx::function<void()> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg) {
     try {
       _delegate->testException(arg);
-    } catch (const apache::thrift::TException& e) {
+    } catch(const apache::thrift::TException& e) {
       exn_cob(apache::thrift::TDelayedException::delayException(e));
       return;
     }
     cob();
   }
 
-  virtual void testMultiException(
-      tcxx::function<void(Xtruct const& _return)> cob,
-      tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
-      const std::string& arg0,
-      const std::string& arg1) {
+  virtual void testMultiException(tcxx::function<void(Xtruct const& _return)> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg0, const std::string& arg1) {
     Xtruct res;
     try {
       _delegate->testMultiException(res, arg0, arg1);
-    } catch (const apache::thrift::TException& e) {
+    } catch(const apache::thrift::TException& e) {
       exn_cob(apache::thrift::TDelayedException::delayException(e));
       return;
     }
@@ -528,12 +496,13 @@
   boost::shared_ptr<TestHandler> _delegate;
 };
 
-int main(int argc, char** argv) {
+
+int main(int argc, char **argv) {
 
   string file_path = boost::filesystem::system_complete(argv[0]).string();
-  string dir_path = file_path.substr(0, file_path.size() - EXECUTABLE_FILE_NAME_LENGTH);
+  string dir_path = file_path.substr(0, file_path.size()-EXECUTABLE_FILE_NAME_LENGTH);
 
-#if _WIN32
+  #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
   int port = 9090;
@@ -544,35 +513,32 @@
   string domain_socket = "";
   size_t workers = 4;
 
+
   boost::program_options::options_description desc("Allowed options");
-  desc.add_options()("help,h", "produce help message")(
-      "port",
-      boost::program_options::value<int>(&port)->default_value(port),
-      "Port number to listen")("domain-socket",
-                               boost::program_options::value<string>(&domain_socket)
-                                   ->default_value(domain_socket),
-                               "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")(
-      "server-type",
-      boost::program_options::value<string>(&server_type)->default_value(server_type),
-      "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")(
-      "transport",
-      boost::program_options::value<string>(&transport_type)->default_value(transport_type),
-      "transport: buffered, framed, http")(
-      "protocol",
-      boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
-      "protocol: binary, compact, json")("ssl", "Encrypted Transport using SSL")(
-      "processor-events",
-      "processor-events")("workers,n",
-                          boost::program_options::value<size_t>(&workers)->default_value(workers),
-                          "Number of thread pools workers. Only valid for thread-pool server type");
+  desc.add_options()
+      ("help,h", "produce help message")
+      ("port", boost::program_options::value<int>(&port)->default_value(port), "Port number to listen")
+	  ("domain-socket", boost::program_options::value<string>(&domain_socket)->default_value(domain_socket),
+	    "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")
+      ("server-type", boost::program_options::value<string>(&server_type)->default_value(server_type),
+        "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")
+      ("transport", boost::program_options::value<string>(&transport_type)->default_value(transport_type),
+        "transport: buffered, framed, http")
+      ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
+        "protocol: binary, compact, json")
+	  ("ssl", "Encrypted Transport using SSL")
+	  ("processor-events", "processor-events")
+      ("workers,n", boost::program_options::value<size_t>(&workers)->default_value(workers),
+        "Number of thread pools workers. Only valid for thread-pool server type")
+  ;
 
   boost::program_options::variables_map vm;
   boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
   boost::program_options::notify(vm);
 
   if (vm.count("help")) {
-    cout << desc << "\n";
-    return 1;
+      cout << desc << "\n";
+      return 1;
   }
 
   try {
@@ -582,7 +548,7 @@
       } else if (server_type == "threaded") {
       } else if (server_type == "nonblocking") {
       } else {
-        throw invalid_argument("Unknown server type " + server_type);
+          throw invalid_argument("Unknown server type "+server_type);
       }
     }
 
@@ -591,7 +557,7 @@
       } else if (protocol_type == "compact") {
       } else if (protocol_type == "json") {
       } else {
-        throw invalid_argument("Unknown protocol type " + protocol_type);
+          throw invalid_argument("Unknown protocol type "+protocol_type);
       }
     }
 
@@ -600,7 +566,7 @@
       } else if (transport_type == "framed") {
       } else if (transport_type == "http") {
       } else {
-        throw invalid_argument("Unknown transport type " + transport_type);
+          throw invalid_argument("Unknown transport type "+transport_type);
       }
     }
 
@@ -623,8 +589,7 @@
     boost::shared_ptr<TProtocolFactory> compactProtocolFactory(new TCompactProtocolFactory());
     protocolFactory = compactProtocolFactory;
   } else {
-    boost::shared_ptr<TProtocolFactory> binaryProtocolFactory(
-        new TBinaryProtocolFactoryT<TBufferBase>());
+    boost::shared_ptr<TProtocolFactory> binaryProtocolFactory(new TBinaryProtocolFactoryT<TBufferBase>());
     protocolFactory = binaryProtocolFactory;
   }
 
@@ -633,8 +598,8 @@
   boost::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler));
 
   if (vm.count("processor-events")) {
-    testProcessor->setEventHandler(
-        boost::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler()));
+    testProcessor->setEventHandler(boost::shared_ptr<TProcessorEventHandler>(
+          new TestProcessorEventHandler()));
   }
 
   // Transport
@@ -672,8 +637,8 @@
   }
 
   // Server Info
-  cout << "Starting \"" << server_type << "\" server (" << transport_type << "/" << protocol_type
-       << ") listen on: " << domain_socket;
+  cout << "Starting \"" << server_type << "\" server ("
+    << transport_type << "/" << protocol_type << ") listen on: " << domain_socket;
   if (port != 0) {
     cout << port;
   }
@@ -683,13 +648,17 @@
   boost::shared_ptr<apache::thrift::server::TServer> server;
 
   if (server_type == "simple") {
-    server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory));
+    server.reset(new TSimpleServer(testProcessor,
+                               serverSocket,
+                               transportFactory,
+                               protocolFactory));
   } else if (server_type == "thread-pool") {
 
-    boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
+    boost::shared_ptr<ThreadManager> threadManager =
+      ThreadManager::newSimpleThreadManager(workers);
 
-    boost::shared_ptr<PlatformThreadFactory> threadFactory
-        = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+    boost::shared_ptr<PlatformThreadFactory> threadFactory =
+      boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
     threadManager->threadFactory(threadFactory);
 
@@ -702,15 +671,15 @@
                                        threadManager));
   } else if (server_type == "threaded") {
 
-    server.reset(
-        new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory));
+    server.reset(new TThreadedServer(testProcessor,
+                                   serverSocket,
+                                   transportFactory,
+                                   protocolFactory));
   } else if (server_type == "nonblocking") {
-    if (transport_type == "http") {
+    if(transport_type == "http") {
       boost::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler));
-      boost::shared_ptr<TAsyncProcessor> testProcessorAsync(
-          new ThriftTestAsyncProcessor(testHandlerAsync));
-      boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(
-          new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
+      boost::shared_ptr<TAsyncProcessor> testProcessorAsync(new ThriftTestAsyncProcessor(testHandlerAsync));
+      boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
 
       // not loading nonblockingServer into "server" because
       // TEvhttpServer doesn't inherit from TServer, and doesn't
@@ -722,18 +691,17 @@
     }
   }
 
-  if (server.get() != NULL) {
+  if(server.get() != NULL)
+  {
     apache::thrift::concurrency::PlatformThreadFactory factory;
     factory.setDetached(false);
     boost::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server);
-    boost::shared_ptr<apache::thrift::concurrency::Thread> thread
-        = factory.newThread(serverThreadRunner);
+    boost::shared_ptr<apache::thrift::concurrency::Thread> thread = factory.newThread(serverThreadRunner);
     thread->start();
 
     // HACK: cross language test suite is unable to handle cin properly
     //       that's why we stay in a endless loop here
-    while (1) {
-    }
+    while(1){}
     // FIXME: find another way to stop the server (e.g. a signal)
     // cout<<"Press enter to stop the server."<<endl;
     // cin.ignore(); //wait until a key is pressed
diff --git a/test/cpp/src/ThriftTest_extras.cpp b/test/cpp/src/ThriftTest_extras.cpp
index af5606e..33f681f 100644
--- a/test/cpp/src/ThriftTest_extras.cpp
+++ b/test/cpp/src/ThriftTest_extras.cpp
@@ -22,12 +22,12 @@
 #include <thrift/protocol/TDebugProtocol.h>
 #include "gen-cpp/ThriftTest_types.h"
 
-namespace thrift {
-namespace test {
+
+namespace thrift { namespace test {
 
 bool Insanity::operator<(thrift::test::Insanity const& other) const {
   using apache::thrift::ThriftDebugString;
   return ThriftDebugString(*this) < ThriftDebugString(other);
 }
-}
-}
+
+}}
