Index: /code/branches/netp4/src/network/Client.cc
===================================================================
--- /code/branches/netp4/src/network/Client.cc	(revision 3136)
+++ /code/branches/netp4/src/network/Client.cc	(revision 3137)
@@ -169,4 +169,5 @@
       bool b = packet->process();
       assert(b);
+      delete event;
     }
     if(gamestate.processGamestates())
Index: /code/branches/netp4/src/network/ClientConnection.cc
===================================================================
--- /code/branches/netp4/src/network/ClientConnection.cc	(revision 3136)
+++ /code/branches/netp4/src/network/ClientConnection.cc	(revision 3137)
@@ -169,6 +169,6 @@
 // 	        assert(0);
           printf("ClientConnection: ENet returned with an error!\n");
-          quit_=true;
-          break;
+//           quit_=true;
+          continue;
           // add some error handling here ========================
         }
@@ -197,10 +197,16 @@
       }
     }
+    delete event;
     // now disconnect
 
     if(!disconnectConnection())
+    {
+      printf("could not disconnect properly\n");
       // if disconnecting failed destroy conn.
       boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
       enet_peer_reset(server);
+    }
+    else
+      printf("properly disconnected\n");
     return;
   }
@@ -221,4 +227,5 @@
         break;
       case ENET_EVENT_TYPE_DISCONNECT:
+        printf("received disconnect confirmation from server");
         return true;
       }
Index: /code/branches/netp4/src/network/ClientInformation.h
===================================================================
--- /code/branches/netp4/src/network/ClientInformation.h	(revision 3136)
+++ /code/branches/netp4/src/network/ClientInformation.h	(revision 3137)
@@ -91,5 +91,4 @@
     bool getSynched();
 
-
   private:
     static ClientInformation *head_;
Index: /code/branches/netp4/src/network/ConnectionManager.cc
===================================================================
--- /code/branches/netp4/src/network/ConnectionManager.cc	(revision 3136)
+++ /code/branches/netp4/src/network/ConnectionManager.cc	(revision 3137)
@@ -132,4 +132,5 @@
     quit_=true;
     receiverThread_->join();
+    delete receiverThread_;
     return true;
   }
@@ -206,6 +207,6 @@
           // we should never reach this point
           printf("ConnectionManager: ENet returned with an error\n");
-          quit_=true;
-          printf("waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhh\n");
+//           quit_=true;
+//           printf("waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhh\n");
           continue;
           // add some error handling here ========================
@@ -218,11 +219,12 @@
 //             printf("====================================================================");
         case ENET_EVENT_TYPE_DISCONNECT:
+//           printf("====================================================================");
         case ENET_EVENT_TYPE_RECEIVE:
-            processData(event);
-            event = new ENetEvent;
+          processData(event);
+          event = new ENetEvent;
           break;
         case ENET_EVENT_TYPE_NONE:
           //receiverThread_->yield();
-          msleep(10);
+          msleep(1);
           break;
       }
Index: /code/branches/netp4/src/network/ConnectionManager.h
===================================================================
--- /code/branches/netp4/src/network/ConnectionManager.h	(revision 3136)
+++ /code/branches/netp4/src/network/ConnectionManager.h	(revision 3137)
@@ -55,5 +55,5 @@
     const int NETWORK_PORT = 55556;
     const int NETWORK_MAX_CONNECTIONS = 50;
-    const int NETWORK_WAIT_TIMEOUT = 10;
+    const int NETWORK_WAIT_TIMEOUT = 1;
     const int NETWORK_DEFAULT_CHANNEL = 0;
 
Index: /code/branches/netp4/src/network/GamestateManager.cc
===================================================================
--- /code/branches/netp4/src/network/GamestateManager.cc	(revision 3136)
+++ /code/branches/netp4/src/network/GamestateManager.cc	(revision 3137)
@@ -63,4 +63,8 @@
   GamestateManager::~GamestateManager()
   {
+    if( this->reference )
+      delete this->reference;
+    for( std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.begin(); it != gamestateQueue.end(); it++ )
+      delete (*it).second;
     delete trafficControl_;
   }
Index: /code/branches/netp4/src/network/Server.cc
===================================================================
--- /code/branches/netp4/src/network/Server.cc	(revision 3136)
+++ /code/branches/netp4/src/network/Server.cc	(revision 3137)
@@ -129,4 +129,13 @@
   */
   void Server::close() {
+    ClientInformation *temp = ClientInformation::getBegin();
+    ClientInformation *temp2;
+    // disconnect all connected clients
+    while( temp )
+    {
+      temp2 = temp;
+      temp = temp->next();
+      disconnectClient( temp2 );
+    }
     connection->quitListener();
     return;
@@ -199,5 +208,5 @@
       switch( event->type ) {
       case ENET_EVENT_TYPE_CONNECT:
-        COUT(3) << "processing event_Type_connect" << std::endl;
+        COUT(4) << "processing event_Type_connect" << std::endl;
         addClient(event);
         break;
@@ -305,4 +314,5 @@
       // gs gets automatically deleted by enet callback
     }
+    delete del;
     return true;
   }
@@ -382,24 +392,25 @@
     if(!client)
       return false;
+    else
+      disconnectClient( client );
+    return true;
+  }
+
+  void Server::disconnectClient(int clientID){
+    ClientInformation *client = ClientInformation::findClient(clientID);
+    if(client)
+      disconnectClient(client);
+  }
+  
+  void Server::disconnectClient( ClientInformation *client){
+    connection->disconnectClient(client);
     gamestates_->removeClient(client);
-
 // inform all the listeners
     ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin();
     while(listener){
       listener->clientDisconnected(client->getID());
-      listener++;
-    }
-
-    return ClientInformation::removeClient(event->peer);
-  }
-
-  void Server::disconnectClient(int clientID){
-    ClientInformation *client = ClientInformation::findClient(clientID);
-    if(client)
-      disconnectClient(client);
-  }
-  void Server::disconnectClient( ClientInformation *client){
-    connection->disconnectClient(client);
-    gamestates_->removeClient(client);
+      ++listener;
+    }
+    delete client; //remove client from list
   }
 
Index: /code/branches/netp4/src/network/TrafficControl.cc
===================================================================
--- /code/branches/netp4/src/network/TrafficControl.cc	(revision 3136)
+++ /code/branches/netp4/src/network/TrafficControl.cc	(revision 3137)
@@ -137,4 +137,6 @@
 	void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
 	{
+    if ( !this->bActive_ )
+      return;
 	  std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
 
@@ -227,32 +229,32 @@
 	{
 
-	  //now the sorting
-
-	  //compare listToProcess vs clientListPerm
-    //if listToProcess contains new Objects, add them to clientListPerm
-    std::list<obj>::iterator itvec;
+    if( bActive_ )
+    {
+      //now the sorting
+
+      //compare listToProcess vs clientListPerm
+      //if listToProcess contains new Objects, add them to clientListPerm
+      std::list<obj>::iterator itvec;
     
-    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
+      std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
     
-	  for( itvec=list.begin(); itvec != list.end(); itvec++)
-	  {
-	    if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
-      {
+      for( itvec=list.begin(); itvec != list.end(); itvec++)
+      {
+        if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
+        {
         // we already have the object in our map
         //obj bleibt in liste und permanente prio wird berechnet
-        objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
-        continue;//check next objId
-      }
-      else
-      {
+          objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
+          continue;//check next objId
+        }
+        else
+        {
         // insert the object into clientListPerm
-        insertinClientListPerm(clientID,*itvec);
-        continue;//check next objId
-      }
-    }
-	  //end compare listToProcess vs clientListPerm
-
-    if( bActive_ )
-    {
+          insertinClientListPerm(clientID,*itvec);
+          continue;//check next objId
+        }
+      }
+    //end compare listToProcess vs clientListPerm
+      
       //sort copied list according to priorities
       // use boost bind here because we need to pass a memberfunction to stl sort
@@ -275,8 +277,9 @@
 //       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
       list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
+      
+      //diese Funktion updateClientList muss noch gemacht werden
+      updateClientListTemp(list);
+      //end of sorting
     }
-    //diese Funktion updateClientList muss noch gemacht werden
-    updateClientListTemp(list);
-    //end of sorting
   }
 
Index: /code/branches/netp4/src/network/packet/Gamestate.cc
===================================================================
--- /code/branches/netp4/src/network/packet/Gamestate.cc	(revision 3136)
+++ /code/branches/netp4/src/network/packet/Gamestate.cc	(revision 3137)
@@ -80,4 +80,6 @@
 Gamestate::~Gamestate()
 {
+  if( header_ )
+    delete header_;
 }
 
@@ -99,4 +101,5 @@
   
   // create the header object
+  assert( header_ == 0 );
   header_ = new GamestateHeader(data_);
 
Index: /code/branches/netp4/src/network/synchronisable/Synchronisable.cc
===================================================================
--- /code/branches/netp4/src/network/synchronisable/Synchronisable.cc	(revision 3136)
+++ /code/branches/netp4/src/network/synchronisable/Synchronisable.cc	(revision 3137)
@@ -98,8 +98,12 @@
     // delete callback function objects
     if(!Identifier::isCreatingHierarchy()){
+      // remove object from the static objectMap
+      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
+        deletedObjects_.push(objectID);
+      // delete all Synchronisable Variables from syncList ( which are also in stringList )
       for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
         delete (*it);
-      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
-        deletedObjects_.push(objectID);
+      syncList.clear();
+      stringList.clear();
     }
     std::map<uint32_t, Synchronisable*>::iterator it;
Index: /code/branches/netp4/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- /code/branches/netp4/src/orxonox/gamestates/GSDedicated.cc	(revision 3136)
+++ /code/branches/netp4/src/orxonox/gamestates/GSDedicated.cc	(revision 3137)
@@ -163,4 +163,5 @@
                                 break;
                             default: //not supported...
+//                                 std::cout << endl << c << endl;
                                 break;
                         }
@@ -251,4 +252,5 @@
     void GSDedicated::setTerminalMode()
     {
+#ifndef ORXONOX_PLATFORM_WINDOWS
         termios new_settings;
      
@@ -262,4 +264,5 @@
         COUT(0) << endl;
 //       atexit(&GSDedicated::resetTerminalMode);
+#endif
     }
     
