Index: code/branches/resource2/src/core/input/Button.cc
===================================================================
--- code/branches/resource2/src/core/input/Button.cc	(revision 5662)
+++ code/branches/resource2/src/core/input/Button.cc	(revision 5663)
@@ -59,5 +59,4 @@
         nCommands_[1]=0;
         nCommands_[2]=0;
-        this->configContainer_ = 0;
     }
 
Index: code/branches/resource2/src/core/input/KeyBinder.cc
===================================================================
--- code/branches/resource2/src/core/input/KeyBinder.cc	(revision 5662)
+++ code/branches/resource2/src/core/input/KeyBinder.cc	(revision 5663)
@@ -55,7 +55,4 @@
         mousePosition_[0] = 0;
         mousePosition_[1] = 0;
-
-        joyStickButtons_.reserve(1000);
-        joyStickAxes_.reserve(1000);
 
         RegisterRootObject(KeyBinder);
@@ -167,7 +164,7 @@
             {
                 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i)
-                    joyStickButtons_[iDev][i].readConfigValue(this->configFile_);
+                    (*joyStickButtons_[iDev])[i].readConfigValue(this->configFile_);
                 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i)
-                    joyStickAxes_[iDev][i].readConfigValue(this->configFile_);
+                    (*joyStickAxes_[iDev])[i].readConfigValue(this->configFile_);
             }
         }
@@ -179,4 +176,9 @@
     void KeyBinder::initialiseJoyStickBindings()
     {
+        while (joyStickAxes_.size() < joySticks_.size())
+            joyStickAxes_.push_back(shared_ptr<JoyStickAxisVector>(new JoyStickAxisVector()));
+        while (joyStickButtons_.size() < joySticks_.size())
+            joyStickButtons_.push_back(shared_ptr<JoyStickButtonVector>(new JoyStickButtonVector()));
+        // For the case the new size is smaller
         this->joyStickAxes_.resize(joySticks_.size());
         this->joyStickButtons_.resize(joySticks_.size());
@@ -189,18 +191,18 @@
             for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
             {
-                joyStickButtons_[iDev][i].name_ = JoyStickButtonCode::ByString[i];
-                joyStickButtons_[iDev][i].paramCommandBuffer_ = &paramCommandBuffer_;
-                joyStickButtons_[iDev][i].groupName_ = "JoyStickButtons_" + deviceName;
+                (*joyStickButtons_[iDev])[i].name_ = JoyStickButtonCode::ByString[i];
+                (*joyStickButtons_[iDev])[i].paramCommandBuffer_ = &paramCommandBuffer_;
+                (*joyStickButtons_[iDev])[i].groupName_ = "JoyStickButtons_" + deviceName;
             }
             // joy stick axes
             for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
             {
-                joyStickAxes_[iDev][i].name_ = JoyStickAxisCode::ByString[i / 2];
+                (*joyStickAxes_[iDev])[i].name_ = JoyStickAxisCode::ByString[i / 2];
                 if (i & 1)
-                    joyStickAxes_[iDev][i].name_ += "Pos";
+                    (*joyStickAxes_[iDev])[i].name_ += "Pos";
                 else
-                    joyStickAxes_[iDev][i].name_ += "Neg";
-                joyStickAxes_[iDev][i].paramCommandBuffer_ = &paramCommandBuffer_;
-                joyStickAxes_[iDev][i].groupName_ = "JoyStickAxes_" + deviceName;
+                    (*joyStickAxes_[iDev])[i].name_ += "Neg";
+                (*joyStickAxes_[iDev])[i].paramCommandBuffer_ = &paramCommandBuffer_;
+                (*joyStickAxes_[iDev])[i].groupName_ = "JoyStickAxes_" + deviceName;
             }
         }
@@ -226,9 +228,9 @@
         {
             for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
-                allButtons_[joyStickButtons_[iDev][i].groupName_ + "." + joyStickButtons_[iDev][i].name_] = &(joyStickButtons_[iDev][i]);
+                allButtons_[(*joyStickButtons_[iDev])[i].groupName_ + "." + (*joyStickButtons_[iDev])[i].name_] = &((*joyStickButtons_[iDev])[i]);
             for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
             {
-                allButtons_[joyStickAxes_[iDev][i].groupName_ + "." + joyStickAxes_[iDev][i].name_] = &(joyStickAxes_[iDev][i]);
-                allHalfAxes_.push_back(&(joyStickAxes_[iDev][i]));
+                allButtons_[(*joyStickAxes_[iDev])[i].groupName_ + "." + (*joyStickAxes_[iDev])[i].name_] = &((*joyStickAxes_[iDev])[i]);
+                allHalfAxes_.push_back(&((*joyStickAxes_[iDev])[i]));
             }
         }
@@ -303,6 +305,6 @@
             for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
             {
-                joyStickAxes_[iDev][i].absVal_ = 0.0f;
-                joyStickAxes_[iDev][i].relVal_ = 0.0f;
+                (*joyStickAxes_[iDev])[i].absVal_ = 0.0f;
+                (*joyStickAxes_[iDev])[i].relVal_ = 0.0f;
             }
         }
@@ -366,5 +368,5 @@
         for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
         {
-            tickHalfAxis(joyStickAxes_[joyStick][i]);
+            tickHalfAxis((*joyStickAxes_[joyStick])[i]);
         }
     }
@@ -481,5 +483,5 @@
     {
         int i = axisID * 2;
-        JoyStickAxisVector& axis = joyStickAxes_[device];
+        JoyStickAxisVector& axis = *joyStickAxes_[device];
         if (value < 0)
         {
Index: code/branches/resource2/src/core/input/KeyBinder.h
===================================================================
--- code/branches/resource2/src/core/input/KeyBinder.h	(revision 5662)
+++ code/branches/resource2/src/core/input/KeyBinder.h	(revision 5663)
@@ -41,4 +41,5 @@
 #include <string>
 #include <vector>
+#include <boost/shared_ptr.hpp>
 
 #include "InputHandler.h"
@@ -115,5 +116,5 @@
         };
         //! Actual key bindings for joy stick buttons
-        std::vector<JoyStickButtonVector> joyStickButtons_;
+        std::vector<shared_ptr<JoyStickButtonVector> > joyStickButtons_;
         //! Helper class to use something like std:vector<HalfAxis[48]>
         struct JoyStickAxisVector
@@ -123,5 +124,5 @@
         };
         //! Actual key bindings for joy stick axes (and sliders)
-        std::vector<JoyStickAxisVector> joyStickAxes_;
+        std::vector<shared_ptr<JoyStickAxisVector> > joyStickAxes_;
 
         //! Pointer map with all Buttons, including half axes
@@ -191,11 +192,11 @@
 
     inline void KeyBinder::buttonPressed (unsigned int device, JoyStickButtonCode::ByEnum button)
-    { joyStickButtons_[device][button].execute(KeybindMode::OnPress); }
+    { (*joyStickButtons_[device])[button].execute(KeybindMode::OnPress); }
 
     inline void KeyBinder::buttonReleased(unsigned int device, JoyStickButtonCode::ByEnum button)
-    { joyStickButtons_[device][button].execute(KeybindMode::OnRelease); }
+    { (*joyStickButtons_[device])[button].execute(KeybindMode::OnRelease); }
 
     inline void KeyBinder::buttonHeld    (unsigned int device, JoyStickButtonCode::ByEnum button)
-    { joyStickButtons_[device][button].execute(KeybindMode::OnHold); }
+    { (*joyStickButtons_[device])[button].execute(KeybindMode::OnHold); }
 
     inline void KeyBinder::allDevicesUpdated(float dt)
Index: code/branches/resource2/src/core/input/KeyDetector.cc
===================================================================
--- code/branches/resource2/src/core/input/KeyDetector.cc	(revision 5662)
+++ code/branches/resource2/src/core/input/KeyDetector.cc	(revision 5663)
@@ -70,5 +70,6 @@
     {
         KeyBinder::JoyStickQuantityChanged(joyStickList);
-        setCallbackCommand(callbackCommand_);
+        if (!callbackCommand_.empty())
+            setCallbackCommand(callbackCommand_);
     }
 }
