Index: /code/branches/network5/src/libraries/network/Client.cc
===================================================================
--- /code/branches/network5/src/libraries/network/Client.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/Client.cc	(revision 7759)
@@ -164,5 +164,5 @@
           COUT(4) << "client tick: sending gs " << gs << std::endl;
           if( !gs->send() )
-            COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
+            COUT(2) << "Problem adding partial gamestate to queue" << std::endl;
         // gs gets automatically deleted by enet callback
         }
Index: /code/branches/network5/src/libraries/network/FunctionCallManager.cc
===================================================================
--- /code/branches/network5/src/libraries/network/FunctionCallManager.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/FunctionCallManager.cc	(revision 7759)
@@ -30,9 +30,10 @@
 #include "packet/FunctionCalls.h"
 #include "core/GameMode.h"
+#include "GamestateHandler.h"
 
 namespace orxonox {
 
 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sClientMap_;
-std::vector<FunctionCall> FunctionCallManager::sIncomingFunctionCallBuffer_;
+std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
 
 // Static calls
@@ -164,19 +165,22 @@
 }
 
-void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall)
+void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t clientID)
 {
-  if( !GameMode::isMaster() )
-    FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( fctCall );
+  FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, clientID)));
 }
 
 void FunctionCallManager::processBufferedFunctionCalls()
 {
-  std::vector<FunctionCall>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
+  std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > >::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
   while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
   {
-    if( it->execute() )
+    uint32_t minGamestateID = it->second.first;
+    uint32_t clientID       = it->second.second;
+    if( minGamestateID <= GamestateHandler::getInstance()->getLastProcessedGamestateID(clientID) && it->first.execute() )
       FunctionCallManager::sIncomingFunctionCallBuffer_.erase(it);
     else
+    {
       ++it;
+    }
   }
 }
Index: /code/branches/network5/src/libraries/network/FunctionCallManager.h
===================================================================
--- /code/branches/network5/src/libraries/network/FunctionCallManager.h	(revision 7758)
+++ /code/branches/network5/src/libraries/network/FunctionCallManager.h	(revision 7759)
@@ -34,4 +34,5 @@
 #include <map>
 #include <vector>
+#include <utility>
 #include "util/UtilPrereqs.h"
 #include "FunctionCall.h"
@@ -61,9 +62,9 @@
   static void sendCalls();
   
-  static void bufferIncomingFunctionCall( const FunctionCall& fctCall );
+  static void bufferIncomingFunctionCall( const FunctionCall& fctCall, uint32_t minGamestateID, uint32_t clientID );
   static void processBufferedFunctionCalls();
 
-  static std::map<uint32_t, packet::FunctionCalls*> sClientMap_;
-  static std::vector<FunctionCall>                  sIncomingFunctionCallBuffer_;
+  static std::map<uint32_t, packet::FunctionCalls*>                           sClientMap_;
+  static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t> > > sIncomingFunctionCallBuffer_;
 protected:
   FunctionCallManager();
Index: /code/branches/network5/src/libraries/network/GamestateClient.cc
===================================================================
--- /code/branches/network5/src/libraries/network/GamestateClient.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/GamestateClient.cc	(revision 7759)
@@ -39,17 +39,20 @@
 namespace orxonox
 {
-  struct _NetworkExport GameStateItem{
+  struct _NetworkExport GameStateItem
+  {
     packet::Gamestate *state;
     unsigned int id;
   };
 
-  GamestateClient::GamestateClient() {
+  GamestateClient::GamestateClient()
+  {
     COUT(5) << "this: " << this << std::endl;
-    last_diff_=0;
-    last_gamestate_=GAMESTATEID_INITIAL-1;
+    lastAckedGamestateID_=GAMESTATEID_INITIAL-1;
+    lastProcessedGamestateID_=GAMESTATEID_INITIAL-1;
     tempGamestate_=NULL;
   }
 
-  GamestateClient::~GamestateClient() {
+  GamestateClient::~GamestateClient()
+  {
       std::map<unsigned int, packet::Gamestate *>::iterator it;
       for ( it = this->gamestateMap_.begin(); it != this->gamestateMap_.end(); ++it )
@@ -59,10 +62,13 @@
   }
 
-  bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID){
+  bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID)
+  {
     return true;
   }
 
-  bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID){
-    if(tempGamestate_!=NULL){
+  bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID)
+  {
+    if(tempGamestate_!=NULL)
+    {
       //delete the obsolete gamestate
       if(tempGamestate_->getID()>gs->getID())
@@ -74,5 +80,6 @@
   }
 
-  bool GamestateClient::processGamestates(){
+  bool GamestateClient::processGamestates()
+  {
     if(tempGamestate_==NULL)
       return false;
@@ -85,5 +92,7 @@
     NetworkCallbackManager::callCallbacks();
 
-    if (!processed){
+    if (!processed)
+    {
+      assert(0);
       sendAck(0);
       return false;
@@ -92,6 +101,7 @@
     tempGamestate_=NULL;
     gamestateMap_[processed->getID()]=processed;
+    lastProcessedGamestateID_ = processed->getID();
     if(isDiffed)
-      last_diff_ = processed->getBaseID();
+      lastAckedGamestateID_ = processed->getBaseID();
     id = processed->getID();
     sendAck(id);
@@ -105,5 +115,6 @@
   * @return iterator pointing to the next object in the list
   */
-  void GamestateClient::removeObject(ObjectListIterator<Synchronisable> &it) {
+  void GamestateClient::removeObject(ObjectListIterator<Synchronisable> &it)
+  {
     ObjectListIterator<Synchronisable> temp=it;
     ++it;
@@ -111,7 +122,9 @@
   }
 
-  packet::Gamestate *GamestateClient::getGamestate(){
+  packet::Gamestate *GamestateClient::getGamestate()
+  {
     packet::Gamestate *gs = new packet::Gamestate();
-    if(!gs->collectData(0,0x2)){
+    if(!gs->collectData(this->getLastProcessedGamestateID(NETWORK_PEER_ID_SERVER), 0x2))
+    {
       delete gs;
       return 0;
@@ -120,8 +133,10 @@
   }
 
-  void GamestateClient::cleanup(){
+  void GamestateClient::cleanup()
+  {
     std::map<unsigned int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
-    while(it!=gamestateMap_.end()){
-      if(it->first>=last_diff_)
+    while(it!=gamestateMap_.end())
+    {
+      if(it->first>=lastAckedGamestateID_)
         break;
       // otherwise delete that stuff
@@ -133,8 +148,10 @@
   }
 
-  void GamestateClient::printGamestateMap(){
+  void GamestateClient::printGamestateMap()
+  {
     std::map<unsigned int, packet::Gamestate*>::iterator it;
     COUT(4) << "gamestates: ";
-    for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
+    for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++)
+    {
       COUT(4) << it->first << ':' << it->second << '|';
     }
@@ -143,11 +160,14 @@
   }
 
-  bool GamestateClient::sendAck(unsigned int gamestateID){
+  bool GamestateClient::sendAck(unsigned int gamestateID)
+  {
     packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0);
-    if(!ack->send()){
+    if(!ack->send())
+    {
       COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
       return false;
     }
-    else{
+    else
+    {
       COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
       return true;
@@ -155,5 +175,6 @@
   }
 
-  packet::Gamestate *GamestateClient::processGamestate(packet::Gamestate *gs){
+  packet::Gamestate *GamestateClient::processGamestate(packet::Gamestate *gs)
+  {
     if(gs->isCompressed())
     {
Index: /code/branches/network5/src/libraries/network/GamestateClient.h
===================================================================
--- /code/branches/network5/src/libraries/network/GamestateClient.h	(revision 7758)
+++ /code/branches/network5/src/libraries/network/GamestateClient.h	(revision 7759)
@@ -57,6 +57,8 @@
     ~GamestateClient();
 
-    bool add(packet::Gamestate *gs, unsigned int clientID);
-    bool ack(unsigned int gamestateID, unsigned int clientID);
+    virtual bool      add(packet::Gamestate *gs, unsigned int clientID);
+    virtual bool      ack(unsigned int gamestateID, unsigned int clientID);
+    virtual uint32_t  getLastProcessedGamestateID(unsigned int clientID) { return this->lastProcessedGamestateID_; }
+    virtual uint32_t  getCurrentGamestateID(){ return this->lastProcessedGamestateID_; }
 
     bool processGamestates();
@@ -69,6 +71,6 @@
     bool sendAck(unsigned int gamestateID);
 
-    unsigned int           last_diff_;
-    unsigned int           last_gamestate_;
+    unsigned int           lastAckedGamestateID_;
+    unsigned int           lastProcessedGamestateID_;
     std::map<unsigned int, packet::Gamestate *> gamestateMap_;
     packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
Index: /code/branches/network5/src/libraries/network/GamestateHandler.h
===================================================================
--- /code/branches/network5/src/libraries/network/GamestateHandler.h	(revision 7758)
+++ /code/branches/network5/src/libraries/network/GamestateHandler.h	(revision 7759)
@@ -32,4 +32,6 @@
 #include "NetworkPrereqs.h"
 
+#include <cassert>
+
 namespace orxonox {
 
@@ -39,8 +41,8 @@
 class _NetworkExport GamestateHandler{
   private:
-    virtual bool add(packet::Gamestate *gs, unsigned int clientID)=0;
-    virtual bool ack(unsigned int gamestateID, unsigned int clientID)=0;
+    virtual bool      add(packet::Gamestate *gs, unsigned int clientID)=0;
+    virtual bool      ack(unsigned int gamestateID, unsigned int clientID)=0;
 
-    static GamestateHandler *instance_;
+    static GamestateHandler* instance_;
 
 
@@ -50,6 +52,10 @@
 
   public:
-    static bool addGamestate(packet::Gamestate *gs, unsigned int clientID){ return instance_->add(gs, clientID); }
-    static bool ackGamestate(unsigned int gamestateID, unsigned int clientID){ return instance_->ack(gamestateID, clientID); }
+    static bool     addGamestate(packet::Gamestate *gs, unsigned int clientID){ return instance_->add(gs, clientID); }
+    static bool     ackGamestate(unsigned int gamestateID, unsigned int clientID){ return instance_->ack(gamestateID, clientID); }
+    static GamestateHandler* getInstance(){ assert(instance_); return instance_; }
+    
+    virtual uint32_t  getLastProcessedGamestateID( unsigned int clientID )=0;
+    virtual uint32_t  getCurrentGamestateID()=0;
 };
 
Index: /code/branches/network5/src/libraries/network/GamestateManager.cc
===================================================================
--- /code/branches/network5/src/libraries/network/GamestateManager.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/GamestateManager.cc	(revision 7759)
@@ -258,4 +258,13 @@
     return true;
   }
+  
+  uint32_t GamestateManager::getLastProcessedGamestateID(unsigned int clientID)
+  {
+    assert( this->lastProcessedGamestateID_.find(clientID) != this->lastProcessedGamestateID_.end() );
+    if( this->lastProcessedGamestateID_.find(clientID) != this->lastProcessedGamestateID_.end() )
+      return this->lastProcessedGamestateID_[clientID];
+    else
+      return GAMESTATEID_INITIAL;
+  }
 
   void GamestateManager::removeClient(ClientInformation* client){
@@ -277,5 +286,11 @@
     }
     assert(!gs->isDiffed());
-    return gs->spreadData(0x1);
+    if( gs->spreadData(0x1) )
+    {
+      this->lastProcessedGamestateID_[gs->getClientID()] = gs->getID();
+      return true;
+    }
+    else
+      return false;
   }
 
Index: /code/branches/network5/src/libraries/network/GamestateManager.h
===================================================================
--- /code/branches/network5/src/libraries/network/GamestateManager.h	(revision 7758)
+++ /code/branches/network5/src/libraries/network/GamestateManager.h	(revision 7759)
@@ -46,4 +46,5 @@
 #include "GamestateHandler.h"
 #include "core/CorePrereqs.h"
+#include "packet/Gamestate.h"
 
 namespace orxonox
@@ -71,5 +72,9 @@
     ~GamestateManager();
 
-    bool add(packet::Gamestate *gs, unsigned int clientID);
+    virtual bool      add(packet::Gamestate *gs, unsigned int clientID);
+    virtual bool      ack(unsigned int gamestateID, unsigned int clientID);
+    virtual uint32_t  getLastProcessedGamestateID( unsigned int clientID );
+    virtual uint32_t  getCurrentGamestateID(){ return reference->getID(); }
+    
     bool processGamestates();
     bool update();
@@ -80,5 +85,4 @@
     bool getSnapshot();
 
-    bool ack(unsigned int gamestateID, unsigned int clientID);
     void removeClient(ClientInformation *client);
   private:
@@ -87,4 +91,5 @@
     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_;
     packet::Gamestate *reference;
     TrafficControl *trafficControl_;
Index: /code/branches/network5/src/libraries/network/MasterServerComm.cc
===================================================================
--- /code/branches/network5/src/libraries/network/MasterServerComm.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/MasterServerComm.cc	(revision 7759)
@@ -89,5 +89,5 @@
 
     /* Wait up to 2 seconds for the connection attempt to succeed. */
-    if (enet_host_service (this->client, this->event, 2000) > 0 &&
+    if (enet_host_service (this->client, this->event, 500) > 0 &&
         this->event->type == ENET_EVENT_TYPE_CONNECT )
       COUT(3) << "Connection to master server succeeded.\n";
Index: /code/branches/network5/src/libraries/network/NetworkPrereqs.h
===================================================================
--- /code/branches/network5/src/libraries/network/NetworkPrereqs.h	(revision 7758)
+++ /code/branches/network5/src/libraries/network/NetworkPrereqs.h	(revision 7759)
@@ -69,4 +69,5 @@
   extern const char* LAN_DISCOVERY_ACK;
   static const unsigned int LAN_DISCOVERY_PORT      = 55557;
+  static const unsigned int NETWORK_PEER_ID_SERVER = 0;
 }
 
@@ -83,7 +84,7 @@
       enum Value
       {
-        Reliable   = 1,
-        Unsequence = 2,
-        NoAllocate = 4
+        Reliable    = 1,
+        Unsequenced = 2,
+        NoAllocate  = 4
       };
     }
Index: /code/branches/network5/src/libraries/network/Server.cc
===================================================================
--- /code/branches/network5/src/libraries/network/Server.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/Server.cc	(revision 7759)
@@ -217,4 +217,5 @@
       // process incoming gamestates
       GamestateManager::processGamestates();
+      FunctionCallManager::processBufferedFunctionCalls();
 
       // send function calls to clients
Index: /code/branches/network5/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- /code/branches/network5/src/libraries/network/packet/FunctionCalls.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/packet/FunctionCalls.cc	(revision 7759)
@@ -32,4 +32,5 @@
 #include "network/FunctionCall.h"
 #include "network/FunctionCallManager.h"
+#include "network/GamestateHandler.h"
 
 namespace orxonox {
@@ -40,13 +41,13 @@
 const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000;
 
-FunctionCalls::FunctionCalls()
- : Packet()
+FunctionCalls::FunctionCalls():
+  Packet(), minGamestateID_(GAMESTATEID_INITIAL)
 {
   flags_ = flags_ | PACKET_FLAGS_FUNCTIONCALLS;
-  currentSize_ = 2*sizeof(uint32_t); // for packetid and nrOfCalls
+  currentSize_ = 3*sizeof(uint32_t); // for packetid, nrOfCalls and minGamestateID_
 }
 
-FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID )
-  : Packet(data, clientID)
+FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID ): 
+  Packet(data, clientID), minGamestateID_(GAMESTATEID_INITIAL)
 {
 }
@@ -63,10 +64,14 @@
   uint32_t nrOfCalls = *(uint32_t*)temp;
   temp += sizeof(uint32_t);
+  this->minGamestateID_ = *(uint32_t*)temp;
+  temp += sizeof(uint32_t);
   for( unsigned int i = 0; i<nrOfCalls; i++ )
   {
     FunctionCall fctCall;
     fctCall.loadData(temp);
-    if( !fctCall.execute() )
-      FunctionCallManager::bufferIncomingFunctionCall( fctCall );
+    if( this->minGamestateID_ > GamestateHandler::getInstance()->getLastProcessedGamestateID(this->getClientID()) || !fctCall.execute() )
+    {
+      FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getClientID() );
+    }
   }
   
@@ -93,9 +98,11 @@
 bool FunctionCalls::send()
 {
+  this->minGamestateID_ = GamestateHandler::getInstance()->getCurrentGamestateID();
   assert(this->functionCalls_.size());
   data_=new uint8_t[ currentSize_ ];
   *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
-  *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls to 0
-  uint8_t* temp = data_+2*sizeof(uint32_t);
+  *(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);
   
   while( this->functionCalls_.size() )
Index: /code/branches/network5/src/libraries/network/packet/FunctionCalls.h
===================================================================
--- /code/branches/network5/src/libraries/network/packet/FunctionCalls.h	(revision 7758)
+++ /code/branches/network5/src/libraries/network/packet/FunctionCalls.h	(revision 7759)
@@ -62,4 +62,5 @@
   std::queue<orxonox::FunctionCall> functionCalls_;
   unsigned int                      clientID_;
+  uint32_t                          minGamestateID_;
   uint32_t                          currentSize_;
 };
Index: /code/branches/network5/src/libraries/network/packet/Gamestate.cc
===================================================================
--- /code/branches/network5/src/libraries/network/packet/Gamestate.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/packet/Gamestate.cc	(revision 7759)
@@ -43,5 +43,7 @@
 #define GAMESTATE_START(data) (data + GamestateHeader::getSize())
 
-#define PACKET_FLAG_GAMESTATE  0 //PacketFlag::Reliable
+// #define PACKET_FLAG_GAMESTATE  PacketFlag::Unsequenced
+// #define PACKET_FLAG_GAMESTATE  0
+#define PACKET_FLAG_GAMESTATE  PacketFlag::Reliable
 
 inline bool memzero( uint8_t* data, uint32_t datalength)
@@ -364,9 +366,4 @@
 inline void /*Gamestate::*/diffObject( uint8_t*& newDataPtr, uint8_t*& origDataPtr, uint8_t*& baseDataPtr, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes )
 {
-  //       COUT(4) << "dodiff" << endl;
-  //       if(baseOffset==0)
-  //       {
-  //         assert(origOffset==0);
-  //       }
   assert( objectHeader.getDataSize() == SynchronisableHeader(baseDataPtr).getDataSize() );
   
@@ -382,8 +379,4 @@
   else
   {
-    //         if( Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() == "Bot" )
-    //           COUT(0) << "blub" << endl;
-    //         COUT(4) << "object diff: " << Synchronisable::getSynchronisable(h.getObjectID())->getIdentifier()->getName() << endl;
-    //         COUT(4) << "diff " << h.getObjectID() << ":";
     // Now start to diff the Object
     SynchronisableHeaderLight newObjectHeader(newDataPtr);
@@ -396,5 +389,4 @@
       // check whether variable changed and write id and copy over variable to the new stream
       // otherwise skip variable
-//       assert(sizes != this->sizes_.end());
       uint32_t varSize = *sizes;
       assert( varSize == Synchronisable::getSynchronisable(objectHeader.getObjectID())->getVarSize(variableID) );
@@ -403,5 +395,4 @@
         if ( memcmp(origDataPtr+objectOffset, baseDataPtr+objectOffset, varSize) != 0 )
         {
-          //               COUT(4) << "copy variable" << endl;
           *(VariableID*)(newDataPtr+diffedObjectOffset) = variableID; // copy over the variableID
           diffedObjectOffset += sizeof(VariableID);
@@ -412,18 +403,15 @@
         else
         {
-          //               COUT(4) << "skip variable" << endl;
           objectOffset += varSize;
         }
       }
-//           else
-//             COUT(4) << "varsize 0" << endl;
 
       ++variableID;
       ++sizes;
     }
-            
+    
+    // if there are variables from this object with 0 size left in sizes
     if( Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables() != variableID )
       sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables() - variableID;
-    //         COUT(4) << endl;
     
     newObjectHeader.setDiffed(true);
@@ -431,18 +419,6 @@
     assert(objectOffset == objectHeader.getDataSize()+SynchronisableHeader::getSize());
     assert(newObjectHeader.getDataSize()>0);
+    
     origDataPtr += objectOffset;
-    //         baseOffset += temp + h.getDataSize()+SynchronisableHeader::getSize() - baseData;
-    //baseOffset += objectOffset;
-    //         SynchronisableHeader htemp(temp);
-    //         baseOffset += SynchronisableHeader::getSize() + htemp.getDataSize();
-    //         {
-      //           SynchronisableHeader htemp2( baseData+(temp-baseData+objectOffset) );
-    //           if( baseData+(temp-baseData+objectOffset) < baseData+baseLength )
-    //           {
-      //             assert(htemp2.getClassID()<500);
-    //             assert(htemp2.getDataSize()!=0 && htemp2.getDataSize()<1000);
-    //             assert(htemp2.isDiffed()==false);
-    //           }
-    //         }
     baseDataPtr += objectOffset;
     newDataPtr += diffedObjectOffset;
@@ -455,4 +431,6 @@
   // Just copy over the whole Object
   memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() );
+  SynchronisableHeader(newData).setDiffed(false);
+  
   newData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
   origData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
@@ -547,7 +525,15 @@
     assert(sizesIt != this->sizes_.end());
     
+    assert(Synchronisable::getSynchronisable(origHeader.getObjectID()));
+    assert(ClassByID(origHeader.getClassID()));
+    assert(origHeader.getDataSize() < 500);
+    
     bool diffedObject = false;
     if( findObject(baseDataPtr, baseDataEnd, origHeader) )
     {
+      SynchronisableHeader baseHeader(baseDataPtr);
+      assert(Synchronisable::getSynchronisable(baseHeader.getObjectID()));
+      assert(ClassByID(baseHeader.getClassID()));
+      assert(baseHeader.getDataSize() < 500);
       if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
       {
@@ -570,4 +556,8 @@
       if( findObject(baseDataPtr, oldBaseDataPtr, origHeader) )
       {
+        SynchronisableHeader baseHeader(baseDataPtr);
+        assert(Synchronisable::getSynchronisable(baseHeader.getObjectID()));
+        assert(ClassByID(baseHeader.getClassID()));
+        assert(baseHeader.getDataSize() < 500);
         if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
         {
Index: /code/branches/network5/src/libraries/network/packet/Packet.cc
===================================================================
--- /code/branches/network5/src/libraries/network/packet/Packet.cc	(revision 7758)
+++ /code/branches/network5/src/libraries/network/packet/Packet.cc	(revision 7759)
@@ -53,7 +53,7 @@
 
 // Make sure we assume the right values
-BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable)   == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));
-BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequence) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));
-BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));
+BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable)    == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));
+BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));
+BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate)  == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));
 
 #define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate
@@ -174,42 +174,41 @@
   unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
   Packet *p = 0;
-  COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
+//   COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
   switch( *(Type::Value *)(data + _PACKETID) )
   {
     case Type::Acknowledgement:
-      COUT(5) << "ack" << std::endl;
+//       COUT(5) << "ack" << std::endl;
       p = new Acknowledgement( data, clientID );
       break;
     case Type::Chat:
-      COUT(5) << "chat" << std::endl;
+//       COUT(5) << "chat" << std::endl;
       p = new Chat( data, clientID );
       break;
     case Type::ClassID:
-      COUT(5) << "classid" << std::endl;
+//       COUT(5) << "classid" << std::endl;
       p = new ClassID( data, clientID );
       break;
     case Type::Gamestate:
-      COUT(5) << "gamestate" << std::endl;
-      // TODO: remove brackets
+//       COUT(5) << "gamestate" << std::endl;
       p = new Gamestate( data, clientID );
       break;
     case Type::Welcome:
-      COUT(5) << "welcome" << std::endl;
+//       COUT(5) << "welcome" << std::endl;
       p = new Welcome( data, clientID );
       break;
     case Type::DeleteObjects:
-      COUT(5) << "deleteobjects" << std::endl;
+//       COUT(5) << "deleteobjects" << std::endl;
       p = new DeleteObjects( data, clientID );
       break;
     case Type::FunctionCalls:
-      COUT(5) << "functionCalls" << std::endl;
+//       COUT(5) << "functionCalls" << std::endl;
       p = new FunctionCalls( data, clientID );
       break;
     case Type::FunctionIDs:
-      COUT(5) << "functionIDs" << std::endl;
+//       COUT(5) << "functionIDs" << std::endl;
       p = new FunctionIDs( data, clientID );
       break;
     default:
-      assert(0); //TODO: repair this
+      assert(0);
       break;
   }
@@ -235,5 +234,5 @@
   delete it->second;
   packetMap_.erase(it);
-  COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
+//   COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
 }
 
Index: /code/branches/network5/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- /code/branches/network5/src/libraries/network/synchronisable/Synchronisable.h	(revision 7758)
+++ /code/branches/network5/src/libraries/network/synchronisable/Synchronisable.h	(revision 7759)
@@ -65,50 +65,4 @@
     };
   }
-  
-  typedef uint8_t VariableID;
-
-  /**
-   * @brief: stores information about a Synchronisable
-   *
-   * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
-   * in an emulated bitset.
-   * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
-   * Bit 32 is a bool and defines whether the variables are stored in diff mode
-   * Byte 5 to 8: objectID_
-   * Byte 9 to 12: classID_
-   * Byte 13 to 16: creatorID_
-   */
-  class _NetworkExport SynchronisableHeader{
-    friend class SynchronisableHeaderLight;
-    private:
-      uint8_t* data_;
-    public:
-      SynchronisableHeader(uint8_t* data)
-        { data_ = data; }
-      inline static uint32_t getSize()
-        { return 14; }
-      inline uint16_t getDataSize() const
-        { return (*(uint16_t*)data_) & 0x7FFF; } //only use the first 15 bits
-      inline void setDataSize(uint16_t size)
-        { *(uint16_t*)(data_) = (size & 0x7FFF) | (*(uint16_t*)(data_) & 0x8000 ); }
-      inline bool isDiffed() const
-        { return ( (*(uint16_t*)data_) & 0x8000 ) == 0x8000; }
-      inline void setDiffed( bool b)
-        { *(uint16_t*)(data_) = (b << 15) | (*(uint16_t*)(data_) & 0x7FFF ); }
-      inline uint32_t getObjectID() const
-        { return *(uint32_t*)(data_+2); }
-      inline void setObjectID(uint32_t objectID_)
-        { *(uint32_t*)(data_+2) = objectID_; }
-      inline uint32_t getClassID() const
-        { return *(uint32_t*)(data_+6); }
-      inline void setClassID(uint32_t classID_)
-        { *(uint32_t*)(data_+6) = classID_; }
-      inline uint32_t getCreatorID() const
-        { return *(uint32_t*)(data_+10); }
-      inline void setCreatorID(uint32_t creatorID_)
-        { *(uint32_t*)(data_+10) = creatorID_; }
-      inline void operator=(SynchronisableHeader& h)
-        { memcpy(data_, h.data_, getSize()); }
-  };
 
     /**
@@ -121,6 +75,7 @@
    * Byte 5 to 8: objectID_
    */
-  class _NetworkExport SynchronisableHeaderLight{
-    private:
+  class _NetworkExport SynchronisableHeaderLight
+  {
+    protected:
       uint8_t* data_;
     public:
@@ -141,7 +96,44 @@
       inline void setObjectID(uint32_t objectID_)
         { *(uint32_t*)(data_+2) = objectID_; }
+      inline void operator=(SynchronisableHeaderLight& h)
+        { memcpy(data_, h.data_, SynchronisableHeaderLight::getSize()); }
+  };
+  
+  typedef uint8_t VariableID;
+  
+  /**
+   * @brief: stores information about a Synchronisable
+   *
+   * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
+   * in an emulated bitset.
+   * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
+   * Bit 32 is a bool and defines whether the variables are stored in diff mode
+   * Byte 5 to 8: objectID_
+   * Byte 9 to 12: classID_
+   * Byte 13 to 16: creatorID_
+   */
+  class _NetworkExport SynchronisableHeader: public SynchronisableHeaderLight
+  {
+    public:
+      SynchronisableHeader(uint8_t* data): SynchronisableHeaderLight(data)
+        {}
+      inline static uint32_t getSize()
+        { return SynchronisableHeaderLight::getSize()+8; }
+      inline uint32_t getClassID() const
+        { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()); }
+      inline void setClassID(uint32_t classID_)
+        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()) = classID_; }
+      inline uint32_t getCreatorID() const
+        { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4); }
+      inline void setCreatorID(uint32_t creatorID_)
+        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = creatorID_; }
       inline void operator=(SynchronisableHeader& h)
         { memcpy(data_, h.data_, getSize()); }
   };
+  
+//   inline void operator=(SynchronisableHeaderLight& h1, SynchronisableHeader& h2)
+//   {
+//     memcpy(h1.data_, h2.data_, h1.getSize());
+//   }
 
   /**
