Index: code/branches/netp6/src/core/CorePrereqs.h
===================================================================
--- code/branches/netp6/src/core/CorePrereqs.h	(revision 3239)
+++ code/branches/netp6/src/core/CorePrereqs.h	(revision 3240)
@@ -189,5 +189,5 @@
     // multithreading
     class Thread;
-    class ThreadGroup;
+    class ThreadPool;
 }
 
Index: code/branches/netp6/src/core/Thread.cc
===================================================================
--- code/branches/netp6/src/core/Thread.cc	(revision 3239)
+++ code/branches/netp6/src/core/Thread.cc	(revision 3240)
@@ -36,5 +36,5 @@
 
 #include "util/Sleep.h"
-#include "Functor.h"
+#include "Executor.h"
 
 namespace orxonox
@@ -44,9 +44,11 @@
     
     Thread::Thread():
-        functor_(0),
+        executor_(0),
         isWorking_(false),
         stopThread_(false)
     {
-        this->communicationMutex_ = new boost::mutex;
+        this->executorMutex_ = new boost::mutex;
+        this->isWorkingMutex_ = new boost::mutex;
+        this->stopThreadMutex_ = new boost::mutex;
         this->workerThread_ = new boost::thread( boost::bind(&Thread::threadLoop, this) );
     }
@@ -54,38 +56,60 @@
     Thread::~Thread()
     {
+        this->stopThreadMutex_->lock();
         this->stopThread_ = true;
+        this->stopThreadMutex_->unlock();
         if( !this->workerThread_->timed_join( THREAD_WAIT_BEFORE_DETACH ) )
             assert(0); // this should not happen
         delete this->workerThread_;
-        delete this->communicationMutex_;
+        delete this->executorMutex_;
+        delete this->stopThreadMutex_;
+        delete this->isWorkingMutex_;
     }
     
-    bool Thread::evaluateFunctor( Functor* functor )
+    bool Thread::isWorking()
     {
-        if( this->communicationMutex_->try_lock() )
-        {
-            this->functor_ = functor;
-            this->communicationMutex_->unlock();
-            return true;
-        }
-        else
-            return false;
+      this->isWorkingMutex_->lock();
+      bool isWorking = this->isWorking_;
+      this->isWorkingMutex_->unlock();
+      return isWorking;
+    }
+    
+    bool Thread::evaluateExecutor( Executor* executor )
+    {
+        this->isWorkingMutex_->lock();
+        this->isWorking_=true;
+        this->isWorkingMutex_->unlock();
+        this->executorMutex_->lock();
+        this->executor_ = executor;
+        this->executorMutex_->unlock();
+        return true;
     }
     
     void Thread::threadLoop()
     {
-        while( !this->stopThread_ )
+        bool stopThread = false;
+        while( !stopThread )
         {
-            this->communicationMutex_->lock();
-            if( this->functor_ )
+            this->executorMutex_->lock();
+            Executor* executor = this->executor_;
+            this->executorMutex_->unlock();
+            if( executor )
             {
-                (*this->functor_)();
-                this->communicationMutex_->unlock();
+                (*executor)();
+                this->executorMutex_->lock();
+                delete this->executor_;
+                this->executor_ = 0;
+                this->executorMutex_->unlock();
+                this->isWorkingMutex_->lock();
+                this->isWorking_=false;
+                this->isWorkingMutex_->unlock();
             }
             else
             {
-                this->communicationMutex_->unlock();
                 this->workerThread_->yield();
             }
+            this->stopThreadMutex_->lock();
+            stopThread = this->stopThread_;
+            this->stopThreadMutex_->unlock();
         }
     }
@@ -96,7 +120,7 @@
         while( stillWorking )
         {
-            this->communicationMutex_->lock();
+            this->isWorkingMutex_->lock();
             stillWorking = this->isWorking_;
-            this->communicationMutex_->unlock();
+            this->isWorkingMutex_->unlock();
             if( stillWorking )
                 msleep( 1 );
Index: code/branches/netp6/src/core/Thread.h
===================================================================
--- code/branches/netp6/src/core/Thread.h	(revision 3239)
+++ code/branches/netp6/src/core/Thread.h	(revision 3240)
@@ -32,4 +32,8 @@
 #include "CorePrereqs.h"
 
+namespace boost{
+  class recursive_mutex;
+}
+
  namespace orxonox
 {
@@ -40,16 +44,18 @@
         virtual ~Thread();
 
-        inline bool isWorking() { return this->isWorking_; }
+        bool isWorking();
         void waitUntilFinished();
-        bool evaluateFunctor( Functor* functor );
+        bool evaluateExecutor( Executor* executor );
 
     private:
         void            threadLoop();
         
-        Functor*        functor_;
+        Executor*       executor_;
         bool            isWorking_;
         bool            stopThread_;
         boost::thread*  workerThread_;
-        boost::mutex*   communicationMutex_;
+        boost::mutex*   executorMutex_;
+        boost::mutex*     isWorkingMutex_;
+        boost::mutex*   stopThreadMutex_;
     };
 
Index: code/branches/netp6/src/core/ThreadPool.cc
===================================================================
--- code/branches/netp6/src/core/ThreadPool.cc	(revision 3239)
+++ code/branches/netp6/src/core/ThreadPool.cc	(revision 3240)
@@ -28,4 +28,5 @@
 
 #include "ThreadPool.h"
+#include "Thread.h"
 #include <cassert>
 
@@ -39,4 +40,6 @@
     ThreadPool::~ThreadPool()
     {
+        unsigned int a = this->setNrOfThreads(0);
+        assert(a == 0);
     }
     
@@ -44,17 +47,21 @@
     {
         for( unsigned int i=0; i<nr; i++ )
-            this->threadPool_.push_back(Thread());
+            this->threadPool_.push_back(new Thread());
     }
     unsigned int ThreadPool::removeThreads( unsigned int nr )
     {
         unsigned int i=0;
-        std::vector<Thread>::iterator it;
-        for( it = this->threadPool_.begin(); it != threadPool_.end() && i<nr; ++it )
+        std::vector<Thread*>::iterator it;
+        for( it = this->threadPool_.begin(); it != threadPool_.end() && i<nr; )
         {
-            if( ! it->isWorking() )
+            if( ! (*it)->isWorking() )
             {
-                this->threadPool_.erase( it++ );
+                Thread* temp = *it;
+                it=this->threadPool_.erase( it );
+                delete temp;
                 ++i;
             }
+            else
+              ++it;
         }
         return i;
@@ -74,12 +81,12 @@
     }
     
-    bool ThreadPool::passFunction( Functor* functor, bool addThread )
+    bool ThreadPool::passFunction( Executor* executor, bool addThread )
     {
-        std::vector<Thread>::iterator it;
+        std::vector<Thread*>::iterator it;
         for ( it=this->threadPool_.begin(); it!=this->threadPool_.end(); ++it )
         {
-            if ( ! it->isWorking() )
+            if ( ! (*it)->isWorking() )
             {
-                bool b = it->evaluateFunctor( functor );
+                bool b = (*it)->evaluateExecutor( executor );
                 assert(b); // if b is false then there is some code error
                 return true;
@@ -89,5 +96,6 @@
         {
             addThreads( 1 );
-            this->threadPool_.back().evaluateFunctor( functor ); // access the last element
+            bool b = this->threadPool_.back()->evaluateExecutor( executor ); // access the last element
+            assert(b);
             return true;
         }
@@ -98,8 +106,8 @@
     void ThreadPool::synchronise()
     {
-        std::vector<Thread>::iterator it;
+        std::vector<Thread*>::iterator it;
         for ( it=this->threadPool_.begin(); it!=this->threadPool_.end(); ++it )
         {
-            it->waitUntilFinished();
+            (*it)->waitUntilFinished();
         }
     }
Index: code/branches/netp6/src/core/ThreadPool.h
===================================================================
--- code/branches/netp6/src/core/ThreadPool.h	(revision 3239)
+++ code/branches/netp6/src/core/ThreadPool.h	(revision 3240)
@@ -33,5 +33,4 @@
 
 #include <vector>
-#include "Thread.h"
 
  namespace orxonox
@@ -47,9 +46,9 @@
         unsigned int setNrOfThreads( unsigned int nr );
         
-        bool passFunction( Functor* functor, bool addThread=false );
+        bool passFunction( Executor* executor, bool addThread=false );
         void synchronise();
         
     private:
-        std::vector<Thread> threadPool_;
+        std::vector<Thread*> threadPool_;
         
     };
Index: code/branches/netp6/src/network/GamestateManager.cc
===================================================================
--- code/branches/netp6/src/network/GamestateManager.cc	(revision 3239)
+++ code/branches/netp6/src/network/GamestateManager.cc	(revision 3240)
@@ -42,6 +42,10 @@
 
 #include <cassert>
+#include <queue>
+#include <boost/thread/mutex.hpp>
 
 #include "util/Debug.h"
+#include "core/Executor.h"
+#include "core/ThreadPool.h"
 #include "ClientInformation.h"
 #include "packet/Acknowledgement.h"
@@ -56,4 +60,6 @@
   {
     trafficControl_ = new TrafficControl();
+    threadMutex_ = new boost::mutex();
+    threadPool_ = new ThreadPool();
   }
 
@@ -71,5 +77,7 @@
         delete (*it2).second;
     }
-    delete trafficControl_;
+    delete this->trafficControl_;
+    delete this->threadMutex_;
+    delete this->threadPool_;
   }
 
@@ -116,30 +124,80 @@
     return true;
   }
-
-
-  packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) {
+  
+  void GamestateManager::sendGamestates()
+  {
+    ClientInformation *temp = ClientInformation::getBegin();
+    std::queue<packet::Gamestate*> clientGamestates;
+    while(temp != NULL){
+      if( !(temp->getSynched()) ){
+        COUT(5) << "Server: not sending gamestate" << std::endl;
+        temp=temp->next();
+        if(!temp)
+          break;
+        continue;
+      }
+      COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
+      COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
+      int cid = temp->getID(); //get client id
+      
+      packet::Gamestate *gs;
+      unsigned int gID = temp->getGamestateID();
+      if(!reference)
+        return;
+      
+      packet::Gamestate *client=0;
+      if(gID != GAMESTATEID_INITIAL){
+        assert(gamestateMap_.find(cid)!=gamestateMap_.end());
+        std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[cid].find(gID);
+        if(it!=gamestateMap_[cid].end())
+        {
+          client = it->second;
+        }
+      }
+      
+      clientGamestates.push(0);
+//       finishGamestate( cid, clientGamestates.back(), client, reference );
+      //FunctorMember<GamestateManager>* functor = 
+      ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate) );
+      executor->setObject(this);
+      executor->setDefaultValues( cid, &clientGamestates.back(), client, reference );
+//       (*static_cast<Executor*>(executor))();
+      this->threadPool_->passFunction( executor, true );
+//       (*functor)( cid, &(clientGamestates.back()), client, reference );
+      
+      temp = temp->next();
+    }
+    
+    threadPool_->synchronise();
+    
+    while( !clientGamestates.empty() )
+    {
+      if(clientGamestates.front())
+        clientGamestates.front()->send();
+      clientGamestates.pop();
+    }
+  }
+
+
+  void GamestateManager::finishGamestate( unsigned int clientID, 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?
-    packet::Gamestate *gs;
-    unsigned int gID = ClientInformation::findClient(clientID)->getGamestateID();
-    if(!reference)
-      return 0;
-    gs = reference->doSelection(clientID, 10000);
     // save the (undiffed) gamestate in the clients gamestate map
-    gamestateMap_[clientID][gs->getID()]=gs;
     //chose wheather the next gamestate is the first or not
-    packet::Gamestate *client=0;
-    if(gID != GAMESTATEID_INITIAL){
-      assert(gamestateMap_.find(clientID)!=gamestateMap_.end());
-      std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[clientID].find(gID);
-      if(it!=gamestateMap_[clientID].end())
-      {
-        client = it->second;
-      }
-    }
-    if(client){
+    
+    packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
+//     packet::Gamestate *gs = new packet::Gamestate(*gamestate);
+//     packet::Gamestate *gs = new packet::Gamestate();
+//     gs->collectData( id_, 0x1 );
+    this->threadMutex_->lock();
+    gamestateMap_[clientID][gamestate->getID()]=gs;
+    this->threadMutex_->unlock();
+    
+    if(base)
+    {
+        
 //       COUT(3) << "diffing" << std::endl;
 //       packet::Gamestate* gs1  = gs;
-      packet::Gamestate *diffed = gs->diff(client);
+      packet::Gamestate *diffed = gs->diff(base);
       //packet::Gamestate *gs2 = diffed->undiff(gs);
 //       assert(*gs == *gs2);
@@ -150,15 +208,17 @@
     }
     else{
-//       COUT(3) << "not diffing" << std::endl;
       gs = new packet::Gamestate(*gs);
     }
+    
+    
     bool b = gs->compressData();
     assert(b);
-    COUT(4) << "sending gamestate with id " << gs->getID();
-    if(gs->isDiffed())
-    COUT(4) << " and baseid " << gs->getBaseID() << endl;
-    else
-    COUT(4) << endl;
-    return gs;
+//     COUT(4) << "sending gamestate with id " << gs->getID();
+//     if(gamestate->isDiffed())
+//     COUT(4) << " and baseid " << gs->getBaseID() << endl;
+//     else
+//     COUT(4) << endl;
+    gs->setClientID(clientID);
+    *destgamestate = gs;
   }
 
Index: code/branches/netp6/src/network/GamestateManager.h
===================================================================
--- code/branches/netp6/src/network/GamestateManager.h	(revision 3239)
+++ code/branches/netp6/src/network/GamestateManager.h	(revision 3240)
@@ -45,4 +45,5 @@
 #include <map>
 #include "GamestateHandler.h"
+#include "core/CorePrereqs.h"
 
 namespace orxonox
@@ -73,5 +74,7 @@
     bool processGamestates();
     bool update();
-    packet::Gamestate *popGameState(unsigned int clientID);
+    void sendGamestates();
+//     packet::Gamestate *popGameState(unsigned int clientID);
+    void finishGamestate( unsigned int clientID, packet::Gamestate** destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate );
 
     bool getSnapshot();
@@ -79,14 +82,14 @@
     bool ack(unsigned int gamestateID, unsigned int clientID);
     void removeClient(ClientInformation *client);
-    private:
+  private:
     bool processGamestate(packet::Gamestate *gs);
 
     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
-    //std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
-    //std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
     std::map<unsigned int, packet::Gamestate*> gamestateQueue;
     packet::Gamestate *reference;
     TrafficControl *trafficControl_;
     unsigned int id_;
+    boost::mutex* threadMutex_;
+    ThreadPool*   threadPool_;
   };
 
Index: code/branches/netp6/src/network/Host.cc
===================================================================
--- code/branches/netp6/src/network/Host.cc	(revision 3239)
+++ code/branches/netp6/src/network/Host.cc	(revision 3240)
@@ -74,19 +74,4 @@
 }
 
-
-// bool Host::chat(std::string& message){
-//   if(!instance_)
-//     return false;
-//   packet::Chat *c = new packet::Chat(message, getPlayerID());
-//   return instance_->sendChat(c);
-// }
-
-// bool Host::receiveChat(packet::Chat *message, unsigned int clientID){
-//   if(instance_)
-//     return instance_->processChat(message, clientID);
-//   else
-//     return false;
-// }
-
 /**
  * This function returns the ID of the player
Index: code/branches/netp6/src/network/Server.cc
===================================================================
--- code/branches/netp6/src/network/Server.cc	(revision 3239)
+++ code/branches/netp6/src/network/Server.cc	(revision 3240)
@@ -48,4 +48,6 @@
 #include "core/Clock.h"
 #include "core/ObjectList.h"
+#include "core/Executor.h"
+#include "core/ThreadPool.h"
 #include "packet/Chat.h"
 #include "packet/ClassID.h"
@@ -68,12 +70,12 @@
   */
   Server::Server() {
-    timeSinceLastUpdate_=0;
-    gamestates_ = new GamestateManager();
+    this->timeSinceLastUpdate_=0;
+    this->threadPool_ = new ThreadPool();
   }
 
   Server::Server(int port){
     this->setPort( port );
-    timeSinceLastUpdate_=0;
-    gamestates_ = new GamestateManager();
+    this->timeSinceLastUpdate_=0;
+    this->threadPool_ = new ThreadPool();
   }
 
@@ -86,6 +88,6 @@
     this->setPort( port );
     this->setBindAddress( bindAddress );
-    timeSinceLastUpdate_=0;
-    gamestates_ = new GamestateManager();
+    this->timeSinceLastUpdate_=0;
+    this->threadPool_ = new ThreadPool();
   }
 
@@ -94,6 +96,5 @@
   */
   Server::~Server(){
-    if(gamestates_)
-      delete gamestates_;
+    delete this->threadPool_;
   }
 
@@ -138,6 +139,15 @@
   */
   void Server::update(const Clock& time) {
+    // receive incoming packets
     Connection::processQueue();
-    gamestates_->processGamestates();
+    // process incoming gamestates
+    GamestateManager::processGamestates();
+    
+    // pass sendFunctionCalls to worker thread pool
+    ExecutorStatic* functioncalls = createExecutor( createFunctor(&FunctionCallManager::sendCalls) );
+    this->threadPool_->passFunction( functioncalls, true );
+    
+    this->threadPool_->synchronise();
+    
     //this steers our network frequency
     timeSinceLastUpdate_+=time.getDeltaTime();
@@ -145,6 +155,8 @@
     {
       timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
+//       ExecutorMember<GamestateManager>* updategamestate = createExecutor( createFunctor(&GamestateManager::updateGamestate);
+//       updategamestate->setObject( static_cast<GamestateManager*>(this) );
+//       this->threadPool_->passFunction( updategamestate );
       updateGamestate();
-      FunctionCallManager::sendCalls();
     }
     sendPackets(); // flush the enet queue
@@ -175,8 +187,8 @@
   */
   void Server::updateGamestate() {
-//     if( ClientInformation::getBegin()==NULL )
+    if( ClientInformation::getBegin()==NULL )
       //no client connected
-//       return;
-    gamestates_->update();
+      return;
+    GamestateManager::update();
     COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
     //std::cout << "updated gamestate, sending it" << std::endl;
@@ -197,38 +209,36 @@
   */
   bool Server::sendGameState() {
-    COUT(5) << "Server: starting function sendGameState" << std::endl;
-    ClientInformation *temp = ClientInformation::getBegin();
-    bool added=false;
-    while(temp != NULL){
-      if( !(temp->getSynched()) ){
-        COUT(5) << "Server: not sending gamestate" << std::endl;
-        temp=temp->next();
-        if(!temp)
-          break;
-        //think this works without continue
-        continue;
-      }
-      COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
-      COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
-      int gid = temp->getGamestateID(); //get gamestate id
-      int cid = temp->getID(); //get client id
-      COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl;
-      packet::Gamestate *gs = gamestates_->popGameState(cid);
-      if(gs==NULL){
-        COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
-        temp = temp->next();
-        continue;
-      }
-      //std::cout << "adding gamestate" << std::endl;
-      gs->setClientID(cid);
-      if ( !gs->send() ){
-        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
-        temp->addFailure();
-      }else
-        temp->resetFailures();
-      added=true;
-      temp=temp->next();
-      // gs gets automatically deleted by enet callback
-    }
+//     COUT(5) << "Server: starting function sendGameState" << std::endl;
+//     ClientInformation *temp = ClientInformation::getBegin();
+//     bool added=false;
+//     while(temp != NULL){
+//       if( !(temp->getSynched()) ){
+//         COUT(5) << "Server: not sending gamestate" << std::endl;
+//         temp=temp->next();
+//         if(!temp)
+//           break;
+//         continue;
+//       }
+//       COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
+//       COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
+//       int cid = temp->getID(); //get client id
+//       packet::Gamestate *gs = GamestateManager::popGameState(cid);
+//       if(gs==NULL){
+//         COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
+//         temp = temp->next();
+//         continue;
+//       }
+//       //std::cout << "adding gamestate" << std::endl;
+//       gs->setClientID(cid);
+//       if ( !gs->send() ){
+//         COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
+//         temp->addFailure();
+//       }else
+//         temp->resetFailures();
+//       added=true;
+//       temp=temp->next();
+//       // gs gets automatically deleted by enet callback
+//     }
+    GamestateManager::sendGamestates();
     return true;
   }
@@ -324,5 +334,5 @@
   void Server::disconnectClient( ClientInformation *client ){
     ServerConnection::disconnectClient( client );
-    gamestates_->removeClient(client);
+    GamestateManager::removeClient(client);
 // inform all the listeners
     ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin();
Index: code/branches/netp6/src/network/Server.h
===================================================================
--- code/branches/netp6/src/network/Server.h	(revision 3239)
+++ code/branches/netp6/src/network/Server.h	(revision 3240)
@@ -34,4 +34,5 @@
 #include "core/CorePrereqs.h"
 #include "Host.h"
+#include "GamestateManager.h"
 #include "ServerConnection.h"
 
@@ -43,5 +44,5 @@
   * It implements all functions necessary for a Server
   */
-  class _NetworkExport Server : public Host, public ServerConnection{
+  class _NetworkExport Server : public Host, public ServerConnection, public GamestateManager{
   public:
     Server();
@@ -63,5 +64,5 @@
     unsigned int shipID(){return 0;}
     unsigned int playerID(){return 0;}
-
+    
     void addClient(ENetEvent *event);
     bool createClient(int clientID);
@@ -75,7 +76,5 @@
     void syncClassid(unsigned int clientID);
 
-    GamestateManager *gamestates_;
-
-
+    ThreadPool* threadPool_;
     float timeSinceLastUpdate_;
   };
Index: code/branches/netp6/src/network/synchronisable/NetworkCallbackManager.cc
===================================================================
--- code/branches/netp6/src/network/synchronisable/NetworkCallbackManager.cc	(revision 3239)
+++ code/branches/netp6/src/network/synchronisable/NetworkCallbackManager.cc	(revision 3240)
@@ -44,6 +44,6 @@
     if (it != callbackSet_.end())
     {
-      delete (*it);
       callbackSet_.erase(it);
+      delete cb;
     }
   }
Index: code/branches/netp6/src/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/netp6/src/network/synchronisable/Synchronisable.cc	(revision 3239)
+++ code/branches/netp6/src/network/synchronisable/Synchronisable.cc	(revision 3240)
@@ -247,6 +247,8 @@
       return 0;
     uint32_t tempsize = 0;
+#ifndef NDEBUG
     if (this->classID==0)
       COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
+#endif
 
     if (this->classID == static_cast<uint32_t>(-1))
Index: code/branches/netp6/src/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/branches/netp6/src/network/synchronisable/SynchronisableVariable.h	(revision 3239)
+++ code/branches/netp6/src/network/synchronisable/SynchronisableVariable.h	(revision 3240)
@@ -114,5 +114,8 @@
   {
     if (this->callback_ != 0)
+    {
       NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
+      // this is neccessary because for example for a Vector3 all 3 components of the vector use the same callback
+    }
   }
 
Index: code/branches/netp6/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- code/branches/netp6/src/orxonox/gamestates/GSDedicated.cc	(revision 3239)
+++ code/branches/netp6/src/orxonox/gamestates/GSDedicated.cc	(revision 3240)
@@ -103,4 +103,5 @@
 #endif
         //inputThread_->join();
+        delete this->inputThread_;
 
         GameMode::setHasServer(false);
