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);
 }
-}
-}
+
+}}
