Index: branches/network/src/lib/network/message_manager.cc
===================================================================
--- branches/network/src/lib/network/message_manager.cc	(revision 8174)
+++ branches/network/src/lib/network/message_manager.cc	(revision 8184)
@@ -17,4 +17,6 @@
 
 #include "message_manager.h"
+
+#include "network_stream.h"
 
 using namespace std;
@@ -312,5 +314,6 @@
          recieverType == RT_ALL_NOT_ME ||
          recieverType == RT_USER && it->first == reciever ||
-         recieverType == RT_NOT_USER && it->first != reciever
+         recieverType == RT_NOT_USER && it->first != reciever ||
+         recieverType == RT_SERVER && getNetworkStream()->isUserServer( it->first )
        )
     {
Index: branches/network/src/lib/network/message_manager.h
===================================================================
--- branches/network/src/lib/network/message_manager.h	(revision 8174)
+++ branches/network/src/lib/network/message_manager.h	(revision 8184)
@@ -30,5 +30,6 @@
   TESTMESSAGEID = 1,
   MSGID_DELETESYNCHRONIZEABLE,
-  MSGID_PREFEREDTEAM
+  MSGID_PREFEREDTEAM,
+  MSGID_CHANGEPLAYERNAME
 };
 
@@ -40,5 +41,6 @@
   RT_ALL_ME,           //!< message is sent to all users
   RT_USER,             //!< message is only sent to reciever
-  RT_NOT_USER          //!< message is sent to all but reciever
+  RT_NOT_USER,         //!< message is sent to all but reciever
+  RT_SERVER            //!< message is sent to server only
 };
 
Index: branches/network/src/lib/network/network_manager.cc
===================================================================
--- branches/network/src/lib/network/network_manager.cc	(revision 8174)
+++ branches/network/src/lib/network/network_manager.cc	(revision 8184)
@@ -51,7 +51,5 @@
 
   /* initialize the references */
-  this->netStreamList = NULL;
-  this->syncList = NULL;
-  this->defaultSyncStream = NULL;
+  this->networkStream = NULL;
   this->sharedNetworkData = SharedNetworkData::getInstance();
   this->elapsedTime = 0.0f;
@@ -71,5 +69,11 @@
  */
 NetworkManager::~NetworkManager()
-{}
+{
+  if ( this->networkStream )
+  {
+    delete this->networkStream;
+    this->networkStream = NULL;
+  }
+}
 
 
@@ -79,8 +83,5 @@
 void NetworkManager::initialize()
 {
-  /* get the synchronizeable list from the class list */
-  this->netStreamList = ClassList::getList(CL_SYNCHRONIZEABLE);
   PRINTF(0)("NetworkManager initzalized\n");
-
 }
 
@@ -101,7 +102,7 @@
 int NetworkManager::establishConnection(const std::string & name, unsigned int port)
 {
-  this->defaultSyncStream = new NetworkStream( name, port );
-  this->sharedNetworkData->setDefaultSyncStream(this->defaultSyncStream);
-  this->defaultSyncStream->startHandshake();
+  this->networkStream = new NetworkStream( name, port );
+  this->sharedNetworkData->setDefaultSyncStream(this->networkStream);
+  this->networkStream->startHandshake();
   return 1;
 }
@@ -116,7 +117,7 @@
   this->sharedNetworkData->setHostID(0);
   this->sharedNetworkData->setGameServer(true);
-  this->defaultSyncStream = new NetworkStream(port);
-  this->sharedNetworkData->setDefaultSyncStream(this->defaultSyncStream);
-  this->defaultSyncStream->createNetworkGameManager();
+  this->networkStream = new NetworkStream(port);
+  this->sharedNetworkData->setDefaultSyncStream(this->networkStream);
+  this->networkStream->createNetworkGameManager();
   PRINTF(0)("CREATE SERVER\n");
   SDL_Delay(20);
@@ -127,6 +128,6 @@
 void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
 {
-  if( this->defaultSyncStream)
-    this->defaultSyncStream->connectSynchronizeable(sync);
+  if( this->networkStream)
+    this->networkStream->connectSynchronizeable(sync);
 }
 
@@ -143,11 +144,6 @@
   this->elapsedTime = 0.0f;
 
-  if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL)
-  {
-    std::list<BaseObject*>::const_iterator stream;
-    for (stream = this->netStreamList->begin(); stream != this->netStreamList->end(); ++stream)
-      if( static_cast<NetworkStream*>(*stream)->isActive())
-        static_cast<NetworkStream*>(*stream)->processData();
-  }
+  if ( networkStream->isActive() )
+    networkStream->processData();
   
   NetworkGameManager::getInstance()->tick( this->elapsedTime );
@@ -162,5 +158,5 @@
 {
   PRINT(0)("=================Network::debug()=========\n");
-  this->defaultSyncStream->debug();
+  this->networkStream->debug();
   PRINT(0)("===========================================\n");
 }
Index: branches/network/src/lib/network/network_manager.h
===================================================================
--- branches/network/src/lib/network/network_manager.h	(revision 8174)
+++ branches/network/src/lib/network/network_manager.h	(revision 8184)
@@ -55,8 +55,6 @@
 
   private:
-    const std::list<BaseObject*>*    netStreamList;           // list with refs to all network streams
-    const std::list<BaseObject*>*    syncList;                // list of synchronizeables
     static NetworkManager*           singletonRef;            //!< Pointer to the only instance of this Class
-    NetworkStream*                   defaultSyncStream;       //!< FIXME: this is only for testing purposes
+    NetworkStream*                   networkStream;       //!< pointer to network stream
 
     SharedNetworkData*               sharedNetworkData;       //!< reference to the shared data
Index: branches/network/src/lib/network/player_stats.cc
===================================================================
--- branches/network/src/lib/network/player_stats.cc	(revision 8174)
+++ branches/network/src/lib/network/player_stats.cc	(revision 8184)
@@ -62,4 +62,7 @@
   playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId" ) );
   modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
+  playerName_handle = registerVarId( new SynchronizeableString( &playerName, &playerName, "playerName" ) );
+  
+  MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGEPLAYERNAME, changePlayernameHandler, NULL );
   
   PRINTF(0)("PlayerStats created\n");
@@ -164,3 +167,41 @@
 }
 
-
+bool PlayerStats::changePlayernameHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
+{
+  if ( !SharedNetworkData::getInstance()->isGameServer() )
+    return true;
+  
+  if ( Converter::byteArrayToString( data, getStats(userId)->playerName, dataLength ) != dataLength );
+  {
+    PRINTF(1)("recieved invalid message from user %d\n", userId);
+    // TODO give user a name
+    getStats( userId )->playerName = "invalid name";
+  }
+  
+  return true;
+}
+
+std::string PlayerStats::setPlayerName( std::string name )
+{
+  if ( isServer() )
+  {
+    this->playerName = name;
+  }
+  else
+  {
+    if ( userId == getHostID() )
+    {
+      byte * data = new byte[INTSIZE+playerName.length()];
+      
+      assert( Converter::stringToByteArray( playerName, data, INTSIZE+playerName.length() ) == INTSIZE+playerName.length() );
+      
+      MessageManager::getInstance()->sendMessage( MSGID_CHANGEPLAYERNAME, data, INTSIZE+playerName.length(), RT_SERVER, 0, MP_HIGHBANDWIDTH );
+    }
+    else
+    {
+      PRINTF(1)("Clients cannot set PlayerNames of other hosts!\n");
+    }
+  }
+}
+
+
Index: branches/network/src/lib/network/player_stats.h
===================================================================
--- branches/network/src/lib/network/player_stats.h	(revision 8174)
+++ branches/network/src/lib/network/player_stats.h	(revision 8184)
@@ -9,4 +9,5 @@
 #include "synchronizeable.h"
 #include "playable.h"
+#include "message_manager.h"
 
 #include <string>
@@ -35,4 +36,7 @@
     inline int getUserId(){ return userId; }
     
+    inline std::string getPlayerName(){ return playerName; }
+    inline std::string setPlayerName( std::string name );
+    
     inline int getTeamId(){ return teamId; }
     inline void setTeamId( int teamId ){ this->teamId = teamId; }
@@ -54,7 +58,12 @@
     
     Playable * getPlayable();
+    
+    static bool changePlayernameHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
 
   private:
     int userId;                //!< userId
+
+    std::string playerName;    //!< playername
+
     int teamId;                //!< teamId
     int preferedTeamId;        //!< preferedTeamId
@@ -69,4 +78,5 @@
     // handles for SynchronizeableVars
     int userId_handle;
+    int playerName_handle;
     int teamId_handle;
     int preferedTeamId_handle;
Index: branches/network/src/lib/network/udp_server_socket.cc
===================================================================
--- branches/network/src/lib/network/udp_server_socket.cc	(revision 8174)
+++ branches/network/src/lib/network/udp_server_socket.cc	(revision 8184)
@@ -44,5 +44,5 @@
 UdpServerSocket::~UdpServerSocket( )
 {
-  for ( int i = 0; i < packetBuffer.size(); i++ )
+  for ( int i = 0; i < (int)packetBuffer.size(); i++ )
     removeUserPackets( i );
   
@@ -99,5 +99,5 @@
 {
   
-  for ( int i = 0; i < packetBuffer.size(); i++ )
+  for ( int i = 0; i < (int)packetBuffer.size(); i++ )
     removeUserPackets( i );
   
@@ -115,5 +115,5 @@
 void UdpServerSocket::removeUserPackets( int userId )
 {
-  if ( userId >= packetBuffer.size() )
+  if ( userId >= (int)packetBuffer.size() )
     return;
   
@@ -141,9 +141,12 @@
   res.length = 0;
   
-  if ( packetBuffer.size() > userId && packetBuffer[userId].size() > 0 )
+  if ( (int)packetBuffer.size() > userId && (int)packetBuffer[userId].size() > 0 )
   {
     res.data = packetBuffer[userId].front().data;
     res.length = packetBuffer[userId].front().length;
     packetBuffer[userId].pop_front();
+    
+    if ( res.length == 0 )
+      res.length = -1;
   }
   
@@ -158,5 +161,5 @@
 int UdpServerSocket::getPacketCount( int userId )
 {
-  if ( userId >= packetBuffer.size() )
+  if ( userId >= (int)packetBuffer.size() )
     return -1;
   
@@ -179,11 +182,11 @@
   }
   
-  if ( userId < packetBuffer.size() )
+  if ( userId < (int)packetBuffer.size() )
     removeUserPackets( userId );
   
-  if ( packetBuffer.size() <= userId )
+  if ( (int)packetBuffer.size() <= userId )
     packetBuffer.resize( userId + 1 );
   
-  if ( userList.size() <= userId )
+  if ( (int)userList.size() <= userId )
     userList.resize( userId + 1 );
   
@@ -199,5 +202,5 @@
   removeUserPackets( userId );
   
-  if ( userId >= userList.size() )
+  if ( userId >= (int)userList.size() )
     return;
   
@@ -244,9 +247,9 @@
     bool isNewConnection = false;
     
-    for ( userId =0; userId < userList.size(); userId++ )
+    for ( userId =0; userId < (int)userList.size(); userId++ )
       if ( userList[userId].host == packet->address.host && userList[userId].port == packet->address.port )
         break;
     
-    if ( userId >= userList.size() )
+    if ( userId >= (int)userList.size() )
     {
       
@@ -260,5 +263,5 @@
       }
       
-      for ( userId =0; userId < userList.size(); userId++ )
+      for ( userId =0; userId < (int)userList.size(); userId++ )
         if ( userList[userId].host == 0 && userList[userId].port == 0 )
           break;
@@ -281,7 +284,4 @@
     else
     {
-      if ( isNewConnection )
-        continue;
-      
       networkPacket.data = NULL;
     }
Index: branches/network/src/lib/network/udp_socket.cc
===================================================================
--- branches/network/src/lib/network/udp_socket.cc	(revision 8174)
+++ branches/network/src/lib/network/udp_socket.cc	(revision 8184)
@@ -81,9 +81,9 @@
 UdpSocket::~UdpSocket( )
 {
+  this->disconnectServer();
+  
   if ( serverSocket )
     serverSocket->removeUser( userId );
-  
-  disconnectServer();
-  
+
   if ( this->packet )
     SDLNet_FreePacket( this->packet );
@@ -128,13 +128,13 @@
     return;
   }
-  
+}
+
+/**
+ * disconnect from server
+ */
+void UdpSocket::disconnectServer( )
+{
+  PRINTF(0)("disconnect from server\n");
   writePacket( NULL, 0 );
-}
-
-/**
- * disconnect from server
- */
-void UdpSocket::disconnectServer( )
-{
   SDLNet_UDP_Unbind( socket, -1 );
   SDLNet_UDP_Close( socket );
@@ -196,4 +196,10 @@
     NetworkPacket networkPacket = serverSocket->getPacket( this->userId );
     
+    if ( networkPacket.length == -1 )
+    {
+      this->disconnectServer();
+      return 0;
+    }
+    
     if ( networkPacket.length > 0 )
     {
@@ -218,4 +224,10 @@
       assert( packet->len <= maxLength );
       
+      if ( packet->len == 0 )
+      {
+        this->disconnectServer();
+        return 0;
+      }
+      
       memcpy( data, packet->data, packet->len );
       return packet->len;
Index: branches/network/src/story_entities/multi_player_world.cc
===================================================================
--- branches/network/src/story_entities/multi_player_world.cc	(revision 8174)
+++ branches/network/src/story_entities/multi_player_world.cc	(revision 8184)
@@ -26,4 +26,5 @@
 
 #include "network_manager.h"
+#include "network_game_manager.h"
 
 
@@ -119,2 +120,14 @@
   ((MultiPlayerWorldData*)this->dataTank)->debug();
 }
+
+/**
+ * cleanup
+ * @return 
+ */
+ErrorMessage MultiPlayerWorld::unloadData( )
+{
+  GameWorld::unloadData();
+  
+  delete NetworkManager::getInstance();
+  delete NetworkGameManager::getInstance();
+}
Index: branches/network/src/story_entities/multi_player_world.h
===================================================================
--- branches/network/src/story_entities/multi_player_world.h	(revision 8174)
+++ branches/network/src/story_entities/multi_player_world.h	(revision 8184)
@@ -26,4 +26,6 @@
 
   virtual void loadParams(const TiXmlElement* root);
+  
+  virtual ErrorMessage unloadData();
 
   void debug();
Index: branches/network/src/util/signal_handler.cc
===================================================================
--- branches/network/src/util/signal_handler.cc	(revision 8174)
+++ branches/network/src/util/signal_handler.cc	(revision 8184)
@@ -17,7 +17,7 @@
 #include <assert.h>
 
+SignalHandler * SignalHandler::singletonRef = NULL;
+
 #ifndef __WIN32__
-
-SignalHandler * SignalHandler::singletonRef = NULL;
 
 SignalHandler::SignalHandler()
@@ -59,4 +59,9 @@
 void SignalHandler::sigHandler( int sig )
 {
+  for ( SignalCallbackList::iterator it = SignalHandler::getInstance()->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++  )
+  {
+    (*(it->cb))( it->someData );
+  }
+  
   std::string sigName = "UNKNOWN";
 
@@ -113,3 +118,12 @@
 }
 
+void SignalHandler::registerCallback( SignalCallback cb, void * someData )
+{
+  SignalCallbackRec rec;
+  rec.cb = cb;
+  rec.someData = someData;
+  
+  callbackList.push_back(rec);
+}
+
 #endif /* __WIN32__ */
Index: branches/network/src/util/signal_handler.h
===================================================================
--- branches/network/src/util/signal_handler.h	(revision 8174)
+++ branches/network/src/util/signal_handler.h	(revision 8184)
@@ -17,4 +17,5 @@
 };
 
+typedef bool (*SignalCallback)( void * someData );
 
 #ifndef __WIN32__
@@ -27,6 +28,13 @@
 };
 
+struct SignalCallbackRec
+{
+  SignalCallback cb;
+  void * someData;
+};
+
 
 typedef std::list<SignalRec> SignalRecList;
+typedef std::list<SignalCallbackRec> SignalCallbackList;
 
 class SignalHandler
@@ -35,6 +43,7 @@
     SignalHandler();
   public:
-    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler();
-      return SignalHandler::singletonRef; }
+    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
+      
+    void registerCallback( SignalCallback cb, void * someData );
 
     void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE );
@@ -46,4 +55,6 @@
     void catchSignal( int sig );
     SignalRecList sigRecList;
+    
+    SignalCallbackList callbackList;
 
     static SignalHandler * singletonRef;
@@ -58,7 +69,8 @@
 {
  public:
-  inline static SignalHandler* getInstance() {};
+   inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
   void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ) {};
   void dontCatch() {};
+  void registerCallback( SignalCallback cb, void * someData ) {};
 };
 #endif
