Index: code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.cc	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/Acknowledgement.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.h	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Acknowledgement.h	(revision 12020)
@@ -34,9 +34,9 @@
 
 namespace orxonox {
+	
 const unsigned int ACKID_NACK = 0;
+
 namespace packet {
-/**
-    @author
-*/
+
 class _NetworkExport Acknowledgement : public Packet
 {
Index: code/branches/PresentationFS18/src/libraries/network/packet/Chat.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Chat.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Chat.cc	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/Chat.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Chat.h	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Chat.h	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/ClassID.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/ClassID.cc	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/DeleteObjects.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/DeleteObjects.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/DeleteObjects.cc	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/FunctionCalls.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/FunctionCalls.cc	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.cc	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/Gamestate.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.h	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Gamestate.h	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/Packet.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Packet.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Packet.cc	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/Packet.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/Packet.h	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/Packet.h	(revision 12020)
@@ -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/PresentationFS18/src/libraries/network/packet/ServerInformation.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/network/packet/ServerInformation.cc	(revision 12012)
+++ code/branches/PresentationFS18/src/libraries/network/packet/ServerInformation.cc	(revision 12020)
@@ -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];
