Index: /code/trunk/src/core/input/ExtendedInputState.cc
===================================================================
--- /code/trunk/src/core/input/ExtendedInputState.cc	(revision 1880)
+++ /code/trunk/src/core/input/ExtendedInputState.cc	(revision 1881)
@@ -362,19 +362,4 @@
 
         return success;
-    }
-
-    void ExtendedInputState::removeAndDestroyAllHandlers()
-    {
-        for (std::vector<InputHandler*>::iterator it = allHandlers_.begin();
-            it != allHandlers_.end(); ++it)
-            delete *it;
-
-        allHandlers_.clear();
-        keyHandlers_.clear();
-        mouseHandlers_.clear();
-        joyStickHandlersAll_.clear();
-        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); ++iJoyStick)
-            joyStickHandlers_[iJoyStick].clear();
-        update();
     }
 
Index: /code/trunk/src/core/input/ExtendedInputState.h
===================================================================
--- /code/trunk/src/core/input/ExtendedInputState.h	(revision 1880)
+++ /code/trunk/src/core/input/ExtendedInputState.h	(revision 1881)
@@ -64,6 +64,4 @@
         bool removeHandler(InputHandler* handler);
 
-        void removeAndDestroyAllHandlers();
-
     private:
         ExtendedInputState() { }
Index: /code/trunk/src/core/input/InputManager.cc
===================================================================
--- /code/trunk/src/core/input/InputManager.cc	(revision 1880)
+++ /code/trunk/src/core/input/InputManager.cc	(revision 1881)
@@ -107,8 +107,8 @@
         , windowHnd_(0)
         , internalState_(Uninitialised)
-        , stateDetector_(0)
-        , stateCalibrator_(0)
         , stateEmpty_(0)
         , stateMaster_(0)
+        , keyDetector_(0)
+        , calibratorCallbackBuffer_(0)
         , bCalibrating_(false)
         , keyboardModifiers_(0)
@@ -189,21 +189,25 @@
             CCOUT(4) << "Initialising InputStates components..." << std::endl;
 
+            // Lowest priority empty InputState
             stateEmpty_ = createInputState<SimpleInputState>("empty", -1);
             stateEmpty_->setHandler(&EMPTY_HANDLER);
             activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
 
-            stateDetector_ = createInputState<SimpleInputState>("detector", 101);
-            KeyDetector* temp = new KeyDetector();
-            temp->loadBindings("storeKeyStroke");
-            stateDetector_->setHandler(temp);
-
-            stateCalibrator_ = createInputState<SimpleInputState>("calibrator", 100);
-            stateCalibrator_->setHandler(&EMPTY_HANDLER);
-            InputBuffer* buffer = new InputBuffer();
-            buffer->registerListener(this, &InputManager::_completeCalibration, '\r', true);
-            stateCalibrator_->setKeyHandler(buffer);
-
+            // Always active master InputState
             stateMaster_ = new ExtendedInputState();
             stateMaster_->setName("master");
+
+            // KeyDetector to evaluate a pressed key's name
+            SimpleInputState* detector = createInputState<SimpleInputState>("detector", 101);
+            keyDetector_ = new KeyDetector();
+            keyDetector_->loadBindings("storeKeyStroke");
+            detector->setHandler(keyDetector_);
+
+            // Joy stick calibration helper callback
+            SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", 100);
+            calibrator->setHandler(&EMPTY_HANDLER);
+            calibratorCallbackBuffer_ = new InputBuffer();
+            calibratorCallbackBuffer_->registerListener(this, &InputManager::_completeCalibration, '\r', true);
+            calibrator->setKeyHandler(calibratorCallbackBuffer_);
 
             internalState_ |= InternalsReady;
@@ -430,10 +434,4 @@
                 CCOUT(3) << "Destroying ..." << std::endl;
 
-                // clear our own states
-                //stateEmpty_->removeAndDestroyAllHandlers();
-                //stateCalibrator_->removeAndDestroyAllHandlers();
-                //stateDetector_->removeAndDestroyAllHandlers();
-                // TODO: Memory Leak when not deleting the handlers!!!
-
                 // kick all active states 'nicely'
                 for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
@@ -443,11 +441,19 @@
                 }
 
-                // destroy all input states
-                while (inputStatesByPriority_.size() > 0)
-                    _destroyState((*inputStatesByPriority_.rbegin()).second);
-
+                // Destroy calibrator helper handler and state
+                delete keyDetector_;
+                requestDestroyState("calibrator");
+                // Destroy KeyDetector and state
+                delete calibratorCallbackBuffer_;
+                requestDestroyState("detector");
+                // destroy the empty InputState
+                _destroyState(this->stateEmpty_);
                 // destroy the master input state. This might trigger a memory leak
                 // because the user has forgotten to destroy the KeyBinder or any Handler!
                 delete stateMaster_;
+
+                // destroy all user InputStates
+                while (inputStatesByPriority_.size() > 0)
+                    _destroyState((*inputStatesByPriority_.rbegin()).second);
 
                 // destroy the devices
@@ -1231,7 +1237,7 @@
     bool InputManager::requestDestroyState(const std::string& name)
     {
-        if (name == "empty" || name == "calibrator" || name == "detector")
-        {
-            COUT(2) << "InputManager: Removing the '" << name << "' state is not allowed!" << std::endl;
+        if (name == "empty")
+        {
+            COUT(2) << "InputManager: Removing the empty state is not allowed!" << std::endl;
             return false;
         }
Index: /code/trunk/src/core/input/InputManager.h
===================================================================
--- /code/trunk/src/core/input/InputManager.h	(revision 1880)
+++ /code/trunk/src/core/input/InputManager.h	(revision 1881)
@@ -193,8 +193,8 @@
 
         // some internally handled states and handlers
-        SimpleInputState*                   stateDetector_;        //!< KeyDetector instance
-        SimpleInputState*                   stateCalibrator_;
         SimpleInputState*                   stateEmpty_;
         ExtendedInputState*                 stateMaster_;          //!< Always active master input state
+        KeyDetector*                        keyDetector_;        //!< KeyDetector instance
+        InputBuffer*                        calibratorCallbackBuffer_;
 
         std::map<std::string, InputState*>  inputStatesByName_;
Index: /code/trunk/src/core/input/SimpleInputState.cc
===================================================================
--- /code/trunk/src/core/input/SimpleInputState.cc	(revision 1880)
+++ /code/trunk/src/core/input/SimpleInputState.cc	(revision 1881)
@@ -184,20 +184,4 @@
     }
 
-    //void SimpleInputState::removeAndDestroyAllHandlers()
-    //{
-    //    for (std::vector<InputHandler*>::iterator it = allHandlers_.begin();
-    //        it != allHandlers_.end(); ++it)
-    //        delete *it;
-
-    //    allHandlers_.clear();
-    //    keyHandler_ = 0;
-    //    mouseHandler_ = 0;
-    //    joyStickHandlerAll_ = 0;
-    //    for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandler_.size(); ++iJoyStick)
-    //        joyStickHandler_[iJoyStick] = 0;
-
-    //    update();
-    //}
-
     /**
     @brief
Index: /code/trunk/src/core/input/SimpleInputState.h
===================================================================
--- /code/trunk/src/core/input/SimpleInputState.h	(revision 1880)
+++ /code/trunk/src/core/input/SimpleInputState.h	(revision 1881)
@@ -53,5 +53,4 @@
         bool setJoyStickHandler   (JoyStickHandler* handler);
         bool setHandler(InputHandler* handler);
-        //void removeAndDestroyAllHandlers();
 
     private:
