Index: code/branches/formation/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/HumanController.cc	(revision 8947)
+++ code/branches/formation/src/orxonox/controllers/HumanController.cc	(revision 8948)
@@ -77,16 +77,18 @@
         this->boosting_ = false;
         this->boosting_ = false;
-
+        this->tempMaster=NULL;
         HumanController::localController_s = this;
         this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));
         this->boostingTimeout_.stopTimer();
-        this->state_=MASTER;
+        this->state_=FREE;
     }
 
     HumanController::~HumanController()
     {
+        if (HumanController::localController_s) 
+        {
+            HumanController::localController_s->removeFromFormation();
+        }
         HumanController::localController_s = 0;
-        if (this->state_==MASTER)
-            removeFromFormation();
     }
 
@@ -101,7 +103,7 @@
 
         // commandslaves when Master of a formation
-        if (this->state_==MASTER)
-        {
-            this->commandSlaves();
+        if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
+        {
+            HumanController::localController_s->commandSlaves();
         }
     }
@@ -274,4 +276,5 @@
     void HumanController::toggleFormationFlight()
     {
+        
         if (HumanController::localController_s)
         {
@@ -280,8 +283,11 @@
                 HumanController::localController_s->freeSlaves();
                 HumanController::localController_s->state_=FREE;
+                orxout(message) <<"FormationFlight disabled "<< endl;
             } else //SLAVE or FREE
             {
                 HumanController::localController_s->takeLeadOfFormation();
+                orxout(message) <<"FormationFlight enabled "<< endl;
             }
+            
         }
 
Index: code/branches/formation/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/formation/src/orxonox/controllers/HumanController.h	(revision 8947)
+++ code/branches/formation/src/orxonox/controllers/HumanController.h	(revision 8948)
@@ -109,4 +109,5 @@
             Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.
             static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.
+            Masterable* tempMaster;
 
     }; // tolua_export
Index: code/branches/formation/src/orxonox/controllers/Masterable.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/Masterable.cc	(revision 8947)
+++ code/branches/formation/src/orxonox/controllers/Masterable.cc	(revision 8948)
@@ -59,5 +59,5 @@
   static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7;
   static const int RADIUS_TO_SEARCH_FOR_MASTERS = 20000;
-  static const int FORMATION_LENGTH =  130;
+  static const int FORMATION_LENGTH =  110;
   static const int FORMATION_WIDTH =  110;
   static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
@@ -86,5 +86,5 @@
         this->speedCounter_ = 0.2f;
         this->targetPosition_ = Vector3::ZERO;
-
+        //this->team_=-1;
         this->target_.setCallback(createFunctor(&Masterable::targetDied, this));
   }
@@ -319,5 +319,5 @@
                 if (distance < 40)
                 {
-                    this->getControllableEntity()->moveFrontBack(0.8f*SPEED_MASTER);
+                    this->getControllableEntity()->moveFrontBack(0.2f*SPEED_MASTER);
 		   
                 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
@@ -444,4 +444,5 @@
             this->state_ = MASTER;
             this->myMaster_ = 0;
+            orxout(debug_output) << "search new master: no master found, but teammates"<< endl;
         }
     }
@@ -588,5 +589,6 @@
         if (this->state_==FREE)
         {
-            float minDistance=RADIUS_TO_SEARCH_FOR_MASTERS;
+          /*
+            float minDistance=(float)RADIUS_TO_SEARCH_FOR_MASTERS;
             Masterable* bestMaster=NULL;
 
@@ -639,10 +641,13 @@
               this->slaves_.clear();
               this->myMaster_=0;
+              orxout(debug_output) << this << "no formation found!, empty formation"<< endl;
               return;
             }
-        }
-
-        if (this->state_==SLAVE)
-        {
+         */
+          searchNewMaster();
+        }
+
+        if (this->state_==SLAVE)  //become master of this formation
+        {   
             this->slaves_=myMaster_->slaves_;
             this->myMaster_->slaves_.clear();
