Index: code/branches/mergeFS18/src/libraries/network/Client.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Client.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Client.cc	(revision 12027)
@@ -166,15 +166,8 @@
           }
         }
-        //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
-//         if(gs){
-//           orxout(verbose, context::network) << "client tick: sending gs " << gs << endl;
-//           if( !gs->send() )
-//             orxout(internal_warning, context::network) << "Problem adding partial gamestate to queue" << endl;
-//         // gs gets automatically deleted by enet callback
-//         }
+
         FunctionCallManager::sendCalls(static_cast<Host*>(this));
       }
     }
-//     sendPackets(); // flush the enet queue
 
     Connection::processQueue();
@@ -185,6 +178,5 @@
         isSynched_=true;
     }
-//     GamestateManager::cleanup();;
-//     Connection::sendPackets();
+
 
     return;
Index: code/branches/mergeFS18/src/libraries/network/Client.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Client.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Client.h	(revision 12027)
@@ -90,5 +90,5 @@
   private:
     Client(const Client& copy); // not used
-    virtual bool isServer_() override{return false;}
+    virtual bool isServer_() override { return false; }
     virtual void processPacket(packet::Packet* packet) override;
 
Index: code/branches/mergeFS18/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/ClientConnection.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/ClientConnection.cc	(revision 12027)
@@ -105,6 +105,6 @@
       {
         // manually add server to list of peers
-        /*incomingEvent inEvent = */Connection::preprocessConnectEvent(event);
-//         addPeer(inEvent.peerID);
+        Connection::preprocessConnectEvent(event);
+
         // start communication thread
         this->established_=true;
@@ -155,5 +155,4 @@
     assert( this->server_ );
     assert( packet );
-//     return Connection::addPacket( packet, NETWORK_PEER_ID_SERVER, channelID );
     // HACK: actually there should be a way to do this using addPacket and the correct peerID
     return Connection::broadcastPacket(packet, channelID);
@@ -168,5 +167,5 @@
     this->established_=false;
     orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl;
-        // server closed the connection
+    // server closed the connection
     this->stopCommunicationThread();
     this->connectionClosed();
Index: code/branches/mergeFS18/src/libraries/network/ClientConnection.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/ClientConnection.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/ClientConnection.h	(revision 12027)
@@ -36,5 +36,5 @@
 {
 
-  class _NetworkExport ClientConnection: public Connection{
+  class _NetworkExport ClientConnection: public Connection {
   public:
     ClientConnection();
@@ -44,7 +44,4 @@
     void setPort( unsigned int port );
 
-//     ENetEvent *getEvent();
-    // check wheter the packet queue is empty
-//     bool queueEmpty();
     // create a new listener thread
     virtual bool establishConnection();
Index: code/branches/mergeFS18/src/libraries/network/ClientConnectionListener.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/ClientConnectionListener.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/ClientConnectionListener.cc	(revision 12027)
@@ -31,5 +31,4 @@
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
-// #include "ClientInformation.h"
 
 namespace orxonox
@@ -37,4 +36,8 @@
     RegisterAbstractClass(ClientConnectionListener).inheritsFrom<Listable>();
 
+    /**
+     * Constructor
+     * Register the object
+     */
     ClientConnectionListener::ClientConnectionListener()
     {
@@ -42,4 +45,8 @@
     }
 
+    /**
+     * Call clientConnected() on all ClientConnectionListeners.
+     * @param clientID The ID of the newly connected client
+     */
     void ClientConnectionListener::broadcastClientConnected(unsigned int clientID)
     {
@@ -48,4 +55,8 @@
     }
 
+    /**
+     * Call clientDisconnected() on all ClientConnectionListeners.
+     * @param clientID The ID of the newly disconnected client
+     */
     void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID)
     {
@@ -53,14 +64,4 @@
             listener->clientDisconnected(clientID);
     }
-
-//     void ClientConnectionListener::getConnectedClients()
-//     {
-//         ClientInformation* client = ClientInformation::getBegin();
-//         while (client)
-//         {
-//             this->clientConnected(client->getID());
-//             client = client->next();
-//         }
-//     }
 }
 
Index: code/branches/mergeFS18/src/libraries/network/ClientConnectionListener.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/ClientConnectionListener.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/ClientConnectionListener.h	(revision 12027)
@@ -35,4 +35,7 @@
 namespace orxonox
 {
+    /**
+     * An abstract base class. Derived classes must implement clientConnected() and clientDisconnected().
+     */
     class _NetworkExport ClientConnectionListener : virtual public Listable
     {
@@ -46,7 +49,4 @@
             virtual void clientConnected(unsigned int clientID) = 0;
             virtual void clientDisconnected(unsigned int clientID) = 0;
-
-        protected:
-//             void getConnectedClients();
     };
 }
Index: code/branches/mergeFS18/src/libraries/network/Connection.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Connection.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Connection.cc	(revision 12027)
@@ -38,4 +38,5 @@
 
 #include "packet/Packet.h"
+#include "util/Output.h"
 #include <util/Sleep.h>
 
@@ -45,20 +46,35 @@
   const unsigned int                NETWORK_DISCONNECT_TIMEOUT = 500;
 
+  /**
+   * Constructor
+   * @param firstPeerId The initial value of nextPeerID_
+   */
   Connection::Connection(uint32_t firstPeerID):
     host_(nullptr), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID)
   {
+    // Global initialization of ENet
     enet_initialize();
+
+    // Register enet_deinitialize to be executed when the program exits normally
     atexit(enet_deinitialize);
+
+    // Create mutexes for incoming and outgoing events
     this->incomingEventsMutex_ = new boost::mutex;
     this->outgoingEventsMutex_ = new boost::mutex;
-//     this->overallMutex_ = new boost::mutex;
-  }
-
+  }
+
+  /**
+   * Destructor
+   */
   Connection::~Connection()
   {
+    // Delete the mutexes
     delete this->incomingEventsMutex_;
     delete this->outgoingEventsMutex_;
   }
 
+  /**
+   * Start the main communication thread.
+   */
   void Connection::startCommunicationThread()
   {
@@ -67,10 +83,14 @@
   }
   
+  /**
+   * Stop the main communication thread.
+   */
   void Connection::stopCommunicationThread()
   {
     this->bCommunicationThreadRunning_ = false;
-    if( !this->communicationThread_->timed_join(NETWORK_COMMUNICATION_THREAD_WAIT_TIME) )
-    {
-      // force thread to stop
+    // Wait for peaceful termination
+    if(!this->communicationThread_->timed_join(NETWORK_COMMUNICATION_THREAD_WAIT_TIME))
+    {
+      // Force thread to stop if the waiting time runs out.
       this->communicationThread_->interrupt();
     }
@@ -78,7 +98,10 @@
   }
 
+  /**
+   * Send an outgoing event of type 'disconnectPeer'.
+   * @param peerID The peer to which the event is sent
+   */
   void Connection::disconnectPeer(uint32_t peerID)
   {
-//     this->overallMutex_->lock();
     outgoingEvent outEvent = { peerID, OutgoingEventType::disconnectPeer, nullptr, 0 };
     
@@ -86,7 +109,9 @@
     this->outgoingEvents_.push_back(outEvent);
     this->outgoingEventsMutex_->unlock();
-//     this->overallMutex_->unlock();
-  }
-  
+  }
+
+  /**
+   * Send an outgoing event of type 'disconnectPeers'.
+   */
   void Connection::disconnectPeers()
   {
@@ -98,7 +123,12 @@
   }
 
+  /**
+   * Send a packet.
+   * @param packet Pointer to the packet to send
+   * @param peerID The peer to which the event is sent
+   * @param channelId The channel ID
+   */
   void Connection::addPacket(ENetPacket* packet, uint32_t peerID, uint8_t channelID)
   {
-//     this->overallMutex_->lock();
     outgoingEvent outEvent = { peerID, OutgoingEventType::sendPacket, packet, channelID };
     
@@ -106,10 +136,13 @@
     this->outgoingEvents_.push_back(outEvent);
     this->outgoingEventsMutex_->unlock();
-//     this->overallMutex_->unlock();
-  }
-  
+  }
+  
+  /**
+   * Send a broadcast packet.
+   * @param packet Pointer to the packet to send
+   * @param channelId The channel ID
+   */
   void Connection::broadcastPacket(ENetPacket* packet, uint8_t channelID)
   {
-//     this->overallMutex_->lock();
     outgoingEvent outEvent = { 0, OutgoingEventType::broadcastPacket, packet, channelID };
     
@@ -117,24 +150,24 @@
     this->outgoingEvents_.push_back(outEvent);
     this->outgoingEventsMutex_->unlock();
-//     this->overallMutex_->unlock();
-  }
-
-  
+  }
+
+  
+  /**
+   * Main communication thread
+   */
   void Connection::communicationThread()
   {
     ENetEvent event;
     
-//     this->overallMutex_->lock();
-    while( bCommunicationThreadRunning_ )
+    while(this->bCommunicationThreadRunning_)
     {
       // Receive all pending incoming Events (such as packets, connects and disconnects)
-      while( enet_host_check_events( this->host_, &event ) > 0 )
+      while(enet_host_check_events(this->host_, &event ) > 0)
       {
-        processIncomingEvent(event);
+        this->processIncomingEvent(event);
       }
       
-//       this->overallMutex_->unlock();
+      // Sleep for 1ms
       msleep(1);
-//       this->overallMutex_->lock();
       
       // Send all waiting outgoing packets
@@ -142,7 +175,7 @@
       uint32_t outgoingEventsCount = this->outgoingEvents_.size();
       this->outgoingEventsMutex_->unlock();
-      while( outgoingEventsCount > 0 )
+
+      while(outgoingEventsCount > 0)
       {
-//         orxout(verbose, context::network) << "outgoing event" << endl;
         this->outgoingEventsMutex_->lock();
         outgoingEvent outEvent = this->outgoingEvents_.front();
@@ -150,5 +183,5 @@
         this->outgoingEventsMutex_->unlock();
         
-        processOutgoingEvent(outEvent);
+        this->processOutgoingEvent(outEvent);
         
         this->outgoingEventsMutex_->lock();
@@ -158,17 +191,20 @@
       
       // Wait for incoming events (at most NETWORK_WAIT_TIMEOUT ms)
-      if( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
+      if(enet_host_service(this->host_, &event, NETWORK_WAIT_TIMEOUT) > 0)
       {
-        processIncomingEvent(event);
+        this->processIncomingEvent(event);
       }
     }
-//     this->overallMutex_->unlock();
-  }
-  
+  }
+  
+  /**
+   * Handle an incoming event.
+   * @param event The incoming event
+   */
   void Connection::processIncomingEvent(ENetEvent& event)
   {
     incomingEvent inEvent;
     // preprocess event
-    switch( event.type )
+    switch(event.type)
     {
       case ENET_EVENT_TYPE_CONNECT:
@@ -192,25 +228,29 @@
   }
   
+  /**
+   * Send an event.
+   * @param event The event to send
+   */
   void Connection::processOutgoingEvent(outgoingEvent& event)
   {
     ENetPeer* peer;
-    switch( event.type )
+    switch(event.type)
     {
       case OutgoingEventType::sendPacket:
         // check whether the peer is still/already in the peer list
-        if( this->peerMap_.find(event.peerID) != this->peerMap_.end() )
+        if(this->peerMap_.find(event.peerID) != this->peerMap_.end())
         {
           peer = this->peerMap_[event.peerID];
-          enet_peer_send( peer, event.channelID, event.packet );
+          enet_peer_send(peer, event.channelID, event.packet);
         }
         else
         {
           // peer probably already disconnected so just discard packet
-          assert(event.peerID<this->nextPeerID_);
+          orxout(message) << "Trying to send packet to peer that is not in peer list. Ignoring packet." << endl;
           enet_packet_destroy(event.packet);
         }
         break;
       case OutgoingEventType::disconnectPeer:
-        if( this->peerMap_.find(event.peerID) != this->peerMap_.end() )
+        if(this->peerMap_.find(event.peerID) != this->peerMap_.end())
         {
           peer = this->peerMap_[event.peerID];
@@ -220,9 +260,9 @@
         {
           // peer probably already disconnected so just discard disconnect event
-          assert(event.peerID<this->nextPeerID_);
+          assert(event.peerID < this->nextPeerID_);
         }
         break;
       case OutgoingEventType::disconnectPeers:
-        disconnectPeersInternal();
+        this->disconnectPeersInternal();
         break;
       case OutgoingEventType::broadcastPacket:
@@ -234,5 +274,4 @@
   }
 
-
   void Connection::disconnectPeersInternal()
   {
@@ -241,5 +280,5 @@
       enet_peer_disconnect(mapEntry.second, 0);
     }
-    uint32_t iterations = NETWORK_DISCONNECT_TIMEOUT/NETWORK_WAIT_TIMEOUT;
+    uint32_t iterations = NETWORK_DISCONNECT_TIMEOUT / NETWORK_WAIT_TIMEOUT;
     uint32_t i = 0;
     while( this->peerMap_.size() && i++ < iterations )
@@ -361,4 +400,3 @@
   }
 
-
 }
Index: code/branches/mergeFS18/src/libraries/network/Connection.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Connection.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Connection.h	(revision 12027)
@@ -96,5 +96,5 @@
 
   protected:
-    Connection(uint32_t firstPeerID = NETWORK_PEER_ID_SERVER+1);
+    Connection(uint32_t firstPeerID = NETWORK_PEER_ID_SERVER + 1);
     
     void startCommunicationThread();
@@ -110,7 +110,7 @@
     void processQueue();
     void waitOutgoingQueue();     // wait for the outgoing queue to become empty (everything processed by communication thread)
-    virtual void addPeer(uint32_t peerID)=0;
-    virtual void removePeer(uint32_t peerID)=0;
-    virtual void processPacket( packet::Packet* packet)=0;
+    virtual void addPeer(uint32_t peerID) = 0;
+    virtual void removePeer(uint32_t peerID) = 0;
+    virtual void processPacket( packet::Packet* packet) = 0;
     
     incomingEvent preprocessConnectEvent(ENetEvent& event);
@@ -124,4 +124,5 @@
 
     ENetHost*                     host_;
+
   private:
     void communicationThread();
@@ -130,6 +131,11 @@
     bool                          bCommunicationThreadRunning_;
     ENetAddress*                  bindAddress_;
+
+    // Queue for incoming events
     std::deque<incomingEvent>     incomingEvents_;
+
+    // Queue for outgoing events
     std::deque<outgoingEvent>     outgoingEvents_;
+
     boost::mutex*                 incomingEventsMutex_;
     boost::mutex*                 outgoingEventsMutex_;
Index: code/branches/mergeFS18/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/FunctionCallManager.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/FunctionCallManager.cc	(revision 12027)
@@ -42,14 +42,20 @@
 void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
 {
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
+  // If the peerID doesn't exist yet in the map...
+  if(sPeerMap_.find(peerID) == sPeerMap_.end())
   {
+    // ... add a new FunctionCalls packet for the peer
     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
   }
+
+  // Add a new function call to the peer
   FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, mt1, mt2, mt3, mt4, mt5);
 }
 
-// Send calls
-
+/**
+ * Send all function calls in sPeerMap_ to a given host, then clear sPeerMap_
+ * @param host The host to send the function calls to
+ */
 void FunctionCallManager::sendCalls(orxonox::Host* host)
 {
@@ -62,4 +68,7 @@
 }
 
+/**
+ * Place an incoming function call in the queue for processing.
+ */
 void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID)
 {
@@ -67,8 +76,11 @@
 }
 
+/**
+ * Process queue of incoming function calls.
+ */
 void FunctionCallManager::processBufferedFunctionCalls()
 {
   std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t>>>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
-  while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
+  while( it != FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
   {
     OrxAssert( Host::getActiveInstance(), "No Host class existing" );
Index: code/branches/mergeFS18/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/FunctionCallManager.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/FunctionCallManager.h	(revision 12027)
@@ -53,6 +53,9 @@
   static void processBufferedFunctionCalls();
 
+  // Maps peer IDs to function calls
   static std::map<uint32_t, packet::FunctionCalls*>                           sPeerMap_;
+
   static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t>>> sIncomingFunctionCallBuffer_;
+
 protected:
   FunctionCallManager();
Index: code/branches/mergeFS18/src/libraries/network/GamestateHandler.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/GamestateHandler.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/GamestateHandler.cc	(revision 12027)
@@ -32,6 +32,4 @@
 namespace orxonox {
 
-// GamestateHandler *GamestateHandler::instance_=nullptr;
-
 GamestateHandler::GamestateHandler()
 {
Index: code/branches/mergeFS18/src/libraries/network/GamestateHandler.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/GamestateHandler.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/GamestateHandler.h	(revision 12027)
@@ -37,5 +37,6 @@
 
 /**
-    @author Oliver Scheuss
+ * An interface for any class that wants to handle gamestates.
+ * @author Oliver Scheuss
 */
 class _NetworkExport GamestateHandler
@@ -51,6 +52,6 @@
     virtual bool      addGamestate(packet::Gamestate* gs, unsigned int clientID) = 0;
     virtual bool      ackGamestate(unsigned int gamestateID, unsigned int clientID) = 0;
-    virtual uint32_t  getLastReceivedGamestateID( unsigned int clientID )=0;
-    virtual uint32_t  getCurrentGamestateID()=0;
+    virtual uint32_t  getLastReceivedGamestateID( unsigned int clientID ) = 0;
+    virtual uint32_t  getCurrentGamestateID() = 0;
 };
 
Index: code/branches/mergeFS18/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/GamestateManager.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/GamestateManager.cc	(revision 12027)
@@ -43,5 +43,4 @@
 #include <cassert>
 #include <queue>
-// #include <boost/thread/mutex.hpp>
 
 #include "packet/Acknowledgement.h"
@@ -55,5 +54,4 @@
 #include "util/Clock.h"
 #include "util/OrxAssert.h"
-// #include "TrafficControl.h"
 
 namespace orxonox
@@ -62,28 +60,31 @@
   currentGamestate_(nullptr), id_(0)
   {
-//     trafficControl_ = new TrafficControl();
-//     threadMutex_ = new boost::mutex();
-//     threadPool_ = new ThreadPool();
   }
 
   GamestateManager::~GamestateManager()
   {
-    if( this->currentGamestate_ )
-        delete this->currentGamestate_;
-    for( const auto& mapEntry : gamestateQueue )
-      delete mapEntry.second;
-    for( const auto& mapEntryPeer : peerMap_ )
-    {
-      for( const auto& mapEntryGamestate : mapEntryPeer.second.gamestates )
-        delete mapEntryGamestate.second;
-    }
-//     this->trafficControl_->destroy();
-//     delete this->threadMutex_;
-//     delete this->threadPool_;
-  }
-
-  bool GamestateManager::update(){
-//     cleanup();
-    return getSnapshot();
+    if(this->currentGamestate_)
+    {
+      delete this->currentGamestate_;
+      this->currentGamestate_ = nullptr;
+    }
+
+    for(const auto& gsPair : this->gamestateQueue)
+    {
+      delete gsPair.second;
+    }
+
+    for(const auto& peerPair : this->peerMap_)
+    {
+      for(const auto& gsPair : peerPair.second.gamestates)
+      {
+        delete gsPair.second;
+      }
+    }
+  }
+
+  bool GamestateManager::update()
+  {
+    return this->getSnapshot();
   }
 
@@ -91,37 +92,54 @@
   {
     assert(gs);
-    std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
-    if(it!=gamestateQueue.end())
+    // Search the queue for a gamestate for the client
+    std::map<unsigned int, packet::Gamestate*>::iterator it = this->gamestateQueue.find(clientID);
+    if(it != this->gamestateQueue.end())
     {
       // delete obsolete gamestate
       delete it->second;
     }
-    gamestateQueue[clientID] = gs;
+    // update the client's gamestate
+    this->gamestateQueue[clientID] = gs;
+
     return true;
   }
 
+  /**
+   * Process the queued gamestates.
+   */
   bool GamestateManager::processGamestates()
   {
-    if( this->gamestateQueue.empty() )
+    // Queue is empty, nothing to do
+    if(this->gamestateQueue.empty())
+    {
         return true;
+    }
+
     // now push only the most recent gamestates we received (ignore obsolete ones)
-    for(const auto& mapEntry : gamestateQueue)
-    {
-      OrxVerify(processGamestate(mapEntry.second), "ERROR: could not process Gamestate");
-      sendAck( mapEntry.second->getID(), mapEntry.second->getPeerID() );
-      delete mapEntry.second;
+    for(const auto& gsPair : this->gamestateQueue)
+    {
+      OrxVerify(this->processGamestate(gsPair.second), "ERROR: could not process Gamestate");
+      this->sendAck(gsPair.second->getID(), gsPair.second->getPeerID());
+      delete gsPair.second;
     }
     // now clear the queue
-    gamestateQueue.clear();
+    this->gamestateQueue.clear();
+
     //and call all queued callbacks
     NetworkCallbackManager::callCallbacks();
+
     return true;
   }
   
+  /**
+   * Send Acknowledgement packet.
+   * @param gamestateId The gamestate ID we want to acknowledge
+   * @param peerID The ID of the peer we want to send the Acknowledgement to
+   */
   bool GamestateManager::sendAck(unsigned int gamestateID, uint32_t peerID)
   {
-    assert( gamestateID != ACKID_NACK );
+    assert(gamestateID != ACKID_NACK);
     packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, peerID);
-    if( !this->sendPacket(ack))
+    if(!this->sendPacket(ack))
     {
       orxout(internal_warning, context::network) << "could not ack gamestate: " << gamestateID << endl;
@@ -135,21 +153,36 @@
   }
 
-
-  bool GamestateManager::getSnapshot(){
-    if ( currentGamestate_ != nullptr )
-      delete currentGamestate_;
+  /**
+   * Update the current gamestate.
+   */
+  bool GamestateManager::getSnapshot()
+  {
+    // Delete current gamestate
+    if (this->currentGamestate_)
+    {
+      delete this->currentGamestate_;
+      this->currentGamestate_ = nullptr;
+    }
+
     uint8_t gsMode;
-    if( GameMode::isMaster() )
+    if(GameMode::isMaster())
+    {
       gsMode = packet::GAMESTATE_MODE_SERVER;
-    else
+    }
+    else
+    {
       gsMode = packet::GAMESTATE_MODE_CLIENT;
+    }
+
     uint32_t newID;
-    if( GameMode::isMaster() )
-      newID = ++id_;
-    else
-    {
-      assert(peerMap_.size()!=0);
-      newID = peerMap_[NETWORK_PEER_ID_SERVER].lastReceivedGamestateID;
-      if( newID == GAMESTATEID_INITIAL )
+    if(GameMode::isMaster())
+    {
+      newID = ++this->id_;
+    }
+    else
+    {
+      assert(this->peerMap_.size() != 0);
+      newID = this->peerMap_[NETWORK_PEER_ID_SERVER].lastReceivedGamestateID;
+      if(newID == GAMESTATEID_INITIAL)
       {
         return false;
@@ -157,24 +190,31 @@
     }
     
-    currentGamestate_ = new packet::Gamestate();
-    
-    if(!currentGamestate_->collectData(newID, gsMode))
-    { //we have no data to send
-      delete currentGamestate_;
-      currentGamestate_=nullptr;
+    // Create a new gamestate
+    this->currentGamestate_ = new packet::Gamestate();
+    if(!this->currentGamestate_->collectData(newID, gsMode))
+    {
+      // we have no data to send
+      delete this->currentGamestate_;
+      this->currentGamestate_ = nullptr;
       return false;
     }
+
     return true;
   }
 
+  /**
+   * Return a vector with the gamestates of all peers.
+   */
   std::vector<packet::Gamestate*> GamestateManager::getGamestates()
   {
-    if(!currentGamestate_)
+    // Current gamestate is empty
+    if(!this->currentGamestate_){
       return std::vector<packet::Gamestate*>();
+    }
+
     std::vector<packet::Gamestate*> peerGamestates;
-    
-    for( const auto& mapEntry : peerMap_ )
-    {
-      if( !mapEntry.second.isSynched )
+    for(const auto& mapEntry : this->peerMap_)
+    {
+      if(!mapEntry.second.isSynched)
       {
         orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
@@ -198,16 +238,10 @@
       peerGamestates.push_back(nullptr);  // insert an empty gamestate* to be changed
       finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ );
-      if( peerGamestates.back()==nullptr )
+      if(peerGamestates.back() == nullptr)
+      {
         // nothing to send to remove pointer from vector
         peerGamestates.pop_back();
-      //FunctorMember<GamestateManager>* functor =
-//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
-//       executor->setDefaultValues( cid, &clientGamestates.back(), client, currentGamestate_ );
-//       (*static_cast<Executor*>(executor))();
-//       this->threadPool_->passFunction( executor, true );
-//       (*functor)( cid, &(clientGamestates.back()), client, currentGamestate_ );
-    }
-
-//     threadPool_->synchronise();
+      }
+    }
 
     return peerGamestates;
@@ -215,19 +249,14 @@
 
 
-  void GamestateManager::finishGamestate( unsigned int peerID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) {
-    //why are we searching the same client's gamestate id as we searched in
-    //Server::sendGameState?
+  void GamestateManager::finishGamestate(unsigned int peerID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate)
+  {
     // save the (undiffed) gamestate in the clients gamestate map
-    //chose wheather the next gamestate is the first or not
-
-//     packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
-//       packet::Gamestate* gs = new packet::Gamestate(*gamestate);
-//     packet::Gamestate* gs = gamestate;
+    // choose whether the next gamestate is the first or not
+
+    // Create a copy of the gamestate
     packet::Gamestate *gs = new packet::Gamestate(*gamestate); //this is neccessary because the gamestate are being kept (to diff them later on) for each client seperately
-//     packet::Gamestate *gs = new packet::Gamestate();
-//     gs->collectData( id_, 0x1 );
-//     this->threadMutex_->lock();
-    peerMap_[peerID].gamestates[gamestate->getID()]=gs;
-//     this->threadMutex_->unlock();
+    this->peerMap_[peerID].gamestates[gamestate->getID()] = gs;
+
+    // Start the clock
     Clock clock;
     clock.capture();
@@ -236,5 +265,5 @@
     {
       packet::Gamestate *diffed1 = gs->diffVariables(base);
-      if( diffed1->getDataSize() == 0 )
+      if(diffed1->getDataSize() == 0)
       {
         delete diffed1;
@@ -249,13 +278,9 @@
     }
 
-
-//     OrxVerify(gs->compressData(), "");
+    // Stop the clock
     clock.capture();
     orxout(verbose_more, context::network) << "diff and compress time: " << clock.getDeltaTime() << endl;
-//     orxout(verbose_more, context::network) << "sending gamestate with id " << gs->getID();
-//     if(gamestate->isDiffed())
-//       orxout(verbose_more, context::network) << " and baseid " << gs->getBaseID() << endl;
-//     else
-//       orxout(verbose_more, context::network) << endl;
+
+
     gs->setPeerID(peerID);
     destgamestate = gs;
@@ -263,33 +288,30 @@
 
 
+  /**
+   * Acknowledge a received gamestate.
+   * @param gamestateID The ID of the gamestate to be acknowledged
+   * @param peerID The ID of the peer to send the Acknowledgement to
+   */
   bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID)
   {
-//     ClientInformation *temp = ClientInformation::findClient(peerID);
-//     assert(temp);
+    // Search for the peer in the peer map
     std::map<uint32_t, peerInfo>::iterator it = this->peerMap_.find(peerID);
-    assert(it!=this->peerMap_.end());
+    assert(it != this->peerMap_.end());
+
     unsigned int curid = it->second.lastAckedGamestateID;
 
     assert(gamestateID != ACKID_NACK);
-//     if(gamestateID == ACKID_NACK){
-//       it->second.lastAckedGamestateID = GAMESTATEID_INITIAL;
-// //       temp->setGamestateID(GAMESTATEID_INITIAL);
-//       // now delete all saved gamestates for this client
-//       std::map<uint32_t, packet::Gamestate*>::iterator it2;
-//       for(it2 = it->second.gamestates.begin(); it2!=it->second.gamestates.end(); ++it2 ){
-//         delete it2->second;
-//       }
-//       it->second.gamestates.clear();
-//       return true;
-//     }
-
-//    assert(curid==GAMESTATEID_INITIAL || curid<=gamestateID); // this line is commented out because acknowledgements are unreliable and may arrive in distorted order
-    if( gamestateID <= curid && curid != GAMESTATEID_INITIAL )
+
+    // The gamestate has already been acknowledged, nothing to do
+    if(gamestateID <= curid && curid != GAMESTATEID_INITIAL)
+    {
         return true;
-orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl;
+    }
+
+    orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl;
     std::map<uint32_t, packet::Gamestate*>::iterator it2;
-    for( it2=it->second.gamestates.begin(); it2!=it->second.gamestates.end(); )
-    {
-      if( it2->second->getID() < gamestateID )
+    for (it2 = it->second.gamestates.begin(); it2 != it->second.gamestates.end();)
+    {
+      if(it2->second->getID() < gamestateID)
       {
         delete it2->second;
@@ -297,64 +319,77 @@
       }
       else
+      {
         ++it2;
+      }
     }
     
-//     std::map<unsigned int, packet::Gamestate*>::iterator it;
-//     for(it = gamestateMap_[peerID].begin(); it!=gamestateMap_[peerID].end() && it->first<gamestateID; ){
-//       delete it->second;
-//       gamestateMap_[peerID].erase(it++);
-//     }
+    // update the last acked gamestate
     it->second.lastAckedGamestateID = gamestateID;
-//     temp->setGamestateID(gamestateID);
-//     TrafficControl::processAck(peerID, gamestateID);
+
     return true;
   }
   
+  /**
+   * Return the ID of the last received gamestate for a certain peer
+   * @param peerID The ID of the peer\
+   */
   uint32_t GamestateManager::getLastReceivedGamestateID(unsigned int peerID)
   {
-    assert( this->peerMap_.find(peerID)!=this->peerMap_.end() );
-    if( this->peerMap_.find(peerID) != this->peerMap_.end() )
+    if(this->peerMap_.find(peerID) != this->peerMap_.end())
+    {
       return this->peerMap_[peerID].lastReceivedGamestateID;
-    else
+    }
+    else
+    {
       return GAMESTATEID_INITIAL;
+    }
   }
   
-  
+  /**
+   * Add a peer to the game.
+   * @param peerID The ID of the peer to add.
+   */
   void GamestateManager::addPeer(uint32_t peerID)
   {
-    assert(peerMap_.find(peerID)==peerMap_.end());
-    peerMap_[peerID].peerID = peerID;
-    peerMap_[peerID].lastReceivedGamestateID = GAMESTATEID_INITIAL;
-    peerMap_[peerID].lastAckedGamestateID = GAMESTATEID_INITIAL;
-    if( GameMode::isMaster() )
-      peerMap_[peerID].isSynched = false;
-    else
-      peerMap_[peerID].isSynched = true;
-  }
-
+    // Ensure that the peer doesn't already exist.
+    assert(this->peerMap_.find(peerID) == this->peerMap_.end());
+
+    // Create the peerInfo struct for the peer
+    this->peerMap_[peerID].peerID = peerID;
+    this->peerMap_[peerID].lastReceivedGamestateID = GAMESTATEID_INITIAL;
+    this->peerMap_[peerID].lastAckedGamestateID = GAMESTATEID_INITIAL;
+    if(GameMode::isMaster())
+    {
+      this->peerMap_[peerID].isSynched = false;
+    }
+    else
+    {
+      this->peerMap_[peerID].isSynched = true;
+    }
+  }
+
+  /**
+   * Remove a peer from the game.
+   * @param peerID The ID of the peer to be removed
+   */
   void GamestateManager::removePeer(uint32_t peerID)
   {
-    assert(peerMap_.find(peerID)!=peerMap_.end());
-    for( const auto& mapEntry : peerMap_[peerID].gamestates )
+    // Make sure that the peer exists
+    assert(this->peerMap_.find(peerID) != this->peerMap_.end());
+
+    for (const auto& mapEntry : this->peerMap_[peerID].gamestates)
     {
       delete mapEntry.second;
     }
-    peerMap_.erase(peerMap_.find(peerID));
-  }
-
-
-//   void GamestateManager::removeClient(ClientInformation* client){
-//     assert(client);
-//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>>::iterator clientMap = gamestateMap_.find(client->getID());
-//     // first delete all remained gamestates
-//     std::map<unsigned int, packet::Gamestate*>::iterator it;
-//     for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++)
-//       delete it->second;
-//     // now delete the clients gamestatemap
-//     gamestateMap_.erase(clientMap);
-//   }
-
+    this->peerMap_.erase(this->peerMap_.find(peerID));
+  }
+
+  /**
+   * Process an incoming Gamestate packet.
+   * @param gs Pointer to the incoming Gamestate packet
+   */
   bool GamestateManager::processGamestate(packet::Gamestate *gs)
   {
+    // Decompress if necessary
     if(gs->isCompressed())
     {
@@ -362,10 +397,16 @@
     }
     assert(!gs->isDiffed());
+
     uint8_t gsMode;
-    if( GameMode::isMaster() )
+    if(GameMode::isMaster())
+    {
       gsMode = packet::GAMESTATE_MODE_SERVER;
-    else
+    }
+    else
+    {
       gsMode = packet::GAMESTATE_MODE_CLIENT;
-    if( gs->spreadData(gsMode) )
+    }
+
+    if(gs->spreadData(gsMode))
     {
       this->peerMap_[gs->getPeerID()].lastReceivedGamestateID = gs->getID();
@@ -373,5 +414,7 @@
     }
     else
+    {
       return false;
+    }
   }
 
Index: code/branches/mergeFS18/src/libraries/network/GamestateManager.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/GamestateManager.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/GamestateManager.h	(revision 12027)
@@ -58,11 +58,14 @@
   * - writing gamestates to universe
   * - diffing gamestates
+  *
+  * Inherited by Host
+  *
   * EN/DECODATION:
   * a: last Gamestate a client has received
   * b: new Gamestate
   * x: diffed and compressed gamestate
-  * x=(a^b)
-  * b=(a^x)
-  * diff(a,diff(a,x))=x (hope this is correct)
+  * x = (a ^ b)
+  * b = (a ^ x)
+  * diff(a, diff(a, x)) = x (hope this is correct)
   * @author Oliver Scheuss
   */
@@ -75,5 +78,5 @@
       uint32_t  lastAckedGamestateID;     //!< id of the last gamestate on which we received an ack from the peer
       bool      isSynched;
-      std::map< uint32_t, packet::Gamestate* > gamestates;
+      std::map<uint32_t, packet::Gamestate*> gamestates;
     };
 
@@ -86,5 +89,5 @@
     virtual bool      ackGamestate(unsigned int gamestateID, unsigned int peerID) override;
     virtual uint32_t  getLastReceivedGamestateID( unsigned int peerID ) override;
-    virtual uint32_t  getCurrentGamestateID() override{ if( currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; }
+    virtual uint32_t  getCurrentGamestateID() override { if(currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; }
 
     bool processGamestates();
@@ -98,22 +101,23 @@
     void addPeer( uint32_t peerID );
     void setSynched( uint32_t peerID )
-      { assert(peerMap_.find(peerID)!=peerMap_.end()); peerMap_[peerID].isSynched = true; }
+      { assert(peerMap_.find(peerID) != peerMap_.end()); peerMap_[peerID].isSynched = true; }
     void removePeer( uint32_t peerID );
-    bool hasPeers(){ return this->peerMap_.size()!=0; }
-//     void removeClient(ClientInformation *client);
+    bool hasPeers(){ return this->peerMap_.size() != 0; }
+
   protected:
     virtual bool sendPacket( packet::Packet* packet ) = 0;
+
   private:
     bool processGamestate(packet::Gamestate *gs);
 
-//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>> gamestateMap_;
     std::map<unsigned int, packet::Gamestate*> gamestateQueue;
-//     std::map<unsigned int, uint32_t> lastProcessedGamestateID_;
+
+    // Each peerID maps to a peerInfo struct
     std::map<uint32_t, peerInfo> peerMap_;
+
+    // always contains the latest gamestate
     packet::Gamestate* currentGamestate_;
-//     TrafficControl *trafficControl_;
     unsigned int id_;
-//     boost::mutex* threadMutex_;
-    ThreadPool*   /*thread*/Pool_;
+    ThreadPool* Pool_;
   };
 
Index: code/branches/mergeFS18/src/libraries/network/Host.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Host.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Host.cc	(revision 12027)
@@ -44,7 +44,5 @@
   SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT);
 
-  // Host*               Host::instance_=nullptr;
-  uint32_t            Host::clientID_s=0;
-//   uint32_t            Host::shipID_s=-1;
+  uint32_t            Host::clientID_s = 0;
   std::vector<Host*>  Host::instances_s;
 
@@ -54,7 +52,8 @@
   Host::Host()
   {
-  //   assert(instance_==nullptr);
-    instances_s.push_back(this);
+    Host::instances_s.push_back(this);
+
     ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this);
+
     this->bIsActive_ = false;
   }
@@ -66,6 +65,6 @@
   Host::~Host()
   {
-    assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
-    instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
+    assert(std::find( instances_s.begin(), instances_s.end(), this ) != instances_s.end());
+    Host::instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
     ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(nullptr);
   }
@@ -80,7 +79,7 @@
   void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID)
   {
-    for(Host* host : instances_s)
+    for (Host* host : instances_s)
     {
-      if( host->isActive() )
+      if (host->isActive())
       {
         host->queuePacket(packet, clientID, channelID);
@@ -97,7 +96,11 @@
   void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
   {
-    for(Host* host : instances_s)
-      if( host->isActive() )
+    for (Host* host : instances_s)
+    {
+      if (host->isActive())
+      {
         host->doSendChat(message, sourceID, targetID);
+      }
+    }
   }
 
@@ -108,5 +111,7 @@
   {
     for (NetworkChatListener* listener : ObjectList<NetworkChatListener>())
+    {
       listener->incomingChat(message, sourceID);
+    }
   }
 
@@ -114,10 +119,12 @@
   bool Host::isServer()
   {
-    for (Host* host : instances_s)
+    for (Host* host : Host::instances_s)
     {
-      if( host->isActive() )
+      if (host->isActive())
       {
-        if( host->isServer_() )
+        if (host->isServer_())
+        {
           return true;
+        }
       }
     }
@@ -125,13 +132,20 @@
   }
 
+  /**
+   * Singleton implementation. Return the first active instance.
+   */
   Host* Host::getActiveInstance()
   {
     std::vector<Host*>::iterator it = Host::instances_s.begin();
-    while( it != Host::instances_s.end() )
+    while (it != Host::instances_s.end())
     {
-      if( (*it)->isActive() )
+      if ((*it)->isActive())
+      {
         return *it;
+      }
       else
+      {
         ++it;
+      }
     }
     return nullptr;
Index: code/branches/mergeFS18/src/libraries/network/Host.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Host.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Host.h	(revision 12027)
@@ -40,5 +40,5 @@
   const unsigned int CLIENTID_SERVER = 0;
   const unsigned int NETWORK_FREQUENCY = 25;
-  const float NETWORK_PERIOD = 1.0f/NETWORK_FREQUENCY;
+  const float NETWORK_PERIOD = 1.0f / NETWORK_FREQUENCY;
 
 /**
@@ -55,5 +55,5 @@
 
   private:
-    virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID)=0;
+    virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) = 0;
     virtual bool isServer_()=0;
 
@@ -63,6 +63,6 @@
     void setActive( bool bActive ){ bIsActive_ = bActive; }
 
-    virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0;
-    virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0;
+    virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) = 0;
+    virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) = 0;
 
   public:
@@ -74,6 +74,7 @@
     static bool isServer();
     static void sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
-    virtual void printRTT()=0;
+    virtual void printRTT() = 0;
     bool isActive(){ return bIsActive_; }
+    
   private:
     static uint32_t clientID_s;
Index: code/branches/mergeFS18/src/libraries/network/LANDiscoverable.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/LANDiscoverable.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/LANDiscoverable.cc	(revision 12027)
@@ -121,6 +121,4 @@
             info.setClientNumber(this->clientNumber);
             info.send(event.peer);
-//             ENetPacket* packet = enet_packet_create( LAN_DISCOVERY_ACK, strlen(LAN_DISCOVERY_ACK)+1, ENET_PACKET_FLAG_RELIABLE );
-//             enet_peer_send(event.peer, 0, packet );
             enet_host_flush(this->host_);
           }
Index: code/branches/mergeFS18/src/libraries/network/LANDiscoverable.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/LANDiscoverable.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/LANDiscoverable.h	(revision 12027)
@@ -43,6 +43,5 @@
       void setActivity( bool bActive );
       void update();
-      void updateClientNumber(int clientNumber) {this->clientNumber = clientNumber;}
-;
+      void updateClientNumber(int clientNumber) { this->clientNumber = clientNumber; }
       /** Function used for the configuration file parameter update */
       void setConfigValues();
Index: code/branches/mergeFS18/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/LANDiscovery.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/LANDiscovery.cc	(revision 12027)
@@ -61,5 +61,4 @@
     address.port = LAN_DISCOVERY_PORT;
 
-    /* TODO: check for availability of each protocol */
     /* IPv4 */
     address.host = ENET_HOST_BROADCAST;
@@ -102,6 +101,4 @@
               this->servers_.push_back(info);
           }
-//           enet_address_get_host_ip(&event.peer->address, buffer, buflen );
-//           serverIPs.push_back(std::string(buffer));
           break;
         default:
Index: code/branches/mergeFS18/src/libraries/network/MasterServer.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/MasterServer.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/MasterServer.cc	(revision 12027)
@@ -40,5 +40,4 @@
   SetConsoleCommand( "ms-listservers", &MasterServer::listServers );
   SetConsoleCommand( "ms-delserver", &MasterServer::delServer );
-  //SetConsoleCommand( "ms-serverinfo", &MasterServer::serverInfo );
 
   /* forward declaration so the linker doesn't complain */
@@ -357,5 +356,7 @@
 
         /* incoming data */
-      case ENET_EVENT_TYPE_RECEIVE: eventData( event ); break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        eventData( event ); break;
+        
       default: break;
     }
Index: code/branches/mergeFS18/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/MasterServerComm.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/MasterServerComm.cc	(revision 12027)
@@ -38,5 +38,4 @@
      * the initialize method to facilitate debugging
      */
-    /* register object in orxonox */
   } 
 
@@ -48,8 +47,4 @@
       return 1;
     }
-
-    /* initialize the event holder */
-//     this->event = (ENetEvent *)calloc( sizeof(ENetEvent), 1 );
-    
 
     /* initiate the client */
@@ -226,8 +221,4 @@
     /* One could just use enet_host_service() instead. */
     enet_host_flush( this->client );
-   
-    /* free the packet */
-    // PLEASE: never do this, because enet will free the packet once it's delivered. this will cause double frees
-//     enet_packet_destroy( packet );
 
     /* all done. */
@@ -248,6 +239,4 @@
     /* One could just use enet_host_service() instead. */
     enet_host_flush( this->client );
-    // PLEASE: never do this, because enet will free the packet once it's delivered. this will cause double frees
-//     enet_packet_destroy( packet );
 
     /* all done. */
Index: code/branches/mergeFS18/src/libraries/network/Server.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Server.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Server.cc	(revision 12027)
@@ -55,5 +55,4 @@
 #include "packet/Gamestate.h"
 #include "packet/Welcome.h"
-// #include "ClientInformation.h"
 #include "FunctionCallManager.h"
 #include "GamestateManager.h"
@@ -69,19 +68,17 @@
   Server::Server()
   {
-    this->timeSinceLastUpdate_=0;
-  }
-
+    this->timeSinceLastUpdate_ = 0;
+  }
+
+  /**
+  * Constructor
+  * @param port Port to listen on
+  */
   Server::Server(int port)
   {
-    this->setPort( port );
-    this->timeSinceLastUpdate_=0;
-  }
-/*
-  Server::Server(int port, const std::string name)
-  {
-    this->setPort( port );
-    this->timeSinceLastUpdate_=0;
-    this->serverName_=name;
-  }*/
+    this->setPort(port);
+    this->timeSinceLastUpdate_ = 0;
+  }
+
   /**
   * Constructor
@@ -91,7 +88,7 @@
   Server::Server(int port, const std::string& bindAddress)
   {
-    this->setPort( port );
-    this->setBindAddress( bindAddress );
-    this->timeSinceLastUpdate_=0;
+    this->setPort(port);
+    this->setBindAddress(bindAddress);
+    this->timeSinceLastUpdate_ = 0;
   }
 
@@ -156,5 +153,5 @@
     LANDiscoverable::update();
 
-    if ( GamestateManager::hasPeers() )
+    if (GamestateManager::hasPeers())
     {
       // process incoming gamestates
@@ -163,14 +160,13 @@
 
       // send function calls to clients
-      FunctionCallManager::sendCalls( static_cast<Host*>(this) );
-
-      //this steers our network frequency
-      timeSinceLastUpdate_+=time.getDeltaTime();
-      if(timeSinceLastUpdate_>=NETWORK_PERIOD)
+      FunctionCallManager::sendCalls(static_cast<Host*>(this));
+
+      // this steers our network frequency
+      timeSinceLastUpdate_ += time.getDeltaTime();
+      if(timeSinceLastUpdate_ >= NETWORK_PERIOD)
       {
-        timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
-        updateGamestate();
+        timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD;
+        this->updateGamestate();
       }
-//       sendPackets(); // flush the enet queue
     }
   }
@@ -182,55 +178,33 @@
 
   /**
-   * @brief: returns ping time to client in milliseconds
-   */
-  unsigned int Server::getRTT(unsigned int clientID)
-  {
-//     assert(ClientInformation::findClient(clientID));
-//     return ClientInformation::findClient(clientID)->getRTT();
-    // TODO: reimplement
-    return 0;
-  }
-
+   * Print ping time to client in milliseconds.
+   */
   void Server::printRTT()
   {
-//     for( ClientInformation* temp=ClientInformation::getBegin(); temp!=nullptr; temp=temp->next() )
-//       orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;
-  }
-
-  /**
-   * @brief: return packet loss ratio to client (scales from 0 to 1)
-   */
-  float Server::getPacketLoss(unsigned int clientID)
-  {
-//     assert(ClientInformation::findClient(clientID));
-//     return ClientInformation::findClient(clientID)->getPacketLoss();
-    return 0.;
-  }
-
-  /**
-  * takes a new snapshot of the gamestate and sends it to the clients
-  */
+    // TODO: Implement
+  }
+
+  /**
+   * Take a new snapshot of the gamestate and send it to the clients.
+   */
   void Server::updateGamestate()
   {
-    if( this->clientIDs_.size()==0 )
-      //no client connected
+    if(this->clientIDs_.size() == 0)
+    {
+      // no client connected
       return;
+    }
     GamestateManager::update();
-//     orxout(verbose_more, context::network) << "Server: one gamestate update complete, goig to sendGameState" << endl;
-    //orxout(verbose_more, context::network) << "updated gamestate, sending it" << endl;
-    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
-    sendGameStates();
-    sendObjectDeletes();
-//     orxout(verbose_more, context::network) << "Server: one sendGameState turn complete, repeat in next tick" << endl;
-    //orxout(verbose_more, context::network) << "sent gamestate" << endl;
-  }
-
-  /**
-  * sends the current gamestate to all peers
-  */
+    this->sendGameStates();
+    this->sendObjectDeletes();
+  }
+
+  /**
+   * Send the current gamestate to all peers.
+   */
   bool Server::sendGameStates()
   {
     std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
-    for( packet::Gamestate* gamestate : gamestates )
+    for(packet::Gamestate* gamestate : gamestates)
     {
       gamestate->send(static_cast<Host*>(this));
@@ -240,11 +214,15 @@
 
 
+  /**
+   * Send 'DeleteObjects' packet
+   */
   bool Server::sendObjectDeletes()
   {
-//     ClientInformation *temp = ClientInformation::getBegin();
-//     if( temp == nullptr )
-      //no client connected
-    if( this->clientIDs_.size()==0 )
+    // no client connected
+    if(this->clientIDs_.size() == 0)
+    {
       return true;
+    }
+
     packet::DeleteObjects *del = new packet::DeleteObjects();
     if(!del->fetchIDs())
@@ -253,39 +231,19 @@
       return true;  //everything ok (no deletes this tick)
     }
-//     orxout(verbose, context::network) << "sending DeleteObjects" << endl;
-//     while(temp != nullptr){
-//       if( !(temp->getSynched()) )
-//       {
-//         orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
-//         temp=temp->next();
-//         continue;
-//       }
-//       int cid = temp->getID(); //get client id
-//       packet::DeleteObjects *cd = new packet::DeleteObjects(*del);
-//       assert(cd);
+
     del->setPeerID(NETWORK_PEER_ID_BROADCAST);
-    if ( !del->send( static_cast<Host*>(this) ) )
+    if (!del->send( static_cast<Host*>(this)))
+    {
       orxout(internal_warning, context::network) << "Server: could not broadcast deleteObjects packet" << endl;
-//       temp=temp->next();
-      // gs gets automatically deleted by enet callback
-//     }
-//     delete del;
+    }
+
     return true;
   }
 
-
+  /**
+   * Add a new peer to the server.
+   */
   void Server::addPeer(uint32_t peerID)
   {
-//     static unsigned int newid=1;
-//
-//     orxout(internal_info, context::network) << "Server: adding client" << endl;
-//     ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
-//     if(!temp)
-//     {
-//       orxout(internal_warning, context::network) << "Server: could not add client" << endl;
-//     }
-//     temp->setID(newid);
-//     temp->setPeer(event->peer);
-
     // inform all the listeners
     this->clientIDs_.push_back(peerID);
@@ -296,100 +254,93 @@
     GamestateManager::addPeer(peerID);
 
-//     ++newid;
-
     orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl;
 
-    createClient(peerID);
-}
-
+    this->createClient(peerID);
+  }
+
+  /**
+   * Remove a peer from the server.
+   */
   void Server::removePeer(uint32_t peerID)
   {
     orxout(verbose, context::network) << "removing client from list" << endl;
-//     ClientInformation *client = ClientInformation::findClient(&event->peer->address);
-//     if(!client)
-//       return;
-//     else
-//     {
-  std::vector<uint32_t>::iterator it;
-  for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it )
-  {
-    if( *it == peerID )
-    {
-      this->clientIDs_.erase(it);
-      break;
-    }
-  }
-  WANDiscoverable::updateClientNumber(this->clientIDs_.size());
-  LANDiscoverable::updateClientNumber(this->clientIDs_.size());
-
-  ClientConnectionListener::broadcastClientDisconnected(peerID);
-  GamestateManager::removePeer(peerID);
-      //ServerConnection::disconnectClient( client );
-      //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now
-//       delete client;
-//     }
-  }
-
+
+    // erase the peer from the list
+    std::vector<uint32_t>::iterator it;
+    for(it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it)
+    {
+      if(*it == peerID)
+      {
+        this->clientIDs_.erase(it);
+        break;
+      }
+    }
+
+    WANDiscoverable::updateClientNumber(this->clientIDs_.size());
+    LANDiscoverable::updateClientNumber(this->clientIDs_.size());
+
+    // Send 'clientDisconnected' message
+    ClientConnectionListener::broadcastClientDisconnected(peerID);
+
+    GamestateManager::removePeer(peerID);
+  }
+
+  /**
+   * Process an incoming packet.
+   */
   void Server::processPacket(packet::Packet* packet)
   {
-    if( packet->isReliable() )
-    {
-      if( this->getLastReceivedGamestateID(packet->getPeerID()) >= packet->getRequiredGamestateID() )
+    if(packet->isReliable())
+    {
+      if(this->getLastReceivedGamestateID(packet->getPeerID()) >= packet->getRequiredGamestateID())
+      {
         packet->process(static_cast<Host*>(this));
+      }
       else
+      {
         this->packetQueue_.push_back(packet);
+      }
     }
     else
+    {
       packet->process(static_cast<Host*>(this));
-  }
-
-
+    }
+  }
+
+  /**
+   * Create a client.
+   */
   bool Server::createClient(int clientID)
   {
-//     ClientInformation *temp = ClientInformation::findClient(clientID);
-//     if(!temp)
-//     {
-//       orxout(internal_error, context::network) << "Server. could not create client with id: " << clientID << endl;
-//       return false;
-//     }
-//     orxout(verbose, context::network) << "Con.Man: creating client id: " << temp->getID() << endl;
 
     // synchronise class ids
-    syncClassid(clientID);
+    this->syncClassid(clientID);
 
     // now synchronise functionIDs
     packet::FunctionIDs *fIDs = new packet::FunctionIDs();
     fIDs->setPeerID(clientID);
-    bool b = fIDs->send( static_cast<Host*>(this) );
+    bool b = fIDs->send(static_cast<Host*>(this));
     assert(b);
 
-//     temp->setSynched(true);
     GamestateManager::setSynched(clientID);
 
+    // Send 'Welcome' packet to client
     orxout(verbose, context::network) << "sending welcome" << endl;
     packet::Welcome *w = new packet::Welcome(clientID);
     w->setPeerID(clientID);
-    b = w->send( static_cast<Host*>(this) );
+    b = w->send(static_cast<Host*>(this));
     assert(b);
+
     (void)b; // avoid compiler warning
-//     packet::Gamestate *g = new packet::Gamestate();
-//     g->setPeerID(clientID);
-//     b = g->collectData(0,packet::GAMESTATE_MODE_SERVER);
-//     assert(b);
-//     if(!b)
-//       return false; //no data for the client
-// //     b = g->compressData();
-// //     assert(b);
-//     b = g->send( static_cast<Host*>(this) );
-//     assert(b);
     return true;
   }
 
-  void Server::disconnectClient( uint32_t clientID )
-  {
-    ServerConnection::disconnectClient( clientID );
-    GamestateManager::removePeer( clientID );
-    // inform all the listeners
-    // ClientConnectionListener::broadcastClientDisconnected(client->getID()); // this is done in ClientInformation now
+  /**
+   * Disconnect a client.
+   */
+  void Server::disconnectClient(uint32_t clientID)
+  {
+    ServerConnection::disconnectClient(clientID);
+    GamestateManager::removePeer(clientID);
   }
 
@@ -403,15 +354,19 @@
   {
     // check if the target exists. just ignore the message otherwise
-    if (!this->isValidTarget(targetID)) // TODO: remove this if an invalid clientIDs don't trigger assertions anymore
+    if (!this->isValidTarget(targetID))
+    {
       return;
+    }
 
     // send the message to the target
     packet::Chat* packet = new packet::Chat(message, sourceID, targetID);
     packet->setPeerID(targetID);
-    packet->send( static_cast<Host*>(this) );
+    packet->send(static_cast<Host*>(this));
 
     // if the target is (or includes) this host as well, call the parent function which passes the message to the listeners
     if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == Host::getPlayerID())
+    {
       Host::doReceiveChat(message, sourceID, targetID);
+    }
   }
 
@@ -431,10 +386,18 @@
   bool Server::isValidTarget(unsigned int targetID)
   {
+    // Broadcast or server ID are okay
     if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == NETWORK_PEER_ID_SERVER)
+    {
       return true;
-
-    for( uint32_t id : this->clientIDs_ )
-      if( id == targetID )
+    }
+
+    // IDs in the client list are okay also
+    for(uint32_t id : this->clientIDs_)
+    {
+      if(id == targetID)
+      {
         return true;
+      }
+    }
 
     return false;
@@ -443,8 +406,10 @@
   void Server::syncClassid(unsigned int clientID)
   {
-    int failures=0;
     packet::ClassID *classid = new packet::ClassID();
     classid->setPeerID(clientID);
-    while(!classid->send( static_cast<Host*>(this) ) && failures < 10){
+
+    int failures = 0;
+    while(!classid->send(static_cast<Host*>(this)) && failures < 10)\
+    {
       failures++;
     }
Index: code/branches/mergeFS18/src/libraries/network/Server.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/Server.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/Server.h	(revision 12027)
@@ -38,5 +38,4 @@
 #include "core/CorePrereqs.h"
 #include "Host.h"
-// #include "GamestateManager.h"
 #include "ServerConnection.h"
 #include "LANDiscoverable.h"
@@ -62,17 +61,15 @@
     void close();
     virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) override;
-    virtual bool sendPacket( packet::Packet* packet ) override{ return packet->send( static_cast<Host*>(this) ); }
+    virtual bool sendPacket( packet::Packet* packet ) override { return packet->send( static_cast<Host*>(this) ); }
     void update(const Clock& time);
-    unsigned int getRTT(unsigned int clientID);
     virtual void printRTT() override;
-    float getPacketLoss(unsigned int clientID);
-    int getClientCount() { return this->clientIDs_.size();}
-    std::string getServerName() { return this->serverName_;}
+    int getClientCount() { return this->clientIDs_.size(); }
+    std::string getServerName() { return this->serverName_; }
 
   protected:
     void updateGamestate();
   private:
-    virtual bool isServer_() override{return true;}
-    unsigned int playerID(){return 0;}
+    virtual bool isServer_() override { return true; }
+    unsigned int playerID() { return 0; }
 
     virtual void addPeer(uint32_t peerID) override;
Index: code/branches/mergeFS18/src/libraries/network/ServerConnection.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/ServerConnection.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/ServerConnection.cc	(revision 12027)
@@ -36,14 +36,14 @@
 #include "util/Output.h"
 #include <util/Sleep.h>
-// #include "ClientInformation.h"
 
 namespace orxonox
 {
-
+  /**
+   * Constructor
+   */
   ServerConnection::ServerConnection():
     bListening_(false)
   {
     this->bindAddress_ = new ENetAddress();
-//     memset(this->bindAddress_, 0, sizeof(ENetAddress));
     this->bindAddress_->host = ENET_HOST_ANY;
     this->bindAddress_->port = NETWORK_PORT;
@@ -51,18 +51,33 @@
   }
 
+  /**
+   * Destructor
+   */
   ServerConnection::~ServerConnection()
   {
-    if ( this->bListening_ )
-      closeListener();
+    if (this->bListening_)
+    {
+      this->closeListener();
+    }
     delete this->bindAddress_;
   }
 
-  void ServerConnection::setBindAddress( const std::string& bindAddress )
+  /**
+   * Set address on which to listen.
+   * @param bindAddress The address on which to listen
+   */
+  void ServerConnection::setBindAddress(const std::string& bindAddress)
   {
-    if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0)
-        orxout(internal_error, context::network) << "Could not resolve \"" << bindAddress << "\"." << endl;
+    if (enet_address_set_host(this->bindAddress_, bindAddress.c_str()) < 0)
+    {
+      orxout(internal_error, context::network) << "Could not resolve \"" << bindAddress << "\"." << endl;
+    }
   }
 
-  void ServerConnection::setPort( unsigned int port ) {
+  /**
+   * Set port on which to listen on.
+   * @param port The port on which to listen on.
+   */
+  void ServerConnection::setPort(unsigned int port) {
       this->bindAddress_->port = port;
   }
@@ -73,5 +88,5 @@
     this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);
     
-    if ( this->host_ == nullptr )
+    if (this->host_ == nullptr)
     {
         orxout(internal_error, context::network) << "ServerConnection: host_ == nullptr" << endl;
@@ -81,11 +96,20 @@
     // enable compression
     this->enableCompression();
+
+    // ensure that either IPv4 or IPv6 succeeded
     assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
+
     if (this->host_->socket4 == ENET_SOCKET_NULL)
+    {
         orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl;
+    }
     else if (this->host_->socket6 == ENET_SOCKET_NULL)
+    {
         orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl;
+    }
     else
+    {
         orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl;
+    }
     
     // start communication thread
@@ -95,8 +119,11 @@
   }
 
+  /**
+   * Stop listening.
+   */
   bool ServerConnection::closeListener()
   {
-    this->bListening_=false;
-    disconnectClients();
+    this->bListening_ = false;
+    this->disconnectClients();
     Connection::stopCommunicationThread();
     enet_host_destroy(this->host_);
@@ -104,32 +131,34 @@
   }
 
+  /**
+   * Add outgoing packet to queue.
+   * @param packet The packet to send
+   * @param clientID The ID of the recipient
+   * @param channelID The channel ID
+   */
   void ServerConnection::addPacket(ENetPacket *packet, unsigned int clientID, uint8_t channelID)
   {
-    if ( clientID == NETWORK_PEER_ID_BROADCAST )
+    if (clientID == NETWORK_PEER_ID_BROADCAST)
     {
-      broadcastPacket(packet, channelID);
+      this->broadcastPacket(packet, channelID);
     }
     else
     {
-//       ClientInformation *temp = ClientInformation::findClient(clientID);
-//       if(!temp){
-//         orxout(internal_warning, context::network) << "C.Man: addPacket findClient failed" << endl;
-//       }
       Connection::addPacket(packet, clientID, channelID);
     }
   }
 
-//   void ServerConnection::disconnectClient(ClientInformation *client)
-//   {
-//     Connection::disconnectPeer( client->getPeer() );
-//   }
-
+  /**
+   * Terminate connection with a peer.
+   * @param clientID The peer with which to terminate the connection.
+   */
   void ServerConnection::disconnectClient(int clientID)
   {
-//     ClientInformation *client = ClientInformation::findClient(clientID);
-//     if(client)
     Connection::disconnectPeer(clientID);
   }
 
+  /**
+   * Disconnect all peers.
+   */
   void ServerConnection::disconnectClients()
   {
@@ -138,21 +167,3 @@
     return;
   }
-
-
-//   int ServerConnection::getClientID(ENetPeer* peer)
-//   {
-//     return getClientID(&(peer->address));
-//   }
-
-//   int ServerConnection::getClientID(ENetAddress* address)
-//   {
-//     return ClientInformation::findClient(address)->getID();
-//   }
-// 
-//   ENetPeer *ServerConnection::getClientPeer(int clientID)
-//   {
-//     return ClientInformation::findClient(clientID)->getPeer();
-//   }
-
-
 }
Index: code/branches/mergeFS18/src/libraries/network/ServerConnection.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/ServerConnection.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/ServerConnection.h	(revision 12027)
@@ -47,5 +47,6 @@
 {
 
-  class _NetworkExport ServerConnection : public Connection{
+  class _NetworkExport ServerConnection : public Connection
+  {
   public:
     ~ServerConnection();
@@ -57,6 +58,6 @@
     bool closeListener();
     void addPacket(ENetPacket *packet, unsigned int ID, uint8_t channelID);
-//     virtual void disconnectClient(ClientInformation *client);
     void disconnectClient(int clientID);
+
   protected:
     ServerConnection();
@@ -64,10 +65,5 @@
 
   private:
-//     int getClientID(ENetPeer* peer);
-//     int getClientID(ENetAddress* address);
-//     ENetPeer* getClientPeer(int clientID);
-
     ENetAddress* bindAddress_;
-
     bool bListening_;
 
Index: code/branches/mergeFS18/src/libraries/network/packet/Acknowledgement.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Acknowledgement.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Acknowledgement.cc	(revision 12027)
@@ -37,15 +37,23 @@
 
 #define PACKET_FLAGS_ACK    0
+// Offset to start of packet ID
 #define _PACKETID           0
+// Offset to start of ACK ID
 #define _ACKID              _PACKETID + sizeof(packet::Type)
 
+/**
+ * Constructor
+ * Acknowledgement.data_ is 40 bits in size:
+ * [0, 7]:   Packet Type
+ * [8, 39]:  Acknowledgement ID
+ */
 Acknowledgement::Acknowledgement( unsigned int id, unsigned int peerID )
  : Packet()
 {
-  flags_ = flags_ | PACKET_FLAGS_ACK;
-  data_=new uint8_t[ getSize() ];
-  *(Type *)(data_ + _PACKETID ) = Type::Acknowledgement;
-  *(uint32_t *)(data_ + _ACKID ) = id;
-  peerID_=peerID;
+  this->flags_ |= PACKET_FLAGS_ACK;
+  this->data_ = new uint8_t[ this->getSize() ];
+  *(Type *)(this->data_ + _PACKETID) = Type::Acknowledgement;
+  *(uint32_t *)(this->data_ + _ACKID) = id;
+  this->peerID_ = peerID;
 }
 
@@ -59,9 +67,9 @@
 }
 
-unsigned int Acknowledgement::getSize() const{
+unsigned int Acknowledgement::getSize() const {
   return _ACKID + sizeof(uint32_t);
 }
 
-bool Acknowledgement::process(orxonox::Host* host){
+bool Acknowledgement::process(orxonox::Host* host) {
   orxout(verbose_more, context::packets) << "processing ACK with ID: " << getAckID() << endl;
   bool b = host->ackGamestate(getAckID(), peerID_);
@@ -70,5 +78,5 @@
 }
 
-unsigned int Acknowledgement::getAckID(){
+unsigned int Acknowledgement::getAckID() {
   return *(uint32_t *)(data_ + _ACKID);
 }
Index: code/branches/mergeFS18/src/libraries/network/packet/Acknowledgement.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Acknowledgement.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Acknowledgement.h	(revision 12027)
@@ -34,9 +34,9 @@
 
 namespace orxonox {
+	
 const unsigned int ACKID_NACK = 0;
+
 namespace packet {
-/**
-    @author
-*/
+
 class _NetworkExport Acknowledgement : public Packet
 {
Index: code/branches/mergeFS18/src/libraries/network/packet/Chat.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Chat.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Chat.cc	(revision 12027)
@@ -38,5 +38,5 @@
 #define   PACKET_FLAGS_CHAT PacketFlag::Reliable
 
-/* Some lengths */
+/* Some lengths / offsets */
 #define _PACKETID         0
 #define _SOURCEID         _PACKETID + sizeof(Type)
@@ -49,21 +49,21 @@
 {
   /* Add chat flag to packet flags */
-  flags_ = flags_ | PACKET_FLAGS_CHAT;
+  this->flags_ |= PACKET_FLAGS_CHAT;
 
   /* set message length to length of input string + 1 */
-  messageLength_ = message.length()+1;
+  this->messageLength_ = message.length() + 1;
 
   /* allocate memory for the data */
-  data_=new unsigned char[ getSize() ];
+  this->data_ = new unsigned char[ getSize() ];
 
   *(Type *)(data_ + _PACKETID ) = Type::Chat;
   *(unsigned int *)(data_ + _SOURCEID ) = sourceID;
   *(unsigned int *)(data_ + _TARGETID ) = targetID;
-  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
+  *(unsigned int *)(data_ + _MESSAGELENGTH ) = this->messageLength_;
 
   /* cast the hell out of the message string, and copy it into the
    * data buffer.
    */
-  memcpy( data_+_MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), messageLength_ );
+  memcpy( this->data_ + _MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), this->messageLength_ );
 }
 
@@ -71,5 +71,5 @@
   : Packet(data, clientID)
 {
-  messageLength_ = *(uint32_t *)(data + _MESSAGELENGTH );
+  this->messageLength_ = *(uint32_t *)(data + _MESSAGELENGTH );
 }
 
@@ -79,15 +79,17 @@
 
 unsigned int Chat::getSize() const{
-  return _MESSAGE + messageLength_;
+  return _MESSAGE + this->messageLength_;
 }
 
 bool Chat::process(orxonox::Host* host){
-  host->doReceiveChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_SOURCEID), *(uint32_t *)(data_+_TARGETID));
+  host->doReceiveChat(std::string((const char*)this->data_ + _MESSAGE),
+                                  *(uint32_t *)(this->data_+_SOURCEID),
+                                  *(uint32_t *)(this->data_+_TARGETID));
   delete this;
   return true;
 }
 
-unsigned char *Chat::getMessage(){
-  return data_ + _MESSAGE;
+unsigned char *Chat::getMessage() {
+  return this->data_ + _MESSAGE;
 }
 
Index: code/branches/mergeFS18/src/libraries/network/packet/Chat.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Chat.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Chat.h	(revision 12027)
@@ -55,5 +55,5 @@
 
   /* Get the length of the message (not the full size of the packet) */
-  unsigned int getMessageLength(){ return messageLength_; };
+  unsigned int getMessageLength() { return this->messageLength_; };
 
   /* return message content */
Index: code/branches/mergeFS18/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/ClassID.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/ClassID.cc	(revision 12027)
@@ -46,14 +46,14 @@
 
 
-ClassID::ClassID( ) : Packet(){
+ClassID::ClassID() : Packet() {
   Identifier *id;
-  unsigned int nrOfClasses=0;
-  unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
+  unsigned int nrOfClasses = 0;
+  unsigned int packetSize = 2 * sizeof(uint32_t); //space for the packetID and for the nrofclasses
   uint32_t network_id;
-  flags_ = flags_ | PACKET_FLAGS_CLASSID;
+  this->flags_ |= PACKET_FLAGS_CLASSID;
   std::queue<std::pair<uint32_t, std::string>> tempQueue;
 
-  //calculate total needed size (for all strings and integers)
-  for(const auto& mapEntry : IdentifierManager::getInstance().getIdentifierByStringMap()){
+  // calculate total needed size (for all strings and integers)
+  for(const auto& mapEntry : IdentifierManager::getInstance().getIdentifierByStringMap()) {
     id = mapEntry.second;
     if(id == nullptr || !id->hasFactory())
@@ -64,30 +64,30 @@
     tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) );
     ++nrOfClasses;
-    packetSize += (classname.size()+1)+sizeof(network_id)+sizeof(uint32_t);
+    packetSize += (classname.size() + 1) + sizeof(network_id) + sizeof(uint32_t);
   }
 
-  this->data_=new uint8_t[ packetSize ];
+  this->data_ = new uint8_t[ packetSize ];
   //set the appropriate packet id
   assert(this->data_);
   *(Type *)(this->data_ + _PACKETID ) = Type::ClassID;
 
-  uint8_t *temp=data_+sizeof(uint32_t);
+  uint8_t *temp = this->data_ + sizeof(uint32_t);
   // save the number of all classes
-  *(uint32_t*)temp = nrOfClasses;
+  *(uint32_t*) temp = nrOfClasses;
   temp += sizeof(uint32_t);
 
   // now save all classids and classnames
   std::pair<uint32_t, std::string> tempPair;
-  uint32_t tempsize = 2*sizeof(uint32_t); // packetid and nrOfClasses
+  uint32_t tempsize = 2 * sizeof(uint32_t); // packetid and nrOfClasses
   while( !tempQueue.empty() ){
     tempPair = tempQueue.front();
     tempQueue.pop();
-    *(uint32_t*)temp = tempPair.first;
-    *(uint32_t*)(temp+sizeof(uint32_t)) = tempPair.second.size()+1;
-    memcpy(temp+2*sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size()+1);
-    temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
-    tempsize+=2*sizeof(uint32_t)+tempPair.second.size()+1;
+    *(uint32_t*) temp = tempPair.first;
+    *(uint32_t*) (temp+sizeof(uint32_t)) = tempPair.second.size() + 1;
+    memcpy(temp + 2 * sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size() + 1);
+    temp += 2 * sizeof(uint32_t) + tempPair.second.size() + 1;
+    tempsize += 2 * sizeof(uint32_t) + tempPair.second.size() + 1;
   }
-  assert(tempsize==packetSize);
+  assert(tempsize == packetSize);
 
   orxout(verbose_more, context::packets) << "classid packetSize is " << packetSize << endl;
@@ -104,26 +104,24 @@
 }
 
-uint32_t ClassID::getSize() const{
-  uint8_t *temp = data_+sizeof(uint32_t); // packet identification
+uint32_t ClassID::getSize() const {
+  uint8_t *temp = this->data_ + sizeof(uint32_t); // packet identification
   uint32_t totalsize = sizeof(uint32_t); // packet identification
-  uint32_t nrOfClasses = *(uint32_t*)temp;
+  uint32_t nrOfClasses = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
   totalsize += sizeof(uint32_t); // storage size for nr of all classes
 
-  for(unsigned int i=0; i<nrOfClasses; i++){
-    totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
-    temp += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
+  for(unsigned int i=0; i < nrOfClasses; i++) {
+    totalsize += 2 * sizeof(uint32_t) + *(uint32_t*) (temp + sizeof(uint32_t));
+    temp += 2 * sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
   }
   return totalsize;
 }
 
-
-bool ClassID::process(orxonox::Host* host){
+bool ClassID::process(orxonox::Host* host) {
   int nrOfClasses;
-  uint8_t *temp = data_+sizeof(uint32_t); //skip the packetid
+  uint8_t *temp = this->data_ + sizeof(uint32_t); //skip the packetid
   uint32_t networkID;
   uint32_t stringsize;
   unsigned char *classname;
-
 
   //clear the map of network ids
@@ -134,19 +132,19 @@
   Identifier *id;
   // read the total number of classes
-  nrOfClasses = *(uint32_t*)temp;
+  nrOfClasses = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
 
-  for( int i=0; i<nrOfClasses; i++){
-    networkID = *(uint32_t*)temp;
-    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
-    classname = temp+2*sizeof(uint32_t);
-    id=ClassByString( std::string((const char*)classname) );
+  for( int i = 0; i < nrOfClasses; i++) {
+    networkID = *(uint32_t*) temp;
+    stringsize = *(uint32_t*) (temp + sizeof(uint32_t));
+    classname = temp + 2 * sizeof(uint32_t);
+    id = ClassByString( std::string((const char*) classname) );
     orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl;
-    if(id==nullptr){
+    if(id == nullptr) {
       orxout(user_error, context::packets) << "Received a bad classname" << endl;
       abort();
     }
     id->setNetworkID( networkID );
-    temp += 2*sizeof(uint32_t) + stringsize;
+    temp += 2 * sizeof(uint32_t) + stringsize;
   }
   delete this;
Index: code/branches/mergeFS18/src/libraries/network/packet/DeleteObjects.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/DeleteObjects.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/DeleteObjects.cc	(revision 12027)
@@ -45,5 +45,5 @@
  : Packet()
 {
-  flags_ = flags_ | PACKET_FLAG_DELETE;
+  this->flags_ |= PACKET_FLAG_DELETE;
 }
 
@@ -60,5 +60,5 @@
 {
   unsigned int number = Synchronisable::getNumberOfDeletedObject();
-  if(number==0)
+  if(number == 0)
     return false;
   orxout(verbose, context::packets) << "sending DeleteObjects: ";
@@ -83,13 +83,13 @@
 {
   assert(data_);
-  return _OBJECTIDS + *(uint32_t*)(data_+_QUANTITY)*sizeof(uint32_t);
+  return _OBJECTIDS + *(uint32_t*) (this->data_ + _QUANTITY) * sizeof(uint32_t);
 }
 
 bool DeleteObjects::process(orxonox::Host* host)
 {
-  for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++)
+  for(unsigned int i = 0; i < *(unsigned int *) (this->data_+_QUANTITY); i++)
   {
     orxout(verbose, context::packets) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << endl;
-    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
+    Synchronisable::deleteObject( *(uint32_t*)(this->data_ + _OBJECTIDS + i * sizeof(uint32_t)) );
   }
   delete this;
Index: code/branches/mergeFS18/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/FunctionCalls.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/FunctionCalls.cc	(revision 12027)
@@ -63,10 +63,10 @@
   assert(isDataENetAllocated());
   
-  uint8_t* temp = data_+sizeof(uint32_t); //skip packetid
-  uint32_t nrOfCalls = *(uint32_t*)temp;
+  uint8_t* temp = data_ + sizeof(uint32_t); //skip packetid
+  uint32_t nrOfCalls = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
-  this->minGamestateID_ = *(uint32_t*)temp;
+  this->minGamestateID_ = *(uint32_t*) temp;
   temp += sizeof(uint32_t);
-  for( unsigned int i = 0; i<nrOfCalls; i++ )
+  for( unsigned int i = 0; i < nrOfCalls; i++ )
   {
     FunctionCall fctCall;
@@ -95,9 +95,9 @@
   this->minGamestateID_ = host->getCurrentGamestateID();
   assert(this->functionCalls_.size());
-  data_=new uint8_t[ currentSize_ ];
-  *(Type *)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
-  *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls
-  *(uint32_t*)(data_+2*sizeof(uint32_t)) = this->minGamestateID_; // set minGamestateID_
-  uint8_t* temp = data_+3*sizeof(uint32_t);
+  this->data_ = new uint8_t[ currentSize_ ];
+  *(Type *)(this->data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
+  *(uint32_t*)(this->data_ + sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls
+  *(uint32_t*)(this->data_ + 2 * sizeof(uint32_t)) = this->minGamestateID_; // set minGamestateID_
+  uint8_t* temp = this->data_ + 3 * sizeof(uint32_t);
   
   while( this->functionCalls_.size() )
@@ -107,5 +107,5 @@
   }
   
-  assert( temp==data_+currentSize_ );
+  assert( temp == this->data_ + currentSize_ );
   
   Packet::send(host);
Index: code/branches/mergeFS18/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Gamestate.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Gamestate.cc	(revision 12027)
@@ -46,5 +46,4 @@
 #define GAMESTATE_START(data) (data + GamestateHeader::getSize())
 
-// #define PACKET_FLAG_GAMESTATE  PacketFlag::Reliable
 #define PACKET_FLAG_GAMESTATE  0
 
@@ -102,5 +101,5 @@
 }
 
-
+//AV: This takes all synchronisables and packs it in a GameState, to be sent over the network
 bool Gamestate::collectData(int id, uint8_t mode)
 {
@@ -128,6 +127,4 @@
   for(it = ObjectList<Synchronisable>().begin(); it; ++it)
   {
-
-//     tempsize=it->getSize(id, mode);
 
     tempsize = it->getData(mem, this->sizes_, id, mode);
@@ -173,5 +170,5 @@
 }
 
-
+//AV: This takes the Gamestate received from the network and "unpacks" it back to a list of Objects/Synchronisables, thus updating the data
 bool Gamestate::spreadData(uint8_t mode)
 {
@@ -196,5 +193,4 @@
       else
       {
-//         orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl;
         mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() );
       }
@@ -202,44 +198,8 @@
     else
     {
-//       orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl;
       OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data");
     }
   }
   assert((uintptr_t)(mem-data_) == GamestateHeader::getSize()+header_.getDataSize());
-  
-   // In debug mode, check first, whether there are no duplicate objectIDs
-#ifndef NDEBUG
-  if(this->getID()%1000==1)
-  {
-    std::list<uint32_t> v1;
-    for (Synchronisable* synchronisable : ObjectList<Synchronisable>())
-    {
-      if (synchronisable->getObjectID() == OBJECTID_UNKNOWN)
-      {
-        if (synchronisable->objectMode_ != 0x0)
-        {
-          orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl;
-          orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl;
-          orxout(user_error, context::packets) << "Objects class: " << synchronisable->getIdentifier()->getName() << endl;
-          assert(false);
-        }
-      }
-      else
-      {
-        for (uint32_t id : v1)
-        {
-          if (synchronisable->getObjectID() == id)
-          {
-            orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl
-                                                 << "Are you sure you don't create a Sychnronisable objcect with 'new' \
-                                                     that doesn't have objectMode = 0x0?" << endl;
-            assert(false);
-          }
-        }
-        v1.push_back(synchronisable->getObjectID());
-      }
-    }
-  }
-#endif
   return true;
 }
@@ -276,5 +236,5 @@
 }
 
-
+//AV: This function takes the Gamestate and compresses it for transmission over the network
 bool Gamestate::compressData()
 {
@@ -313,5 +273,5 @@
 }
 
-
+//AV: This function takes the compressed Gamestate received from the network and decompresses it for further unpacking
 bool Gamestate::decompressData()
 {
@@ -374,5 +334,4 @@
   if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 )
   {
-//     orxout(verbose, context::packets) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;
     origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object
     baseDataPtr += objectOffset + objectHeader.getDataSize();
@@ -430,5 +389,4 @@
 inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes )
 {
-  //       orxout(verbose, context::packets) << "docopy" << endl;
   // Just copy over the whole Object
   memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() );
@@ -437,15 +395,7 @@
   newData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
   origData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
-//   SynchronisableHeader baseHeader( baseData );
-//   baseData += baseHeader.getDataSize()+SynchronisableHeader::getSize();
-  //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << endl;
-  //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << ":";
+
   sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
-//   for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i )
-//   {
-//     //         orxout(verbose, context::packets) << " " << *sizes;
-//     ++sizes;
-//   }
-    //       orxout(verbose, context::packets) << endl;
+
 }
 
@@ -501,6 +451,5 @@
   uint8_t *origDataEnd = origDataPtr + header_.getDataSize();
   uint8_t *baseDataEnd = baseDataPtr + base->header_.getDataSize();
-//   uint32_t origLength = header_.getDataSize();
-//   uint32_t baseLength = base->header_.getDataSize();
+
 
   // Allocate new space for diffed gamestate
@@ -595,165 +544,4 @@
 
 
-/*Gamestate* Gamestate::diffData(Gamestate *base)
-{
-  assert(this && base); assert(data_ && base->data_);
-  assert(!header_.isCompressed() && !base->header_.isCompressed());
-  assert(!header_.isDiffed());
-
-  uint8_t *basep = GAMESTATE_START(base->data_);
-  uint8_t *gs = GAMESTATE_START(this->data_);
-  uint32_t dest_length = header_.getDataSize();
-
-  if(dest_length==0)
-    return nullptr;
-
-  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
-  uint8_t *dest = GAMESTATE_START(ndata);
-
-  rawDiff( dest, gs, basep, header_.getDataSize(), base->header_.getDataSize() );
-#ifndef NDEBUG
-  uint8_t *dest2 = new uint8_t[dest_length];
-  rawDiff( dest2, dest, basep, header_.getDataSize(), base->header_.getDataSize() );
-  assert( memcmp( dest2, gs, dest_length) == 0 );
-  delete dest2;
-#endif
-
-  Gamestate *g = new Gamestate(ndata, getClientID());
-  assert(g->header_);
-  *(g->header_) = *header_;
-  g->header_.setDiffed( true );
-  g->header_.setBaseID( base->getID() );
-  g->flags_=flags_;
-  g->packetDirection_ = packetDirection_;
-  assert(g->isDiffed());
-  assert(!g->isCompressed());
-  return g;
-}
-
-
-Gamestate* Gamestate::undiff(Gamestate *base)
-{
-  assert(this && base); assert(data_ && base->data_);
-  assert(!header_.isCompressed() && !base->header_.isCompressed());
-  assert(header_.isDiffed());
-
-  uint8_t *basep = GAMESTATE_START(base->data_);
-  uint8_t *gs = GAMESTATE_START(this->data_);
-  uint32_t dest_length = header_.getDataSize();
-
-  if(dest_length==0)
-    return nullptr;
-
-  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
-  uint8_t *dest = ndata + GamestateHeader::getSize();
-
-  rawDiff( dest, gs, basep, header_.getDataSize(), base->header_.getDataSize() );
-
-  Gamestate *g = new Gamestate(ndata, getClientID());
-  assert(g->header_);
-  *(g->header_) = *header_;
-  g->header_.setDiffed( false );
-  g->flags_=flags_;
-  g->packetDirection_ = packetDirection_;
-  assert(!g->isDiffed());
-  assert(!g->isCompressed());
-  return g;
-}
-
-
-void Gamestate::rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength)
-{
-  uint64_t* gd = (uint64_t*)data;
-  uint64_t* bd = (uint64_t*)basedata;
-  uint64_t* nd = (uint64_t*)newdata;
-
-  unsigned int i;
-  for( i=0; i<datalength/8; i++ )
-  {
-    if( i<baselength/8 )
-      *(nd+i) = *(gd+i) ^ *(bd+i);  // xor the data
-    else
-      *(nd+i) = *(gd+i); // just copy over the data
-  }
-  unsigned int j;
-  // now process the rest (when datalength isn't a multiple of 4)
-  for( j = 8*(datalength/8); j<datalength; j++ )
-  {
-    if( j<baselength )
-      *(newdata+j) = *(data+j) ^ *(basedata+j); // xor
-    else
-      *(newdata+j) = *(data+j); // just copy
-  }
-  assert(j==datalength);
-}*/
-
-
-/*Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
-  assert(data_);
-  std::list<obj>::iterator it;
-
-  // allocate memory for new data
-  uint8_t *gdata = new uint8_t[header_.getDataSize()+GamestateHeader::getSize()];
-  // create a gamestate out of it
-  Gamestate *gs = new Gamestate(gdata);
-  uint8_t *newdata = gdata + GamestateHeader::getSize();
-  uint8_t *origdata = GAMESTATE_START(data_);
-
-  //copy the GamestateHeader
-  assert(gs->header_);
-  *(gs->header_) = *header_;
-
-  uint32_t objectOffset;
-  unsigned int objectsize, destsize=0;
-  // TODO: Why is this variable not used?
-  //Synchronisable *object;
-
-  //call TrafficControl
-  TrafficControl::getInstance()->processObjectList( clientID, header_.getID(), dataVector_ );
-
-  //copy in the zeros
-//   std::list<obj>::iterator itt;
-//   orxout() << "myvector contains:";
-//   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
-//     orxout() << " " << (*itt).objID;
-//   orxout() << endl;
-  for(it=dataVector_.begin(); it!=dataVector_.end();){
-    SynchronisableHeader oldobjectheader(origdata);
-    SynchronisableHeader newobjectheader(newdata);
-    if ( (*it).objSize == 0 )
-    {
-      ++it;
-      continue;
-    }
-    objectsize = oldobjectheader.getDataSize()+SynchronisableHeader::getSize();
-    objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
-    if ( (*it).objID == oldobjectheader.getObjectID() ){
-      memcpy(newdata, origdata, objectsize);
-      ++it;
-    }else{
-      newobjectheader = oldobjectheader;
-      memset(newdata+objectOffset, 0, objectsize-objectOffset);
-    }
-    newdata += objectsize;
-    origdata += objectsize;
-    destsize += objectsize;
-  }
-#ifndef NDEBUG
-  uint32_t origsize = destsize;
-  while ( origsize < header_.getDataSize() )
-  {
-    SynchronisableHeader oldobjectheader(origdata);
-    objectsize = oldobjectheader.getDataSize()+SynchronisableHeader::getSize();
-    origdata += objectsize;
-    origsize += objectsize;
-  }
-  assert(origsize==header_.getDataSize());
-  assert(destsize!=0);
-#endif
-  gs->header_.setDataSize( destsize );
-  return gs;
-}*/
-
-
 uint32_t Gamestate::calcGamestateSize(uint32_t id, uint8_t mode)
 {
Index: code/branches/mergeFS18/src/libraries/network/packet/Gamestate.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Gamestate.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Gamestate.h	(revision 12027)
@@ -57,6 +57,4 @@
     GamestateHeader(uint8_t* data)
       { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; }
-    /*GamestateHeader(uint8_t* data, GamestateHeader* h)
-      { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }*/
     void setData(uint8_t* data)
       { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; }
@@ -127,7 +125,5 @@
     inline uint32_t getDataSize() const { return header_.getDataSize(); }
     Gamestate* diffVariables(Gamestate *base);
-//     Gamestate* diffData(Gamestate *base);
-//     Gamestate *undiff(Gamestate *base);
-//     Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);
+
     bool compressData();
     bool decompressData();
@@ -136,12 +132,9 @@
     // Packet functions
   private:
-//     void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength);
-//     inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 );
+
     virtual uint32_t getSize() const override;
     virtual bool process(orxonox::Host* host) override;
     uint32_t calcGamestateSize(uint32_t id, uint8_t mode=0x0);
-//     inline void diffObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
-//     inline void copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
-    
+   
     std::list<obj>          dataVector_;
     GamestateHeader         header_;
Index: code/branches/mergeFS18/src/libraries/network/packet/Packet.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Packet.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Packet.cc	(revision 12027)
@@ -129,6 +129,11 @@
 }
 
+/**
+ * Send the Packet.
+ * @param host The host which sends the packet
+ */
 bool Packet::send(orxonox::Host* host)
 {
+  // Deny sending incoming packets
   if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional )
   {
@@ -136,7 +141,9 @@
     return false;
   }
+
   if(!enetPacket_)
   {
-    if(!data_){
+    // Deny sending empty packets
+    if(!data_) {
       assert(0);
       return false;
@@ -152,5 +159,5 @@
       // without having a reference in the packetMap_
       Packet::packetMapMutex_.lock();
-      packetMap_[reinterpret_cast<size_t>(enetPacket_)] = this;
+      Packet::packetMap_[reinterpret_cast<size_t>(enetPacket_)] = this;
       Packet::packetMapMutex_.unlock();
     }
@@ -173,55 +180,47 @@
   }
 #endif
-//  ENetPacket *temp = enetPacket_;
-//  enetPacket_ = nullptr; // otherwise we have a double free because enet already handles the deallocation of the packet
+
+  // Send via reliable or standard channel respectively
   if( this->flags_ & PacketFlag::Reliable )
     host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT);
   else
     host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_UNRELIABLE);
+
   return true;
 }
 
+/**
+ * Given an ENetPacket, create an Orxonox packet
+ * @param packet The ENetPacket
+ * @param peerID The sender
+ */
 Packet *Packet::createPacket(ENetPacket* packet, uint32_t peerID)
 {
   uint8_t *data = packet->data;
-//   assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
-//   unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();
-  // HACK
-//   if( peerID==static_cast<unsigned int>(-2))
-//     peerID = NETWORK_PEER_ID_SERVER;
   Packet *p = nullptr;
-//   orxout(verbose_ultra, context::packets) << "packet type: " << *(Type *)&data[_PACKETID] << endl;
   switch( *(Type *)(data + _PACKETID) )
   {
     case Type::Acknowledgement:
-//       orxout(verbose_more, context::packets) << "ack" << endl;
-    p = new Acknowledgement( data, peerID );
+      p = new Acknowledgement( data, peerID );
       break;
     case Type::Chat:
-//       orxout(verbose_more, context::packets) << "chat" << endl;
       p = new Chat( data, peerID );
       break;
     case Type::ClassID:
-//       orxout(verbose_more, context::packets) << "classid" << endl;
       p = new ClassID( data, peerID );
       break;
     case Type::Gamestate:
-//       orxout(verbose_more, context::packets) << "gamestate" << endl;
       p = new Gamestate( data, peerID );
       break;
     case Type::Welcome:
-//       orxout(verbose_more, context::packets) << "welcome" << endl;
       p = new Welcome( data, peerID );
       break;
     case Type::DeleteObjects:
-//       orxout(verbose_more, context::packets) << "deleteobjects" << endl;
       p = new DeleteObjects( data, peerID );
       break;
     case Type::FunctionCalls:
-//       orxout(verbose_more, context::packets) << "functionCalls" << endl;
       p = new FunctionCalls( data, peerID );
       break;
     case Type::FunctionIDs:
-//       orxout(verbose_more, context::packets) << "functionIDs" << endl;
       p = new FunctionIDs( data, peerID );
       break;
@@ -247,12 +246,14 @@
   // Get our Packet from a global map with all Packets created in the send() method of Packet.
   Packet::packetMapMutex_.lock();
-  std::map<size_t, Packet*>::iterator it = packetMap_.find(reinterpret_cast<size_t>(enetPacket));
+
+  std::map<size_t, Packet*>::iterator it = Packet::packetMap_.find(reinterpret_cast<size_t>(enetPacket));
   assert(it != packetMap_.end());
+
   // Make sure we don't delete it again in the destructor
   it->second->enetPacket_ = nullptr;
   delete it->second;
   packetMap_.erase(it);
+
   Packet::packetMapMutex_.unlock();
-//   orxout(verbose_ultra, context::packets) << "PacketMap size: " << packetMap_.size() << endl;
 }
 
Index: code/branches/mergeFS18/src/libraries/network/packet/Packet.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/Packet.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/Packet.h	(revision 12027)
@@ -68,6 +68,9 @@
 
     virtual unsigned char* getData(){ return data_; };
-    virtual unsigned int getSize() const =0;
-    virtual bool process(orxonox::Host* host)=0;
+    virtual unsigned int getSize() const = 0;
+
+    // Invoke some sort of action associated with the packet
+    virtual bool process(orxonox::Host* host) = 0;
+    
     inline uint32_t getFlags()
       { return flags_; }
@@ -82,8 +85,8 @@
 
     virtual bool send(orxonox::Host* host);
+
   protected:
     Packet();
     Packet(uint8_t *data, unsigned int peerID);
-//    Packet(ENetPacket *packet, ENetPeer *peer);
     inline bool isDataENetAllocated() const
       { return bDataENetAllocated_; }
@@ -100,5 +103,7 @@
         data_ might no correlate with enetPacket_->data. */
     bool bDataENetAllocated_;
+
   private:
+    // All Packets are contained in this map
     static std::map<size_t, Packet *> packetMap_;
     static boost::mutex               packetMapMutex_;
Index: code/branches/mergeFS18/src/libraries/network/packet/ServerInformation.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/packet/ServerInformation.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/packet/ServerInformation.cc	(revision 12027)
@@ -50,6 +50,8 @@
       // Save Server Round Trip Time
       this->serverRTT_ = event->peer->roundTripTime;
+
       // Save Server Address, leave some space for scope ID
       enet_address_get_host_ip(&event->peer->address, serverIP, 64);
+
       this->serverIP_ = std::string(serverIP);
       // Save ACK
@@ -57,9 +59,4 @@
       char* ack = nullptr;
       loadAndIncrease((char*&)ack, temp);
-
-      /* Fabian, what is this used for? it crashes the masterserver, hence commenting it */
-      // written by Oli: this is just to make sure that loadAndIncrease really writes the whole ACK string into char* ack
-//       assert(strcmp(ack, (const char*)LAN_DISCOVERY_ACK)==0);
-
       // Save Server Name
       loadAndIncrease(this->serverName_, temp);
@@ -74,5 +71,5 @@
     void ServerInformation::send(ENetPeer* peer)
     {
-      std::string payload = this->serverName_ + Ogre::StringConverter::toString(this->clientNumber_);
+      std::string payload = this->serverName_ + std::to_string(this->clientNumber_);
       uint32_t size = returnSize(LAN_DISCOVERY_ACK) + returnSize(payload);
       uint8_t* temp = new uint8_t[size];
Index: code/branches/mergeFS18/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/mergeFS18/src/libraries/network/synchronisable/Synchronisable.cc	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/synchronisable/Synchronisable.cc	(revision 12027)
@@ -43,5 +43,5 @@
   std::queue<uint32_t> Synchronisable::deletedObjects_;
 
-  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
+  uint8_t Synchronisable::state_=0x1; // determines wheter we are server (default) or client
 
   RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>();
@@ -53,5 +53,5 @@
   Synchronisable::Synchronisable(Context* context)
   {
-      RegisterObject(Synchronisable);
+    RegisterObject(Synchronisable);
     static uint32_t idCounter=0;
     objectMode_=0x1; // by default do not send data to server
@@ -179,8 +179,6 @@
     assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
     no->setObjectID(header.getObjectID());
-    //no->contextID=header.getContextID(); //TODO: remove this
     no->setClassID(header.getClassID());
     assert(no->contextID_ == header.getContextID());
-    //assert(no->classID_ == header.getClassID());
     orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
           // update data and create object/entity...
@@ -189,5 +187,4 @@
     if (b)
     {
-//        b = no->create();
         assert(b);
     }
@@ -273,17 +270,13 @@
 
     orxout(verbose_more, context::network) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << endl;
-//     orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":";
     // copy to location
     for(SynchronisableVariableBase* variable : syncList_)
     {
       uint32_t varsize = variable->getData( mem, mode );
-//       orxout(verbose, context::network) << " " << varsize;
       tempsize += varsize;
       sizes.push_back(varsize);
       ++test;
-      //tempsize += (*i)->getSize( mode );
     }
     assert(tempsize!=0);  // if this happens an empty object (with no variables) would be transmitted
-//     orxout(verbose, context::network) << endl;
 
     header.setObjectID( this->objectID_ );
@@ -340,5 +333,4 @@
     }
 
-    //orxout(verbose_more, context::network) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << endl;
     if( !syncHeaderLight.isDiffed() )
     {
@@ -357,9 +349,7 @@
     {
       mem += SynchronisableHeaderLight::getSize();
-//       orxout(debug_output, context::network) << "objectID: " << this->objectID_ << endl;
       while( mem < data+syncHeaderLight.getDataSize()+SynchronisableHeaderLight::getSize() )
       {
         VariableID varID = *(VariableID*)mem;
-//         orxout(debug_output, context::network) << "varID: " << varID << endl;
         assert( varID < syncList_.size() );
         mem += sizeof(VariableID);
@@ -400,6 +390,4 @@
   bool Synchronisable::doSync(/*int32_t id,*/ uint8_t mode)
   {
-//     if(mode==0x0)
-//       mode=state_;
     assert(mode!=0x0);
     return ( (this->objectMode_ & mode)!=0 && (!syncList_.empty() ) );
Index: code/branches/mergeFS18/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/branches/mergeFS18/src/libraries/network/synchronisable/Synchronisable.h	(revision 12026)
+++ code/branches/mergeFS18/src/libraries/network/synchronisable/Synchronisable.h	(revision 12027)
@@ -134,9 +134,4 @@
         { memcpy(data_, h.data_, getSize()); }
   };
-  
-//   inline void operator=(SynchronisableHeaderLight& h1, SynchronisableHeader& h2)
-//   {
-//     memcpy(h1.data_, h2.data_, h1.getSize());
-//   }
 
   /**
