Index: code/branches/pickup2/src/libraries/core/ArgumentCompletionFunctions.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/ArgumentCompletionFunctions.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ArgumentCompletionFunctions.cc	(revision 6412)
@@ -72,5 +72,5 @@
                 else
                 {
-                    std::string dir = startdirectory.string();
+                    const std::string& dir = startdirectory.string();
                     if (dir.size() > 0 && dir[dir.size() - 1] == ':')
                         startdirectory = dir + '/';
@@ -84,7 +84,7 @@
                 {
                     if (boost::filesystem::is_directory(*file))
-                        dirlist.push_back(ArgumentCompletionListElement((*file).string() + '/', getLowercase((*file).string()) + '/', (*file).BOOST_LEAF_FUNCTION() + '/'));
+                        dirlist.push_back(ArgumentCompletionListElement(file->string() + '/', getLowercase(file->string()) + '/', file->BOOST_LEAF_FUNCTION() + '/'));
                     else
-                        filelist.push_back(ArgumentCompletionListElement((*file).string(), getLowercase((*file).string()), (*file).BOOST_LEAF_FUNCTION()));
+                        filelist.push_back(ArgumentCompletionListElement(file->string(), getLowercase(file->string()), file->BOOST_LEAF_FUNCTION()));
                     ++file;
                 }
@@ -101,6 +101,6 @@
 
             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
-                if ((*it).second->hasConfigValues())
-                    classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+                if (it->second->hasConfigValues())
+                    classlist.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
 
             return classlist;
@@ -110,10 +110,10 @@
         {
             ArgumentCompletionList configvalues;
-            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getStringIdentifierMap().find(classname);
+            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
 
-            if (identifier != Identifier::getStringIdentifierMapEnd() && (*identifier).second->hasConfigValues())
+            if (identifier != Identifier::getLowercaseStringIdentifierMapEnd() && identifier->second->hasConfigValues())
             {
-                for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it)
-                    configvalues.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+                for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->second->getConfigValueMapBegin(); it != identifier->second->getConfigValueMapEnd(); ++it)
+                    configvalues.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
             }
 
@@ -127,8 +127,8 @@
             if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
             {
-                std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
-                if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+                std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
+                if (variable != identifier->second->getLowercaseConfigValueMapEnd())
                 {
-                    std::string valuestring = (*variable).second->toString();
+                    const std::string& valuestring = variable->second->toString();
                     oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
                 }
Index: code/branches/pickup2/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/BaseObject.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/BaseObject.cc	(revision 6412)
@@ -36,5 +36,4 @@
 #include <tinyxml/tinyxml.h>
 
-#include "util/StringUtils.h"
 #include "CoreIncludes.h"
 #include "Event.h"
@@ -119,5 +118,5 @@
         XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
         XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode);
-        
+
         Element* events = 0;
         if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
@@ -139,5 +138,5 @@
         XMLPortEventState(BaseObject, BaseObject, "visibility", setVisible, xmlelement, mode);
         XMLPortEventState(BaseObject, BaseObject, "mainstate", setMainState, xmlelement, mode);
-        
+
         this->bRegisteredEventStates_ = true;
     }
@@ -236,5 +235,5 @@
             if (it->second != state)
                 continue;
-            
+
             if (i == index)
                 return it->first;
@@ -252,5 +251,5 @@
         listener->addEventSource(this, "mainstate");
     }
-    
+
     /**
         @brief Returns an event listener with a given index.
@@ -278,5 +277,5 @@
         if (it != this->eventStates_.end())
         {
-            COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << "." << std::endl;
+            COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << '.' << std::endl;
             delete (it->second);
         }
@@ -292,5 +291,5 @@
         std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(name);
         if (it != this->eventStates_.end())
-            return ((*it).second);
+            return (it->second);
         else
             return 0;
@@ -344,9 +343,9 @@
     {
         this->registerEventStates();
-        
+
         std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(event.statename_);
         if (it != this->eventStates_.end())
             it->second->process(event, this);
-        else if (event.statename_ != "")
+        else if (!event.statename_.empty())
             COUT(2) << "Warning: \"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;
         else
@@ -356,5 +355,5 @@
     /**
         @brief Sets the main state of the object to a given boolean value.
-        
+
         Note: The main state of an object can be set with the @ref setMainStateName function.
         It's part of the eventsystem and used for event forwarding (when the target object can't specify a specific state,
@@ -386,8 +385,8 @@
         this->mainStateFunctor_ = 0;
 
-        if (this->mainStateName_ != "")
+        if (!this->mainStateName_.empty())
         {
             this->registerEventStates();
-            
+
             std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(this->mainStateName_);
             if (it != this->eventStates_.end() && it->second->getFunctor())
@@ -402,5 +401,5 @@
         }
     }
-    
+
     /**
         @brief Calls XMLEventPort with an empty XML-element to register the event states if necessary.
@@ -414,5 +413,5 @@
         }
     }
-    
+
     /**
         @brief Manually loads all event states, even if the class doesn't officially support them. This is needed by some classes like @ref EventDispatcher or @ref EventTarget.
@@ -437,5 +436,5 @@
             for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
             {
-                std::string statename = (*it);
+                const std::string& statename = (*it);
 
                 // if the event state is already known, continue with the next state
@@ -447,6 +446,6 @@
                 if (!container)
                 {
-                    ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + "(" + statename + ")");
-                    ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + "(" + statename + ")");
+                    ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')');
+                    ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')');
                     setfunctor->setDefaultValue(1, statename);
                     getfunctor->setDefaultValue(1, statename);
Index: code/branches/pickup2/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/pickup2/src/libraries/core/BaseObject.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/BaseObject.h	(revision 6412)
@@ -157,5 +157,5 @@
             void removeEventSource(BaseObject* source);
             BaseObject* getEventSource(unsigned int index, const std::string& state) const;
-            
+
             void addEventListener(BaseObject* listener);
             BaseObject* getEventListener(unsigned int index) const;
@@ -172,5 +172,5 @@
             /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */
             inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }
-            
+
             static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier);
 
@@ -210,5 +210,5 @@
             Gametype*              oldGametype_;
             std::set<Template*>    templates_;
-            
+
             std::map<BaseObject*, std::string>  eventSources_;           //!< List of objects which send events to this object, mapped to the state which they affect
             std::set<BaseObject*>               eventListeners_;         //!< List of objects which listen to the events of this object
Index: code/branches/pickup2/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/libraries/core/CMakeLists.txt	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/CMakeLists.txt	(revision 6412)
@@ -29,4 +29,5 @@
   GraphicsManager.cc
   GUIManager.cc
+  IOConsole.cc
   Language.cc
   LuaState.cc
@@ -40,5 +41,5 @@
   CommandEvaluation.cc
   CommandExecutor.cc
-  CommandLine.cc
+  CommandLineParser.cc
   ConsoleCommand.cc
   ConsoleCommandCompilation.cc
@@ -85,6 +86,14 @@
   TOLUA_FILES
     CommandExecutor.h
+    ConfigFileManager.h
+    Game.h
+    GameMode.h
+    GUIManager.h
     Loader.h
     LuaState.h
+    PathConfig.h
+    input/InputManager.h
+    input/KeyBinder.h
+    input/KeyBinderManager.h
   DEFINE_SYMBOL
     "CORE_SHARED_BUILD"
Index: code/branches/pickup2/src/libraries/core/ClassTreeMask.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/ClassTreeMask.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ClassTreeMask.cc	(revision 6412)
@@ -291,4 +291,6 @@
     void ClassTreeMask::add(const Identifier* subclass, bool bInclude, bool overwrite, bool clean)
     {
+        if (!subclass)
+            return;
         // Check if the given subclass is a child of our root-class
         if (subclass->isA(this->root_->getClass()))
@@ -320,4 +322,6 @@
     void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite)
     {
+        if (!subclass)
+            return;
         // Check if the current node contains exactly the subclass we want to add
         if (subclass == node->getClass())
@@ -395,4 +399,6 @@
     void ClassTreeMask::addSingle(const Identifier* subclass, bool bInclude, bool clean)
     {
+        if (!subclass)
+            return;
         for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
             this->add(*it, this->isIncluded(*it), false, false);
@@ -428,4 +434,6 @@
     bool ClassTreeMask::isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const
     {
+        if (!subclass)
+            return false;
         // Check if the searched subclass is of the same type as the class in the current node or a derivative
         if (subclass->isA(node->getClass()))
@@ -816,10 +824,10 @@
             // Calculate the prefix: + means included, - means excluded
             if (it->isIncluded())
-                out << "+";
+                out << '+';
             else
-                out << "-";
+                out << '-';
 
             // Put the name of the corresponding class on the stream
-            out << it->getClass()->getName() << " ";
+            out << it->getClass()->getName() << ' ';
         }
 
@@ -850,10 +858,10 @@
         // If there is a first subclass, move the object-iterator to the first object of this class. Else go to the end
         if (this->subclassIterator_ != this->subclasses_.end())
-            this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+            this->objectIterator_ = this->subclassIterator_->first->getObjects()->begin();
         else
             this->objectIterator_ = ObjectList<BaseObject>::end();
 
         // Check if the iterator points on a valid object. If not, go to the next object by calling ++
-        if (!this->objectIterator_ || ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first)))
+        if (!this->objectIterator_ || (this->subclassIterator_->second && !this->objectIterator_->isExactlyA(this->subclassIterator_->first)))
             this->operator++();
 
@@ -882,5 +890,5 @@
                     // Check if there really is a next class. If yes, move the object-iterator to the first object
                     if (this->subclassIterator_ != this->subclasses_.end())
-                        this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+                        this->objectIterator_ = this->subclassIterator_->first->getObjects()->begin();
                     else
                         return (*this);
@@ -888,5 +896,5 @@
 
             // Repeat this until we reach a valid object or the end
-            } while ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first));
+            } while (this->subclassIterator_->second && !this->objectIterator_->isExactlyA(this->subclassIterator_->first));
         }
         return (*this);
Index: code/branches/pickup2/src/libraries/core/CommandEvaluation.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandEvaluation.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/CommandEvaluation.cc	(revision 6412)
@@ -50,5 +50,5 @@
         this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
 
-        this->additionalParameter_ = "";
+        this->additionalParameter_.clear();
 
         this->bEvaluatedParams_ = false;
@@ -60,8 +60,8 @@
         this->functionclass_ = 0;
         this->function_ = 0;
-        this->possibleArgument_ = "";
-        this->argument_ = "";
-
-        this->errorMessage_ = "";
+        this->possibleArgument_.clear();
+        this->argument_.clear();
+
+        this->errorMessage_.clear();
         this->state_ = CommandState::Empty;
     }
@@ -79,5 +79,5 @@
         if (this->bEvaluatedParams_ && this->function_)
         {
-            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
+            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << ' ' << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl;
             (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
             return true;
@@ -98,5 +98,5 @@
     }
 
-    std::string CommandEvaluation::complete()
+    const std::string& CommandEvaluation::complete()
     {
         if (!this->bNewCommand_)
@@ -114,8 +114,8 @@
                             return (this->command_ = this->function_->getName());
                         else
-                            return (this->command_ = this->function_->getName() + " ");
+                            return (this->command_ = this->function_->getName() + ' ');
                     }
                     else if (this->functionclass_)
-                        return (this->command_ = this->functionclass_->getName() + " ");
+                        return (this->command_ = this->functionclass_->getName() + ' ');
                     break;
                 case CommandState::Function:
@@ -123,7 +123,7 @@
                     {
                         if (this->function_->getParamCount() == 0)
-                            return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName());
+                            return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName());
                         else
-                            return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName() + " ");
+                            return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName() + ' ');
                     }
                     break;
@@ -131,5 +131,5 @@
                 case CommandState::Params:
                 {
-                    if (this->argument_ == "" && this->possibleArgument_ == "")
+                    if (this->argument_.empty() && this->possibleArgument_.empty())
                         break;
 
@@ -137,7 +137,7 @@
                     if (this->command_[this->command_.size() - 1] != ' ')
                         maxIndex -= 1;
-                    std::string whitespace = "";
-
-                    if (this->possibleArgument_ != "")
+                    std::string whitespace;
+
+                    if (!this->possibleArgument_.empty())
                     {
                         this->argument_ = this->possibleArgument_;
@@ -146,5 +146,5 @@
                     }
 
-                    return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + " " + this->argument_ + whitespace);
+                    return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + ' ' + this->argument_ + whitespace);
                     break;
                 }
@@ -262,11 +262,11 @@
     std::string CommandEvaluation::dump(const std::list<std::pair<const std::string*, const std::string*> >& list)
     {
-        std::string output = "";
+        std::string output;
         for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
         {
             if (it != list.begin())
-                output += " ";
-
-            output += *(*it).second;
+                output += ' ';
+
+            output += *(it->second);
         }
         return output;
@@ -275,11 +275,11 @@
     std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
     {
-        std::string output = "";
+        std::string output;
         for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
         {
             if (it != list.begin())
-                output += " ";
-
-            output += (*it).getDisplay();
+                output += ' ';
+
+            output += it->getDisplay();
         }
         return output;
@@ -295,17 +295,17 @@
         {
             if (i != 0)
-                output += " ";
+                output += ' ';
 
             if (command->defaultValueSet(i))
-                output += "[";
+                output += '[';
             else
-                output += "{";
+                output += '{';
 
             output += command->getTypenameParam(i);
 
             if (command->defaultValueSet(i))
-                output += "=" + command->getDefaultValue(i).getString() + "]";
+                output += '=' + command->getDefaultValue(i).getString() + ']';
             else
-                output += "}";
+                output += '}';
         }
         return output;
Index: code/branches/pickup2/src/libraries/core/CommandEvaluation.h
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandEvaluation.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/CommandEvaluation.h	(revision 6412)
@@ -66,5 +66,5 @@
 
             bool execute() const;
-            std::string complete();
+            const std::string& complete();
             std::string hint() const;
             void evaluateParams();
@@ -82,5 +82,5 @@
                 { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
             inline std::string getAdditionalParameter() const
-                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
+                { return (!this->additionalParameter_.empty()) ? (' ' + this->additionalParameter_) : ""; }
 
             void setEvaluatedParameter(unsigned int index, MultiType param);
Index: code/branches/pickup2/src/libraries/core/CommandExecutor.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandExecutor.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/CommandExecutor.cc	(revision 6412)
@@ -59,5 +59,5 @@
         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
         {
-            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << "." << std::endl;
+            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << '.' << std::endl;
         }
 
@@ -82,5 +82,5 @@
         std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);
         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
-            return (*it).second;
+            return it->second;
         else
             return 0;
@@ -96,5 +96,5 @@
         std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);
         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end())
-            return (*it).second;
+            return it->second;
         else
             return 0;
@@ -215,5 +215,5 @@
                         CommandExecutor::getEvaluation().state_ = CommandState::Error;
                         AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + ' ' + GetLocalisation("commandexecutorunknownfirstargument") + '.';
                         return;
                     }
@@ -231,5 +231,5 @@
                     {
                         // It's a shortcut
-                        std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                        const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
                         CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname);
                         if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0)))
@@ -243,5 +243,5 @@
                         if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
                         {
-                            CommandExecutor::getEvaluation().command_ += " ";
+                            CommandExecutor::getEvaluation().command_ += ' ';
                             CommandExecutor::getEvaluation().bCommandChanged_ = true;
                         }
@@ -251,5 +251,5 @@
                     {
                         // It's a classname
-                        std::string classname = *(*CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()).first;
+                        const std::string& classname = *CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()->first;
                         CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname);
                         if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0)))
@@ -260,5 +260,5 @@
                         CommandExecutor::getEvaluation().state_ = CommandState::Function;
                         CommandExecutor::getEvaluation().function_ = 0;
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ';
                         // Move on to next case
                     }
@@ -268,5 +268,5 @@
                         CommandExecutor::getEvaluation().state_ = CommandState::Error;
                         AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + ' ' + CommandExecutor::getArgument(0) + '.';
                         return;
                     }
@@ -319,5 +319,5 @@
                         {
                             // It's a function
-                            std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                            const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
                             CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname, CommandExecutor::getEvaluation().functionclass_);
                             if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(1)))
@@ -327,8 +327,8 @@
                             }
                             CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getEvaluation().function_->getName();
                             if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
                             {
-                                CommandExecutor::getEvaluation().command_ += " ";
+                                CommandExecutor::getEvaluation().command_ += ' ';
                                 CommandExecutor::getEvaluation().bCommandChanged_ = true;
                             }
@@ -340,5 +340,5 @@
                             CommandExecutor::getEvaluation().state_ = CommandState::Error;
                             AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
-                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";
+                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + GetLocalisation("commandexecutorunknownsecondargumentstart") + ' ' + CommandExecutor::getArgument(1) + '.';
                             return;
                         }
@@ -346,5 +346,5 @@
                         {
                             // There are several possibilities
-                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
                             CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
                             CommandExecutor::getEvaluation().bCommandChanged_ = true;
@@ -386,6 +386,6 @@
                 {
                     // There is exactly one possible argument
-                    CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
-                    CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
+                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
+                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
                     CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
                     return;
@@ -451,13 +451,13 @@
     }
 
-    std::string CommandExecutor::getArgument(unsigned int index)
+    const std::string& CommandExecutor::getArgument(unsigned int index)
     {
         if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
             return CommandExecutor::getEvaluation().commandTokens_[index];
         else
-            return "";
-    }
-
-    std::string CommandExecutor::getLastArgument()
+            return BLANKSTRING;
+    }
+
+    const std::string& CommandExecutor::getLastArgument()
     {
         return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1);
@@ -467,9 +467,9 @@
     {
         CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
-        std::string lowercase = getLowercase(fragment);
+        const std::string& lowercase = getLowercase(fragment);
         for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it)
-            if ((*it).second->hasConsoleCommands())
-                if ((*it).first.find(lowercase) == 0 || fragment == "")
-                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+            if (it->second->hasConsoleCommands())
+                if (it->first.find(lowercase) == 0 || fragment.empty())
+                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
     }
 
@@ -477,16 +477,16 @@
     {
         CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear();
-        std::string lowercase = getLowercase(fragment);
+        const std::string& lowercase = getLowercase(fragment);
         if (!identifier)
         {
             for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
-                if ((*it).first.find(lowercase) == 0 || fragment == "")
-                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+                if (it->first.find(lowercase) == 0 || fragment.empty())
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
         }
         else
         {
             for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
-                if ((*it).first.find(lowercase) == 0 || fragment == "")
-                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+                if (it->first.find(lowercase) == 0 || fragment.empty())
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
         }
     }
@@ -497,15 +497,15 @@
 
         CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
-        std::string lowercase = getLowercase(fragment);
+        const std::string& lowercase = getLowercase(fragment);
         for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
         {
-            if ((*it).lowercaseComparison())
-            {
-                if ((*it).getComparable().find(lowercase) == 0 || fragment == "")
+            if (it->lowercaseComparison())
+            {
+                if (it->getComparable().find(lowercase) == 0 || fragment.empty())
                     CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
             }
             else
             {
-                if ((*it).getComparable().find(fragment) == 0 || fragment == "")
+                if (it->getComparable().find(fragment) == 0 || fragment.empty())
                     CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
             }
@@ -515,8 +515,8 @@
     Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
     {
-        std::string lowercase = getLowercase(name);
+        const std::string& lowercase = getLowercase(name);
         std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase);
-        if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
-            return (*it).second;
+        if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && it->second->hasConsoleCommands())
+            return it->second;
 
         return 0;
@@ -525,10 +525,10 @@
     ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
     {
-        std::string lowercase = getLowercase(name);
+        const std::string& lowercase = getLowercase(name);
         if (!identifier)
         {
             std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);
             if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd())
-                return (*it).second;
+                return it->second;
         }
         else
@@ -536,29 +536,29 @@
             std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
             if (it != identifier->getLowercaseConsoleCommandMapEnd())
-                return (*it).second;
+                return it->second;
         }
         return 0;
     }
 
-    std::string CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
+    const std::string& CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
     {
         CommandExecutor::createArgumentCompletionList(command, param);
 
-        std::string lowercase = getLowercase(name);
+        const std::string& lowercase = getLowercase(name);
         for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
         {
-            if ((*it).lowercaseComparison())
-            {
-                if ((*it).getComparable() == lowercase)
-                    return (*it).getString();
+            if (it->lowercaseComparison())
+            {
+                if (it->getComparable() == lowercase)
+                    return it->getString();
             }
             else
             {
-                if ((*it).getComparable() == name)
-                    return (*it).getString();
-            }
-        }
-
-        return "";
+                if (it->getComparable() == name)
+                    return it->getString();
+            }
+        }
+
+        return BLANKSTRING;
     }
 
@@ -589,9 +589,9 @@
         else if (list.size() == 1)
         {
-            return ((*(*list.begin()).first) + " ");
-        }
-        else
-        {
-            std::string output = "";
+            return ((*list.begin()->first) + ' ');
+        }
+        else
+        {
+            std::string output;
             for (unsigned int i = 0; true; i++)
             {
@@ -599,13 +599,13 @@
                 for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
                 {
-                    if ((*(*it).first).size() > i)
+                    if (it->first->size() > i)
                     {
                         if (it == list.begin())
                         {
-                            temp = (*(*it).first)[i];
+                            temp = (*it->first)[i];
                         }
                         else
                         {
-                            if (temp != (*(*it).first)[i])
+                            if (temp != (*it->first)[i])
                                 return output;
                         }
@@ -630,25 +630,30 @@
         else if (list.size() == 1)
         {
-            return ((*list.begin()).getComparable() + " ");
-        }
-        else
-        {
-            std::string output = "";
+            return (list.begin()->getComparable() + ' ');
+        }
+        else
+        {
+            std::string output;
             for (unsigned int i = 0; true; i++)
             {
+                char tempComparable = 0;
                 char temp = 0;
                 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
                 {
-                    std::string argument = (*it).getComparable();
+                    const std::string& argumentComparable = it->getComparable();
+                    const std::string& argument = it->getString();
                     if (argument.size() > i)
                     {
                         if (it == list.begin())
                         {
+                            tempComparable = argumentComparable[i];
                             temp = argument[i];
                         }
                         else
                         {
-                            if (temp != argument[i])
+                            if (tempComparable != argumentComparable[i])
                                 return output;
+                            else if (temp != argument[i])
+                                temp = tempComparable;
                         }
                     }
Index: code/branches/pickup2/src/libraries/core/CommandExecutor.h
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandExecutor.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/CommandExecutor.h	(revision 6412)
@@ -90,6 +90,6 @@
             static unsigned int argumentsGiven();
             static bool enoughArgumentsGiven(ConsoleCommand* command);
-            static std::string getArgument(unsigned int index);
-            static std::string getLastArgument();
+            static const std::string& getArgument(unsigned int index);
+            static const std::string& getLastArgument();
 
             static void createListOfPossibleIdentifiers(const std::string& fragment);
@@ -99,5 +99,5 @@
             static Identifier* getPossibleIdentifier(const std::string& name);
             static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
-            static std::string getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
+            static const std::string& getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
 
             static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param);
Index: code/branches/pickup2/src/libraries/core/CommandLine.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandLine.cc	(revision 6405)
+++ 	(revision )
@@ -1,377 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "CommandLine.h"
-
-#include <algorithm>
-#include <sstream>
-
-#include "util/Convert.h"
-#include "util/Debug.h"
-#include "util/Exception.h"
-#include "util/StringUtils.h"
-#include "util/SubString.h"
-#include "PathConfig.h"
-
-namespace orxonox
-{
-    SetCommandLineOnlyArgument(optionsFile, "start.ini").shortcut("o");
-
-    /**
-    @brief
-        Parses a value string for a command line argument.
-        It simply uses convertValue(Output, Input) to do that.
-        Bools are treated specially. That is necessary
-        so that you can have simple command line switches.
-    */
-    void CommandLineArgument::parse(const std::string& value, bool bParsingFile)
-    {
-        if (bParsingFile && this->bCommandLineOnly_)
-            ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files.");
-        if (value_.getType() == MT_Type::Bool)
-        {
-            // simulate command line switch
-            bool temp;
-            if (convertValue(&temp, value))
-            {
-                this->bHasDefaultValue_ = false;
-                this->value_ = temp;
-            }
-            else if (value == "")
-            {
-                this->bHasDefaultValue_ = false;
-                this->value_ = true;
-            }
-            else
-                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
-        }
-        else
-        {
-            if (!value_.setValue(value))
-            {
-                value_.setValue(defaultValue_);
-                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
-            }
-            else
-                this->bHasDefaultValue_ = false;
-        }
-    }
-
-
-    /**
-    @brief
-        Destructor destroys all CommandLineArguments with it.
-    */
-    CommandLine::~CommandLine()
-    {
-        CommandLine::destroyAllArguments();
-    }
-
-    /**
-    @brief
-        Returns a unique instance (Meyers Singleton).
-    */
-    CommandLine& CommandLine::_getInstance()
-    {
-        static CommandLine instance;
-        return instance;
-    }
-
-    /**
-    @brief
-        Destroys all command line arguments. This should be called at the end
-        of main. Do not use before that.
-    */
-    void CommandLine::destroyAllArguments()
-    {
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin();
-            it != _getInstance().cmdLineArgs_.end(); ++it)
-            delete it->second;
-        _getInstance().cmdLineArgs_.clear();
-    }
-
-    /**
-    @brief
-        Reads the command line parses the values of each argument.
-        It is then stored in the corresponding CommandLineArgument.
-    @note
-        The reason that you have to provide the string to be parsed as
-        space separted list is because of argc and argv. If you only have
-        a whole string, simply use getAllStrings() of SubString.
-    @param arguments
-        Vector of space separated strings.
-    */
-    void CommandLine::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
-    {
-        try
-        {
-            // why this? See bFirstTimeParse_ declaration.
-            if (bFirstTimeParse_)
-            {
-                // first shove all the shortcuts in a map
-                for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
-                    it != cmdLineArgs_.end(); ++it)
-                {
-                    OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
-                        "Cannot have two command line shortcut with the same name.");
-                    if (it->second->getShortcut() != "")
-                        cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
-                }
-                bFirstTimeParse_ = false;
-            }
-
-            std::string name;
-            std::string shortcut;
-            std::string value;
-            for (unsigned int i = 0; i < arguments.size(); ++i)
-            {
-                if (arguments[i].size() != 0)
-                {
-                    // sure not ""
-                    if (arguments[i][0] == '-')
-                    {
-                        // start with "-"
-                        if (arguments[i].size() == 1)
-                        {
-                            // argument[i] is "-", probably a minus sign
-                            value += "- ";
-                        }
-                        else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
-                        {
-                            // negative number as a value
-                            value += arguments[i] + " ";
-                        }
-                        else
-                        {
-                            // can be shortcut or full name argument
-
-                            // save old data first
-                            value = removeTrailingWhitespaces(value);
-                            if (name != "")
-                            {
-                                checkFullArgument(name, value, bParsingFile);
-                                name = "";
-                                assert(shortcut == "");
-                            }
-                            else if (shortcut != "")
-                            {
-                                checkShortcut(shortcut, value, bParsingFile);
-                                shortcut = "";
-                                assert(name == "");
-                            }
-
-                            if (arguments[i][1] == '-')
-                            {
-                                // full name argument with "--name"
-                                name = arguments[i].substr(2);
-                            }
-                            else
-                            {
-                                // shortcut with "-s"
-                                shortcut = arguments[i].substr(1);
-                            }
-
-                            // reset value string
-                            value = "";
-                        }
-                    }
-                    else
-                    {
-                        // value string
-
-                        if (name == "" && shortcut == "")
-                        {
-                            ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
-                        }
-
-                        // Concatenate strings as long as there's no new argument by "-" or "--"
-                        value += arguments[i] + ' ';
-                    }
-                }
-            }
-
-            // parse last argument
-            value = removeTrailingWhitespaces(value);
-            if (name != "")
-            {
-                checkFullArgument(name, value, bParsingFile);
-                assert(shortcut == "");
-            }
-            else if (shortcut != "")
-            {
-                checkShortcut(shortcut, value, bParsingFile);
-                assert(name == "");
-            }
-        }
-        catch (const ArgumentException& ex)
-        {
-            COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl;
-            COUT(0) << CommandLine::getUsageInformation() << std::endl;
-            throw GeneralException("");
-        }
-    }
-
-    /**
-    @brief
-        Parses an argument based on its full name.
-    @param name
-        Full name of the argument
-    @param value
-        String containing the value
-    */
-    void CommandLine::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
-        if (it == cmdLineArgs_.end())
-            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
-
-        it->second->parse(value, bParsingFile);
-    }
-
-    /**
-    @brief
-        Parses an argument based on its shortcut.
-    @param shortcut
-        Shotcut to the argument
-    @param value
-        String containing the value
-    */
-    void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
-        if (it == cmdLineArgsShortcut_.end())
-            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
-
-        it->second->parse(value, bParsingFile);
-    }
-
-    std::string CommandLine::getUsageInformation()
-    {
-        CommandLine& inst = _getInstance();
-        std::ostringstream infoStr;
-
-        // determine maximum name size
-        size_t maxNameSize = 0;
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
-            it != inst.cmdLineArgs_.end(); ++it)
-        {
-            maxNameSize = std::max(it->second->getName().size(), maxNameSize);
-        }
-
-        infoStr << std::endl;
-        infoStr << "Usage: orxonox [options]" << std::endl;
-        infoStr << "Available options:" << std::endl;
-
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
-            it != inst.cmdLineArgs_.end(); ++it)
-        {
-            if (it->second->getShortcut() != "")
-                infoStr << " [-" << it->second->getShortcut() << "] ";
-            else
-                infoStr << "      ";
-            infoStr << "--" << it->second->getName() << " ";
-            if (it->second->getValue().getType() != MT_Type::Bool)
-                infoStr << "ARG ";
-            else
-                infoStr << "    ";
-            // fill with the necessary amount of blanks
-            infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
-            infoStr << ": " << it->second->getInformation();
-            infoStr << std::endl;
-        }
-        return infoStr.str();
-    }
-
-    /**
-    @brief
-        Retrieves a CommandLineArgument.
-        The method throws an exception if 'name' was not found or the value could not be converted.
-    @note
-        You shold of course not call this method before the command line has been parsed.
-    */
-    const CommandLineArgument* CommandLine::getArgument(const std::string& name)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
-        if (it == _getInstance().cmdLineArgs_.end())
-        {
-            ThrowException(Argument, "Could find command line argument '" + name + "'.");
-        }
-        else
-        {
-            return it->second;
-        }
-    }
-
-    /**
-    @brief
-        Parses only the command line for CommandLineArguments.
-    */
-    void CommandLine::_parseCommandLine(const std::string& cmdLine)
-    {
-        std::vector<std::string> args;
-        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '(', ')', false);
-        for (unsigned i = 0; i < tokens.size(); ++i)
-            args.push_back(tokens[i]);
-        this->_parse(args, false);
-    }
-
-    /**
-    @brief
-        Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
-    */
-    void CommandLine::_parseFile()
-    {
-        std::string filename = CommandLine::getValue("optionsFile").getString();
-
-        // look for additional arguments in given file or start.ini as default
-        // They will not overwrite the arguments given directly
-        std::ifstream file;
-        file.open((PathConfig::getConfigPathString() + filename).c_str());
-        std::vector<std::string> args;
-        if (file)
-        {
-            while (!file.eof())
-            {
-                std::string line;
-                std::getline(file, line);
-                line = removeTrailingWhitespaces(line);
-                //if (!(line[0] == '#' || line[0] == '%'))
-                //{
-                SubString tokens(line, " ", " ", false, '\\', true, '"', true, '(', ')', false, '#');
-                for (unsigned i = 0; i < tokens.size(); ++i)
-                    if (tokens[i][0] != '#')
-                        args.push_back(tokens[i]);
-                //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
-                //}
-            }
-            file.close();
-        }
-
-        _parse(args, true);
-    }
-}
Index: code/branches/pickup2/src/libraries/core/CommandLine.h
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandLine.h	(revision 6405)
+++ 	(revision )
@@ -1,223 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _CommandLine_H__
-#define _CommandLine_H__
-
-#include "CorePrereqs.h"
-
-#include <map>
-#include "util/OrxAssert.h"
-#include "util/MultiType.h"
-
-#define SetCommandLineArgument(name, defaultValue) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLine::addArgument(#name, defaultValue, false)
-#define SetCommandLineOnlyArgument(name, defaultValue) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLine::addArgument(#name, defaultValue, true)
-#define SetCommandLineSwitch(name) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLine::addArgument(#name, false, false)
-#define SetCommandLineOnlySwitch(name) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLine::addArgument(#name, false, true)
-
-
-namespace orxonox
-{
-    /**
-    @brief
-        Container class for a command line argument of any type supported by MultiType.
-
-        Whenever you want to have an option specified by a command line switch,
-        you need to first define it with SetCommandLineArgument(name, defaultValue).
-        It is then added to a map and possibly changed when the command line is being parsed.
-        If the option was not given, you can detect this by asking hasDefaultValue().
-
-        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
-        Note the difference between "-" and "--"!
-        Also, there is no restriction to the number of strings you add after --name.
-        So "--startVector (2, 4, 5)" is perfectly legal.
-
-        Retrieving an argument is possible with the getCommandLineArgument function of the
-        CommandLine class. It is a Singleton, but the public interface is static.
-    */
-    class _CoreExport CommandLineArgument
-    {
-        friend class CommandLine;
-
-    public:
-        //! Tells whether the value has been changed by the command line.
-        bool hasDefaultValue() const { return bHasDefaultValue_; }
-        //! Returns the name of the argument.
-        const std::string& getName() const { return name_; }
-
-        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
-        //! Evaluates to "" if there is none.
-        const std::string& getShortcut() const { return shortcut_; }
-        //! Sets the shortcut for the argument
-        CommandLineArgument& shortcut(const std::string& shortcut)
-        { this->shortcut_ = shortcut; return *this; }
-
-        //! Returns the usage information
-        const std::string& getInformation() const { return this->usageInformation_; }
-        //! Sets the option information when displaying orxonox usage.
-        CommandLineArgument& information(const std::string& usage)
-        { this->usageInformation_ = usage; return *this; }
-
-        //! Returns the actual value of the argument. Can be equal to default value.
-        MultiType getValue() const { return value_; }
-        //! Returns the given default value as type T.
-        MultiType getDefaultValue() const { return defaultValue_; }
-
-    private:
-        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
-        CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
-            : bHasDefaultValue_(true)
-            , name_(name)
-            , value_(defaultValue)
-            , defaultValue_(defaultValue)
-            , bCommandLineOnly_(bCommandLineOnly)
-        { }
-
-        //! Undefined copy constructor
-        CommandLineArgument(const CommandLineArgument& instance);
-        ~CommandLineArgument() { }
-
-        //! Parses the value string of a command line argument.
-        void parse(const std::string& value, bool bParsingFile);
-
-        //! Tells whether the value has been changed by the command line.
-        bool bHasDefaultValue_;
-
-    private:
-        std::string name_;             //!< Name of the argument
-        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
-        std::string usageInformation_; //!< Tells about the usage of this parameter
-
-        MultiType   value_;            //!< The actual value
-        MultiType   defaultValue_;     //!< Default value. Should not be changed.
-        bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
-    };
-
-
-    /**
-    @brief
-        Global interface to command line options.
-        Allows to add and retrieve command line arguments. Also does the parsing.
-    @note
-        Internally it is a Singleton, but the public interface is static.
-    @see
-        CommandLineArgument
-    */
-    class _CoreExport CommandLine
-    {
-    public:
-
-        //! Parse redirection to internal member method.
-        static void parseCommandLine(const std::string& cmdLine) { _getInstance()._parseCommandLine(cmdLine); }
-        static void parseFile() { _getInstance()._parseFile(); }
-
-        static std::string getUsageInformation();
-
-        static const CommandLineArgument* getArgument(const std::string& name);
-        //! Writes the argument value in the given parameter.
-        template <class T>
-        static void getValue(const std::string& name, T* value)
-        { *value = (T)(getArgument(name)->getValue()); }
-        static MultiType getValue(const std::string& name)
-        { return getArgument(name)->getValue(); }
-        template <class T>
-        static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
-
-        static bool existsArgument(const std::string& name)
-        {
-            std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
-            return !(it == _getInstance().cmdLineArgs_.end());
-        }
-
-        static void destroyAllArguments();
-
-    private:
-        //! Constructor initialises bFirstTimeParse_ with true.
-        CommandLine() : bFirstTimeParse_(true) { }
-        //! Undefined copy constructor
-        CommandLine(const CommandLine& instance);
-        ~CommandLine();
-
-        static CommandLine& _getInstance();
-
-        void _parseCommandLine(const std::string& cmdLine);
-        void _parseFile();
-        void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
-        void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
-        void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
-
-        /**
-            Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
-            So when we call parse() the first time, we need to create a map with all shortcuts since these
-            get added after addCommandLineArgument().
-        */
-        bool bFirstTimeParse_;
-
-        //! Holds all pointers to the arguments and serves as a search map by name.
-        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
-        //! Search map by shortcut for the arguments.
-        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
-    };
-
-    template <>
-    inline void CommandLine::getValue<std::string>(const std::string& name, std::string* value)
-    {
-        *value = getArgument(name)->getValue().getString();
-    }
-
-    /**
-    @brief
-        Adds a new CommandLineArgument to the internal map.
-        Note that only such arguments are actually valid.
-    @param name
-        Name of the argument. Shortcut can be added later.
-    @param defaultValue
-        Default value that is used when argument was not given.
-    */
-    template <class T>
-    CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
-    {
-        OrxAssert(!_getInstance().existsArgument(name),
-            "Cannot add a command line argument with name '" + name + "' twice.");
-        OrxAssert(MultiType(defaultValue).getType() != MT_Type::Bool || MultiType(defaultValue).getBool() != true,
-               "Boolean command line arguments with positive default values are not supported." << std::endl
-            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
-
-        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
-    }
-}
-
-#endif /* _CommandLine_H__ */
Index: code/branches/pickup2/src/libraries/core/CommandLineParser.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandLineParser.cc	(revision 6412)
+++ code/branches/pickup2/src/libraries/core/CommandLineParser.cc	(revision 6412)
@@ -0,0 +1,377 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandLineParser.h"
+
+#include <algorithm>
+#include <sstream>
+
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "util/StringUtils.h"
+#include "util/SubString.h"
+#include "PathConfig.h"
+
+namespace orxonox
+{
+    SetCommandLineOnlyArgument(optionsFile, "start.ini").shortcut("o");
+
+    /**
+    @brief
+        Parses a value string for a command line argument.
+        It simply uses convertValue(Output, Input) to do that.
+        Bools are treated specially. That is necessary
+        so that you can have simple command line switches.
+    */
+    void CommandLineArgument::parse(const std::string& value, bool bParsingFile)
+    {
+        if (bParsingFile && this->bCommandLineOnly_)
+            ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files.");
+        if (value_.getType() == MT_Type::Bool)
+        {
+            // simulate command line switch
+            bool temp;
+            if (convertValue(&temp, value))
+            {
+                this->bHasDefaultValue_ = false;
+                this->value_ = temp;
+            }
+            else if (value.empty())
+            {
+                this->bHasDefaultValue_ = false;
+                this->value_ = true;
+            }
+            else
+                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+        }
+        else
+        {
+            if (!value_.setValue(value))
+            {
+                value_.setValue(defaultValue_);
+                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+            }
+            else
+                this->bHasDefaultValue_ = false;
+        }
+    }
+
+
+    /**
+    @brief
+        Destructor destroys all CommandLineArguments with it.
+    */
+    CommandLineParser::~CommandLineParser()
+    {
+        CommandLineParser::destroyAllArguments();
+    }
+
+    /**
+    @brief
+        Returns a unique instance (Meyers Singleton).
+    */
+    CommandLineParser& CommandLineParser::_getInstance()
+    {
+        static CommandLineParser instance;
+        return instance;
+    }
+
+    /**
+    @brief
+        Destroys all command line arguments. This should be called at the end
+        of main. Do not use before that.
+    */
+    void CommandLineParser::destroyAllArguments()
+    {
+        for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin();
+            it != _getInstance().cmdLineArgs_.end(); ++it)
+            delete it->second;
+        _getInstance().cmdLineArgs_.clear();
+    }
+
+    /**
+    @brief
+        Reads the command line parses the values of each argument.
+        It is then stored in the corresponding CommandLineArgument.
+    @note
+        The reason that you have to provide the string to be parsed as
+        space separted list is because of argc and argv. If you only have
+        a whole string, simply use getAllStrings() of SubString.
+    @param arguments
+        Vector of space separated strings.
+    */
+    void CommandLineParser::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
+    {
+        try
+        {
+            // why this? See bFirstTimeParse_ declaration.
+            if (bFirstTimeParse_)
+            {
+                // first shove all the shortcuts in a map
+                for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+                    it != cmdLineArgs_.end(); ++it)
+                {
+                    OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
+                        "Cannot have two command line shortcut with the same name.");
+                    if (!it->second->getShortcut().empty())
+                        cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+                }
+                bFirstTimeParse_ = false;
+            }
+
+            std::string name;
+            std::string shortcut;
+            std::string value;
+            for (unsigned int i = 0; i < arguments.size(); ++i)
+            {
+                if (arguments[i].size() != 0)
+                {
+                    // sure not ""
+                    if (arguments[i][0] == '-')
+                    {
+                        // start with "-"
+                        if (arguments[i].size() == 1)
+                        {
+                            // argument[i] is "-", probably a minus sign
+                            value += "- ";
+                        }
+                        else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
+                        {
+                            // negative number as a value
+                            value += arguments[i] + ' ';
+                        }
+                        else
+                        {
+                            // can be shortcut or full name argument
+
+                            // save old data first
+                            value = removeTrailingWhitespaces(value);
+                            if (!name.empty())
+                            {
+                                checkFullArgument(name, value, bParsingFile);
+                                name.clear();
+                                assert(shortcut.empty());
+                            }
+                            else if (!shortcut.empty())
+                            {
+                                checkShortcut(shortcut, value, bParsingFile);
+                                shortcut.clear();
+                                assert(name.empty());
+                            }
+
+                            if (arguments[i][1] == '-')
+                            {
+                                // full name argument with "--name"
+                                name = arguments[i].substr(2);
+                            }
+                            else
+                            {
+                                // shortcut with "-s"
+                                shortcut = arguments[i].substr(1);
+                            }
+
+                            // reset value string
+                            value.clear();
+                        }
+                    }
+                    else
+                    {
+                        // value string
+
+                        if (name.empty() && shortcut.empty())
+                        {
+                            ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
+                        }
+
+                        // Concatenate strings as long as there's no new argument by "-" or "--"
+                        value += arguments[i] + ' ';
+                    }
+                }
+            }
+
+            // parse last argument
+            value = removeTrailingWhitespaces(value);
+            if (!name.empty())
+            {
+                checkFullArgument(name, value, bParsingFile);
+                assert(shortcut.empty());
+            }
+            else if (!shortcut.empty())
+            {
+                checkShortcut(shortcut, value, bParsingFile);
+                assert(name.empty());
+            }
+        }
+        catch (const ArgumentException& ex)
+        {
+            COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl;
+            COUT(0) << CommandLineParser::getUsageInformation() << std::endl;
+            throw GeneralException("");
+        }
+    }
+
+    /**
+    @brief
+        Parses an argument based on its full name.
+    @param name
+        Full name of the argument
+    @param value
+        String containing the value
+    */
+    void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
+        if (it == cmdLineArgs_.end())
+            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
+
+        it->second->parse(value, bParsingFile);
+    }
+
+    /**
+    @brief
+        Parses an argument based on its shortcut.
+    @param shortcut
+        Shotcut to the argument
+    @param value
+        String containing the value
+    */
+    void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
+        if (it == cmdLineArgsShortcut_.end())
+            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
+
+        it->second->parse(value, bParsingFile);
+    }
+
+    std::string CommandLineParser::getUsageInformation()
+    {
+        CommandLineParser& inst = _getInstance();
+        std::ostringstream infoStr;
+
+        // determine maximum name size
+        size_t maxNameSize = 0;
+        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
+            it != inst.cmdLineArgs_.end(); ++it)
+        {
+            maxNameSize = std::max(it->second->getName().size(), maxNameSize);
+        }
+
+        infoStr << std::endl;
+        infoStr << "Usage: orxonox [options]" << std::endl;
+        infoStr << "Available options:" << std::endl;
+
+        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
+            it != inst.cmdLineArgs_.end(); ++it)
+        {
+            if (!it->second->getShortcut().empty())
+                infoStr << " [-" << it->second->getShortcut() << "] ";
+            else
+                infoStr << "      ";
+            infoStr << "--" << it->second->getName() << ' ';
+            if (it->second->getValue().getType() != MT_Type::Bool)
+                infoStr << "ARG ";
+            else
+                infoStr << "    ";
+            // fill with the necessary amount of blanks
+            infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
+            infoStr << ": " << it->second->getInformation();
+            infoStr << std::endl;
+        }
+        return infoStr.str();
+    }
+
+    /**
+    @brief
+        Retrieves a CommandLineArgument.
+        The method throws an exception if 'name' was not found or the value could not be converted.
+    @note
+        You shold of course not call this method before the command line has been parsed.
+    */
+    const CommandLineArgument* CommandLineParser::getArgument(const std::string& name)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        if (it == _getInstance().cmdLineArgs_.end())
+        {
+            ThrowException(Argument, "Could find command line argument '" + name + "'.");
+        }
+        else
+        {
+            return it->second;
+        }
+    }
+
+    /**
+    @brief
+        Parses only the command line for CommandLineArguments.
+    */
+    void CommandLineParser::_parseCommandLine(const std::string& cmdLine)
+    {
+        std::vector<std::string> args;
+        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '(', ')', false);
+        for (unsigned i = 0; i < tokens.size(); ++i)
+            args.push_back(tokens[i]);
+        this->_parse(args, false);
+    }
+
+    /**
+    @brief
+        Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
+    */
+    void CommandLineParser::_parseFile()
+    {
+        const std::string& filename = CommandLineParser::getValue("optionsFile").getString();
+
+        // look for additional arguments in given file or start.ini as default
+        // They will not overwrite the arguments given directly
+        std::ifstream file;
+        file.open((PathConfig::getConfigPathString() + filename).c_str());
+        std::vector<std::string> args;
+        if (file)
+        {
+            while (!file.eof())
+            {
+                std::string line;
+                std::getline(file, line);
+                line = removeTrailingWhitespaces(line);
+                //if (!(line[0] == '#' || line[0] == '%'))
+                //{
+                SubString tokens(line, " ", " ", false, '\\', true, '"', true, '(', ')', false, '#');
+                for (unsigned i = 0; i < tokens.size(); ++i)
+                    if (tokens[i][0] != '#')
+                        args.push_back(tokens[i]);
+                //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
+                //}
+            }
+            file.close();
+        }
+
+        _parse(args, true);
+    }
+}
Index: code/branches/pickup2/src/libraries/core/CommandLineParser.h
===================================================================
--- code/branches/pickup2/src/libraries/core/CommandLineParser.h	(revision 6412)
+++ code/branches/pickup2/src/libraries/core/CommandLineParser.h	(revision 6412)
@@ -0,0 +1,223 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandLine_H__
+#define _CommandLine_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+#include "util/OrxAssert.h"
+#include "util/MultiType.h"
+
+#define SetCommandLineArgument(name, defaultValue) \
+    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLineParser::addArgument(#name, defaultValue, false)
+#define SetCommandLineOnlyArgument(name, defaultValue) \
+    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLineParser::addArgument(#name, defaultValue, true)
+#define SetCommandLineSwitch(name) \
+    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLineParser::addArgument(#name, false, false)
+#define SetCommandLineOnlySwitch(name) \
+    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLineParser::addArgument(#name, false, true)
+
+
+namespace orxonox
+{
+    /**
+    @brief
+        Container class for a command line argument of any type supported by MultiType.
+
+        Whenever you want to have an option specified by a command line switch,
+        you need to first define it with SetCommandLineArgument(name, defaultValue).
+        It is then added to a map and possibly changed when the command line is being parsed.
+        If the option was not given, you can detect this by asking hasDefaultValue().
+
+        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
+        Note the difference between "-" and "--"!
+        Also, there is no restriction to the number of strings you add after --name.
+        So "--startVector (2, 4, 5)" is perfectly legal.
+
+        Retrieving an argument is possible with the getCommandLineArgument function of the
+        CommandLineParser class. It is a Singleton, but the public interface is static.
+    */
+    class _CoreExport CommandLineArgument
+    {
+        friend class CommandLineParser;
+
+    public:
+        //! Tells whether the value has been changed by the command line.
+        bool hasDefaultValue() const { return bHasDefaultValue_; }
+        //! Returns the name of the argument.
+        const std::string& getName() const { return name_; }
+
+        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
+        //! Evaluates to "" if there is none.
+        const std::string& getShortcut() const { return shortcut_; }
+        //! Sets the shortcut for the argument
+        CommandLineArgument& shortcut(const std::string& shortcut)
+        { this->shortcut_ = shortcut; return *this; }
+
+        //! Returns the usage information
+        const std::string& getInformation() const { return this->usageInformation_; }
+        //! Sets the option information when displaying orxonox usage.
+        CommandLineArgument& information(const std::string& usage)
+        { this->usageInformation_ = usage; return *this; }
+
+        //! Returns the actual value of the argument. Can be equal to default value.
+        MultiType getValue() const { return value_; }
+        //! Returns the given default value as type T.
+        MultiType getDefaultValue() const { return defaultValue_; }
+
+    private:
+        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
+        CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
+            : bHasDefaultValue_(true)
+            , name_(name)
+            , value_(defaultValue)
+            , defaultValue_(defaultValue)
+            , bCommandLineOnly_(bCommandLineOnly)
+        { }
+
+        //! Undefined copy constructor
+        CommandLineArgument(const CommandLineArgument& instance);
+        ~CommandLineArgument() { }
+
+        //! Parses the value string of a command line argument.
+        void parse(const std::string& value, bool bParsingFile);
+
+        //! Tells whether the value has been changed by the command line.
+        bool bHasDefaultValue_;
+
+    private:
+        std::string name_;             //!< Name of the argument
+        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
+        std::string usageInformation_; //!< Tells about the usage of this parameter
+
+        MultiType   value_;            //!< The actual value
+        MultiType   defaultValue_;     //!< Default value. Should not be changed.
+        bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
+    };
+
+
+    /**
+    @brief
+        Global interface to command line options.
+        Allows to add and retrieve command line arguments. Also does the parsing.
+    @note
+        Internally it is a Singleton, but the public interface is static.
+    @see
+        CommandLineArgument
+    */
+    class _CoreExport CommandLineParser
+    {
+    public:
+
+        //! Parse redirection to internal member method.
+        static void parseCommandLine(const std::string& cmdLine) { _getInstance()._parseCommandLine(cmdLine); }
+        static void parseFile() { _getInstance()._parseFile(); }
+
+        static std::string getUsageInformation();
+
+        static const CommandLineArgument* getArgument(const std::string& name);
+        //! Writes the argument value in the given parameter.
+        template <class T>
+        static void getValue(const std::string& name, T* value)
+        { *value = (T)(getArgument(name)->getValue()); }
+        static MultiType getValue(const std::string& name)
+        { return getArgument(name)->getValue(); }
+        template <class T>
+        static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
+
+        static bool existsArgument(const std::string& name)
+        {
+            std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+            return !(it == _getInstance().cmdLineArgs_.end());
+        }
+
+        static void destroyAllArguments();
+
+    private:
+        //! Constructor initialises bFirstTimeParse_ with true.
+        CommandLineParser() : bFirstTimeParse_(true) { }
+        //! Undefined copy constructor
+        CommandLineParser(const CommandLineParser& instance);
+        ~CommandLineParser();
+
+        static CommandLineParser& _getInstance();
+
+        void _parseCommandLine(const std::string& cmdLine);
+        void _parseFile();
+        void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
+        void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
+        void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
+
+        /**
+            Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
+            So when we call parse() the first time, we need to create a map with all shortcuts since these
+            get added after addCommandLineArgument().
+        */
+        bool bFirstTimeParse_;
+
+        //! Holds all pointers to the arguments and serves as a search map by name.
+        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
+        //! Search map by shortcut for the arguments.
+        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
+    };
+
+    template <>
+    inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value)
+    {
+        *value = getArgument(name)->getValue().getString();
+    }
+
+    /**
+    @brief
+        Adds a new CommandLineArgument to the internal map.
+        Note that only such arguments are actually valid.
+    @param name
+        Name of the argument. Shortcut can be added later.
+    @param defaultValue
+        Default value that is used when argument was not given.
+    */
+    template <class T>
+    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
+    {
+        OrxAssert(!_getInstance().existsArgument(name),
+            "Cannot add a command line argument with name '" + name + "' twice.");
+        OrxAssert(MultiType(defaultValue).getType() != MT_Type::Bool || MultiType(defaultValue).getBool() != true,
+               "Boolean command line arguments with positive default values are not supported." << std::endl
+            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
+
+        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
+    }
+}
+
+#endif /* _CommandLine_H__ */
Index: code/branches/pickup2/src/libraries/core/ConfigFileManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/ConfigFileManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ConfigFileManager.cc	(revision 6412)
@@ -51,9 +51,14 @@
         if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
         {
-            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
-            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
-                return (*variable).second->set(value);
+            std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
+            if (variable != identifier->second->getLowercaseConfigValueMapEnd())
+                return variable->second->set(value);
         }
         return false;
+    }
+
+    std::string getConfig(const std::string& classname, const std::string& varname)
+    {
+        return ConfigFileManager::getInstance().getValue(ConfigFileType::Settings, classname, varname, "", true);
     }
 
@@ -63,7 +68,7 @@
         if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
         {
-            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
-            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
-                return (*variable).second->tset(value);
+            std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
+            if (variable != identifier->second->getLowercaseConfigValueMapEnd())
+                return variable->second->tset(value);
         }
         return false;
@@ -94,5 +99,5 @@
             this->value_ = value;
         else
-            this->value_ = "\"" + addSlashes(stripEnclosingQuotes(value)) + "\"";
+            this->value_ = '"' + addSlashes(stripEnclosingQuotes(value)) + '"';
     }
 
@@ -107,8 +112,8 @@
     std::string ConfigFileEntryValue::getFileEntry() const
     {
-        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
-            return (this->name_ + "=" + this->value_);
-        else
-            return (this->name_ + "=" + this->value_ + " " + this->additionalComment_);
+        if (this->additionalComment_.empty())
+            return (this->name_ + '=' + this->value_);
+        else
+            return (this->name_ + '=' + this->value_ + " " + this->additionalComment_);
     }
 
@@ -119,8 +124,8 @@
     std::string ConfigFileEntryVectorValue::getFileEntry() const
     {
-        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
-            return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]" + "=" + this->value_);
-        else
-            return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]=" + this->value_ + " " + this->additionalComment_);
+        if (this->additionalComment_.empty())
+            return (this->name_ + '[' + multi_cast<std::string>(this->index_) + ']' + '=' + this->value_);
+        else
+            return (this->name_ + '[' + multi_cast<std::string>(this->index_) + "]=" + this->value_ + ' ' + this->additionalComment_);
     }
 
@@ -166,8 +171,8 @@
     std::string ConfigFileSection::getFileEntry() const
     {
-        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
-            return ("[" + this->name_ + "]");
-        else
-            return ("[" + this->name_ + "] " + this->additionalComment_);
+        if (this->additionalComment_.empty())
+            return ('[' + this->name_ + ']');
+        else
+            return ('[' + this->name_ + "] " + this->additionalComment_);
     }
 
@@ -246,5 +251,5 @@
                 std::getline(file, line);
 
-                std::string temp = getStripped(line);
+                const std::string& temp = getStripped(line);
                 if (!isEmpty(temp) && !isComment(temp))
                 {
@@ -256,5 +261,5 @@
                     {
                         // New section
-                        std::string comment = line.substr(pos2 + 1);
+                        const std::string& comment = line.substr(pos2 + 1);
                         if (isComment(comment))
                             newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
@@ -288,5 +293,5 @@
                                 commentposition = getNextCommentPosition(line, commentposition + 1);
                             }
-                            std::string value = "", comment = "";
+                            std::string value, comment;
                             if (commentposition == std::string::npos)
                             {
@@ -377,5 +382,5 @@
         {
             std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName());
-            if (it2 != Identifier::getStringIdentifierMapEnd() && (*it2).second->hasConfigValues())
+            if (it2 != Identifier::getStringIdentifierMapEnd() && it2->second->hasConfigValues())
             {
                 // The section exists, delete comment
@@ -384,6 +389,6 @@
                 for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); )
                 {
-                    std::map<std::string, ConfigValueContainer*>::const_iterator it4 = (*it2).second->getConfigValueMap().find((*it3)->getName());
-                    if (it4 != (*it2).second->getConfigValueMapEnd())
+                    std::map<std::string, ConfigValueContainer*>::const_iterator it4 = it2->second->getConfigValueMap().find((*it3)->getName());
+                    if (it4 != it2->second->getConfigValueMapEnd())
                     {
                         // The config-value exists, delete comment
@@ -459,5 +464,5 @@
                 if (it->second->hasConfigValues())
                 {
-                    for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = (*it).second->getConfigValueMapBegin(); it2 != (*it).second->getConfigValueMapEnd(); ++it2)
+                    for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = it->second->getConfigValueMapBegin(); it2 != it->second->getConfigValueMapEnd(); ++it2)
                         it2->second->update();
 
Index: code/branches/pickup2/src/libraries/core/ConfigFileManager.h
===================================================================
--- code/branches/pickup2/src/libraries/core/ConfigFileManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ConfigFileManager.h	(revision 6412)
@@ -40,6 +40,8 @@
 #include "util/Singleton.h"
 
+// tolua_begin
 namespace orxonox
 {
+    // tolua_end
     // Use int as config file type to have an arbitrary number of files
     struct ConfigFileType : OrxEnum<ConfigFileType>
@@ -50,14 +52,16 @@
         static const int Settings            = 1;
         static const int JoyStickCalibration = 2;
+        static const int CommandHistory      = 3;
 
         static const int numberOfReservedTypes = 1024;
     };
 
-    bool config(const std::string& classname, const std::string& varname, const std::string& value);
-    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
-    void reloadConfig();
-    void saveConfig();
-    void cleanConfig();
-    void loadSettings(const std::string& filename);
+    _CoreExport bool config(const std::string& classname, const std::string& varname, const std::string& value); // tolua_export
+    _CoreExport std::string getConfig(const std::string& classname, const std::string& varname); // tolua_export
+    _CoreExport bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
+    _CoreExport void reloadConfig();
+    _CoreExport void saveConfig();
+    _CoreExport void cleanConfig();
+    _CoreExport void loadSettings(const std::string& filename);
 
 
@@ -85,5 +89,10 @@
     {
         public:
-            inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : name_(name), value_(value), bString_(bString), additionalComment_(additionalComment) {}
+            inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "")
+                : name_(name)
+                , value_(value)
+                , bString_(bString)
+                , additionalComment_(additionalComment)
+                {}
             inline virtual ~ConfigFileEntryValue() {}
 
@@ -169,5 +178,9 @@
 
         public:
-            inline ConfigFileSection(const std::string& name, const std::string& additionalComment = "") : name_(name), additionalComment_(additionalComment), bUpdated_(false) {}
+            inline ConfigFileSection(const std::string& name, const std::string& additionalComment = "")
+                : name_(name)
+                , additionalComment_(additionalComment)
+                , bUpdated_(false)
+                {}
             ~ConfigFileSection();
 
@@ -240,10 +253,10 @@
                 { this->getSection(section)->setValue(name, value, bString); this->save(); }
             inline std::string getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
-                { std::string output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
+                { const std::string& output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
 
             inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
                 { this->getSection(section)->setValue(name, index, value, bString); this->save(); }
             inline std::string getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
-                { std::string output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
+                { const std::string& output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
 
             inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
@@ -319,5 +332,5 @@
             static ConfigFileManager* singletonPtr_s;
     };
-}
+} // tolua_export
 
 #endif /* _ConfigFileManager_H__ */
Index: code/branches/pickup2/src/libraries/core/ConfigValueContainer.h
===================================================================
--- code/branches/pickup2/src/libraries/core/ConfigValueContainer.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ConfigValueContainer.h	(revision 6412)
@@ -121,6 +121,6 @@
                 @param defvalue The default-value
             */
-            template <class V>
-            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<V>& defvalue)
+            template <class D, class V>
+            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>& value)
             {
                 this->init(type, identifier, sectionname, varname);
@@ -146,11 +146,9 @@
                 if ((this->callback_ && object) || this->bContainerIsNew_)
                 {
-                    if (this->bContainerIsNew_)
-                        this->bContainerIsNew_ = false;
-
                     T temp = *value;
                     this->value_.getValue(value);
-                    if ((*value) != temp)
-                    {
+                    if (this->bContainerIsNew_ || (*value) != temp)
+                    {
+                        this->bContainerIsNew_ = false;
                         if (this->callback_ && object)
                             this->callback_->call(object);
Index: code/branches/pickup2/src/libraries/core/ConfigValueIncludes.h
===================================================================
--- code/branches/pickup2/src/libraries/core/ConfigValueIncludes.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ConfigValueIncludes.h	(revision 6412)
@@ -23,11 +23,12 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder (functions)
  *
  */
 
 /**
-    @file
-    @brief Definition of macros for config-values.
+@file
+@brief
+    Definition of macros and functions for config-values.
 */
 
@@ -41,74 +42,137 @@
 #include "ConfigFileManager.h"
 
+namespace orxonox
+{
+    /** Sets a runtime configurable value.
+        If the container for the value doesn't yet exist, a new one is created.
+        Also, the @a variable argument will be modified and set to the new value (default or from ini file).
+    @param object
+        Class instance that the config value should belong to (usually just 'this')
+    @param variable
+        Pointer to the variable where the value should be written to
+    @param type
+        Type of the config file, usually ConfigFileType::Settings
+    @param sectionName
+        Name of the section in the ini file (e.g. [MySection])
+    @param entryName
+        Name of the entry in the ini file (e.g. [MySection] myValue)
+    @param defaultValue
+        Value to be used if it cannot be read from the ini file
+    */
+    template <class T, class D, class V>
+    inline ConfigValueContainer& setConfigValueGeneric(T* object, V* variable, ConfigFileType type, const std::string& sectionName, const std::string& entryName, const D& defaultValue)
+    {
+        ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName);
+        if (!container)
+        {
+            container = new ConfigValueContainer(type, object->getIdentifier(), sectionName, entryName, defaultValue, *variable);
+            object->getIdentifier()->addConfigValueContainer(entryName, container);
+        }
+        return container->getValue(variable, object);
+    }
+}
 
-/**
-    @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file).
-    @param varname The name of the variable
-    @param defvalue The default-value of the variable
+/** Sets a runtime configurable value (simplified macro version of setConfigValueGeneric)
+    If the container for the value doesn't yet exist, a new one is created.
+    Also, the @a varname argument will be modified and set to the new value (default or from ini file).
+@param varname
+    Variable name as C++ identifier. It will be used as entry name and as variable pointer
+@param defaultValue
+    Value to be used if it cannot be read from the ini file
 */
-#define SetConfigValueGeneric(type, varname, defvalue) \
-    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
-    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
-    if (!container##varname) \
-    { \
-        container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, identifier##varname->getName(), #varname, defvalue, varname); \
-        identifier##varname->addConfigValueContainer(#varname, container##varname); \
-    } \
-    container##varname->getValue(&varname, this)
+#define SetConfigValue(varname, defaultValue) \
+    orxonox::setConfigValueGeneric(this, &varname, ConfigFileType::Settings, this->getIdentifier()->getName(), #varname, defaultValue)
 
-#define SetConfigValue(varname, defvalue) SetConfigValueGeneric(ConfigFileType::Settings, varname, defvalue)
+/** Sets a runtime configurable value (simplified macro version of setConfigValueGeneric)
+    If the container for the value doesn't yet exist, a new one is created.
+    Also, the @a varname argument will be modified and set to the new value (default or from ini file).
+@param variable
+    Variable name as C++ identifier.
+@param entryName
+    Name of the entry in the ini file (e.g. [MySection] myValue)
+@param defaultValue
+    Value to be used if it cannot be read from the ini file
+*/
+#define SetConfigValueAlias(variable, entryName, defaultValue) \
+    orxonox::setConfigValueGeneric(this, &variable, ConfigFileType::Settings, this->getIdentifier()->getName(), entryName, defaultValue)
 
 
-/**
-    @brief Assigns the vector-values, defined in the config-file, to the vector (or the default-value, if there are no entries in the file).
-    @param varname The name of the std::vector
-    @param defvalue The default-value
+namespace orxonox
+{
+    /** Resets a runtime configurable value to its default.
+        If the container for the value doesn't yet exist, a warning is displayed.
+        Also, the @a variable argument will be modified and set to the default value.
+    @param object
+        Class instance that the config value should belong to (usually just 'this')
+    @param variable
+        Pointer to the variable where the value should be written to
+    @param entryName
+        Name of the entry in the ini file (e.g. [MySection] myValue)
+    */
+    template <class T, class V>
+    inline void resetConfigValueGeneric(T* object, V* variable, const std::string& entryName)
+    {
+        ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName);
+        if (container)
+        {
+            container->reset();
+            container->getValue(variable, object);
+        }
+        else
+        {
+            COUT(2) << "Warning: Couldn't reset config-value '" << entryName << "' in class '"
+                    << object->getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl;
+        }
+    }
+}
+
+/** Resets a runtime configurable value to its default (simplified macro version of modifyConfigValueGeneric)
+    If the container for the value doesn't yet exist, a warning is displayed.
+    Also, the @a varname argument will be modified and set to the default value.
+@param varname
+    Variable name as C++ identifier. It will be used as entry name and as variable pointer
 */
-#define SetConfigValueVectorGeneric(type, varname, defvalue) \
-    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
-    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
-    if (!container##varname) \
-    { \
-        container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, identifier##varname->getName(), #varname, defvalue); \
-        identifier##varname->addConfigValueContainer(#varname, container##varname); \
-    } \
-    container##varname->getValue(&varname, this)
-
-#define SetConfigValueVector(varname, defvalue) SetConfigValueVectorGeneric(ConfigFileType::Settings, varname, defvalue)
+#define ResetConfigValue(varname) \
+    orxonox::resetConfigValueGeneric(this, &varname, #varname)
 
 
-/**
-    @brief Sets the variable and the config-file entry back to the previously defined default-value.
-    @param varname The name of the variable
+/** Modifies a runtime configurable value by using a modifier and some arguments.
+    If the container for the value doesn't yet exist, a warning is displayed.
+    Also, the @a variable argument will be modified and set to the current value.
+@param object
+    Class instance that the config value should belong to (usually just 'this')
+@param variable
+    Pointer to the variable where the value should be written to
+@param entryName
+    Name of the entry in the ini file (e.g. [MySection] myValue)
+@param modifier
+    On of these functions: set, tset, add, remove, reset, update
+@param ...
+    Arguments for the modifier function
 */
-#define ResetConfigValue(varname) \
-    orxonox::ConfigValueContainer* container##varname##reset = this->getIdentifier()->getConfigValueContainer(#varname); \
-    if (container##varname##reset) \
+#define ModifyConfigValueGeneric(object, variable, entryName, modifier, ...) \
+    if (orxonox::ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName)) \
     { \
-        container##varname##reset->reset(); \
-        container##varname##reset->getValue(&varname, this); \
+        container->modifier(__VA_ARGS__); \
+        container->getValue(variable, object); \
     } \
     else \
     { \
-        COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
+        COUT(2) << "Warning: Couln't modify config-value '" << entryName << "' in class '" \
+                << object->getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl; \
     }
 
-
-/**
-    @brief Modifies a config-value by using a modifier and some arguments.
-    @param varname The name of the config-value
-    @param modifier The name of the modifier: set, tset, add, remove, reset, update
+/** Modifies a runtime configurable value by using a modifier and some arguments.
+    If the container for the value doesn't yet exist, a warning is displayed.
+    Also, the @a varname argument will be modified and set to the current value.
+@param varname
+    Variable name as C++ identifier. It will be used as entry name and as variable pointer
+@param modifier
+    On of these functions: set, tset, add, remove, reset, update
+@param ...
+    Arguments for the modifier function
 */
 #define ModifyConfigValue(varname, modifier, ...) \
-    orxonox::ConfigValueContainer* container##varname##modify##modifier = this->getIdentifier()->getConfigValueContainer(#varname); \
-    if (container##varname##modify##modifier) \
-    { \
-        container##varname##modify##modifier->modifier(__VA_ARGS__); \
-        container##varname##modify##modifier->getValue(&varname, this); \
-    } \
-    else \
-    { \
-        COUT(2) << "Warning: Couln't modify config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
-    }
+    ModifyConfigValueGeneric(this, &varname, #varname, modifier, __VA_ARGS__)
 
 #endif /* _ConfigValueIncludes_H__ */
Index: code/branches/pickup2/src/libraries/core/ConsoleCommandCompilation.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/ConsoleCommandCompilation.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ConsoleCommandCompilation.cc	(revision 6412)
@@ -35,4 +35,5 @@
 #include "util/Debug.h"
 #include "util/ExprParser.h"
+#include "util/StringUtils.h"
 #include "ConsoleCommand.h"
 
@@ -86,5 +87,4 @@
     std::string echo(const std::string& text)
     {
-        std::cout << text << std::endl;
         return text;
     }
@@ -143,5 +143,5 @@
         }
 
-        std::string output = "";
+        std::string output;
         while (file.good() && !file.eof())
         {
@@ -159,5 +159,6 @@
     float calculate(const std::string& calculation)
     {
-        ExprParser expr(calculation);
+        ExprParser expr;
+        expr.parse(calculation);
         if (expr.getSuccess())
         {
@@ -166,7 +167,7 @@
                 COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;
             }
-            if (expr.getRemains() != "")
+            if (!expr.getRemains().empty())
             {
-                COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << "'" << std::endl;
+                COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;
             }
             return static_cast<float>(expr.getResult());
Index: code/branches/pickup2/src/libraries/core/Core.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Core.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Core.cc	(revision 6412)
@@ -51,8 +51,9 @@
 #include "util/Debug.h"
 #include "util/Exception.h"
+#include "util/Scope.h"
 #include "util/SignalHandler.h"
 #include "PathConfig.h"
 #include "CommandExecutor.h"
-#include "CommandLine.h"
+#include "CommandLineParser.h"
 #include "ConfigFileManager.h"
 #include "ConfigValueIncludes.h"
@@ -64,7 +65,7 @@
 #include "Identifier.h"
 #include "Language.h"
+#include "IOConsole.h"
 #include "LuaState.h"
 #include "ScopedSingletonManager.h"
-#include "Shell.h"
 #include "TclBind.h"
 #include "TclThreadManager.h"
@@ -78,112 +79,6 @@
     SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
 #ifdef ORXONOX_PLATFORM_WINDOWS
-    SetCommandLineArgument(limitToCPU, 0).information("Limits the program to one cpu/core (1, 2, 3, etc.). 0 turns it off (default)");
-#endif
-
-    /**
-    @brief
-        Helper class for the Core singleton: we cannot derive
-        Core from OrxonoxClass because we need to handle the Identifier
-        destruction in the Core destructor.
-    */
-    class CoreConfiguration : public OrxonoxClass
-    {
-    public:
-        CoreConfiguration()
-        {
-        }
-
-        void initialise()
-        {
-            RegisterRootObject(CoreConfiguration);
-            this->setConfigValues();
-        }
-
-        /**
-            @brief Function to collect the SetConfigValue-macro calls.
-        */
-        void setConfigValues()
-        {
-#ifdef NDEBUG
-            const unsigned int defaultLevelConsole = 1;
-            const unsigned int defaultLevelLogfile = 3;
-            const unsigned int defaultLevelShell   = 1;
-#else
-            const unsigned int defaultLevelConsole = 3;
-            const unsigned int defaultLevelLogfile = 4;
-            const unsigned int defaultLevelShell   = 3;
-#endif
-            SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
-                .description("The maximal level of debug output shown in the console")
-                .callback(this, &CoreConfiguration::debugLevelChanged);
-            SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
-                .description("The maximal level of debug output shown in the logfile")
-                .callback(this, &CoreConfiguration::debugLevelChanged);
-            SetConfigValue(softDebugLevelShell_, defaultLevelShell)
-                .description("The maximal level of debug output shown in the ingame shell")
-                .callback(this, &CoreConfiguration::debugLevelChanged);
-
-            SetConfigValue(language_, Language::getInstance().defaultLanguage_)
-                .description("The language of the ingame text")
-                .callback(this, &CoreConfiguration::languageChanged);
-            SetConfigValue(bInitializeRandomNumberGenerator_, true)
-                .description("If true, all random actions are different each time you start the game")
-                .callback(this, &CoreConfiguration::initializeRandomNumberGenerator);
-        }
-
-        /**
-            @brief Callback function if the debug level has changed.
-        */
-        void debugLevelChanged()
-        {
-            // softDebugLevel_ is the maximum of the 3 variables
-            this->softDebugLevel_ = this->softDebugLevelConsole_;
-            if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
-                this->softDebugLevel_ = this->softDebugLevelLogfile_;
-            if (this->softDebugLevelShell_ > this->softDebugLevel_)
-                this->softDebugLevel_ = this->softDebugLevelShell_;
-
-            OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
-            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
-            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
-            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
-        }
-
-        /**
-            @brief Callback function if the language has changed.
-        */
-        void languageChanged()
-        {
-            // Read the translation file after the language was configured
-            Language::getInstance().readTranslatedLanguageFile();
-        }
-
-        /**
-            @brief Sets the language in the config-file back to the default.
-        */
-        void resetLanguage()
-        {
-            ResetConfigValue(language_);
-        }
-
-        void initializeRandomNumberGenerator()
-        {
-            static bool bInitialized = false;
-            if (!bInitialized && this->bInitializeRandomNumberGenerator_)
-            {
-                srand(static_cast<unsigned int>(time(0)));
-                rand();
-                bInitialized = true;
-            }
-        }
-
-        int softDebugLevel_;                            //!< The debug level
-        int softDebugLevelConsole_;                     //!< The debug level for the console
-        int softDebugLevelLogfile_;                     //!< The debug level for the logfile
-        int softDebugLevelShell_;                       //!< The debug level for the ingame shell
-        std::string language_;                          //!< The language
-        bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
-    };
-
+    SetCommandLineArgument(limitToCPU, 1).information("Limits the program to one CPU/core (1, 2, 3, etc.). Default is the first core (faster than off)");
+#endif
 
     Core::Core(const std::string& cmdLine)
@@ -192,5 +87,4 @@
         // Cleanup guard for external console commands that don't belong to an Identifier
         , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)
-        , configuration_(new CoreConfiguration()) // Don't yet create config values!
         , bGraphicsLoaded_(false)
     {
@@ -216,19 +110,19 @@
 
         // Parse command line arguments AFTER the modules have been loaded (static code!)
-        CommandLine::parseCommandLine(cmdLine);
+        CommandLineParser::parseCommandLine(cmdLine);
 
         // Set configurable paths like log, config and media
         this->pathConfig_->setConfigurablePaths();
 
-        // create a signal handler (only active for linux)
+        // create a signal handler (only active for Linux)
         // This call is placed as soon as possible, but after the directories are set
         this->signalHandler_.reset(new SignalHandler());
         this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");
 
-        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
-        OutputHandler::getOutStream().setLogPath(PathConfig::getLogPathString());
+        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used
+        OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());
 
         // Parse additional options file now that we know its path
-        CommandLine::parseFile();
+        CommandLineParser::parseFile();
 
 #ifdef ORXONOX_PLATFORM_WINDOWS
@@ -236,5 +130,5 @@
         // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
         // the timer though).
-        int limitToCPU = CommandLine::getValue("limitToCPU");
+        int limitToCPU = CommandLineParser::getValue("limitToCPU");
         if (limitToCPU > 0)
             setThreadAffinity(static_cast<unsigned int>(limitToCPU));
@@ -244,15 +138,19 @@
         this->configFileManager_.reset(new ConfigFileManager());
         this->configFileManager_->setFilename(ConfigFileType::Settings,
-            CommandLine::getValue("settingsFile").getString());
+            CommandLineParser::getValue("settingsFile").getString());
 
         // Required as well for the config values
         this->languageInstance_.reset(new Language());
 
+        // Do this soon after the ConfigFileManager has been created to open up the
+        // possibility to configure everything below here
+        ClassIdentifier<Core>::getIdentifier("Core")->initialiseObject(this, "Core", true);
+        this->setConfigValues();
+
+        // create persistent io console
+        this->ioConsole_.reset(new IOConsole());
+
         // creates the class hierarchy for all classes with factories
         Identifier::createClassHierarchy();
-
-        // Do this soon after the ConfigFileManager has been created to open up the
-        // possibility to configure everything below here
-        this->configuration_->initialise();
 
         // Load OGRE excluding the renderer and the render window
@@ -262,7 +160,4 @@
         this->tclBind_.reset(new TclBind(PathConfig::getDataPathString()));
         this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter()));
-
-        // create a shell
-        this->shell_.reset(new Shell());
 
         // Create singletons that always exist (in other libraries)
@@ -276,4 +171,44 @@
     Core::~Core()
     {
+        // Remove us from the object lists again to avoid problems when destroying them
+        this->unregisterObject();
+    }
+
+    //! Function to collect the SetConfigValue-macro calls.
+    void Core::setConfigValues()
+    {
+#ifdef ORXONOX_RELEASE
+        const unsigned int defaultLevelLogFile = 3;
+#else
+        const unsigned int defaultLevelLogFile = 4;
+#endif
+        setConfigValueGeneric(this, &this->softDebugLevelLogFile_, ConfigFileType::Settings, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
+            .description("The maximum level of debug output shown in the log file");
+        OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);
+
+        SetConfigValue(language_, Language::getInstance().defaultLanguage_)
+            .description("The language of the in game text")
+            .callback(this, &Core::languageChanged);
+        SetConfigValue(bInitRandomNumberGenerator_, true)
+            .description("If true, all random actions are different each time you start the game")
+            .callback(this, &Core::initRandomNumberGenerator);
+    }
+
+    //! Callback function if the language has changed.
+    void Core::languageChanged()
+    {
+        // Read the translation file after the language was configured
+        Language::getInstance().readTranslatedLanguageFile();
+    }
+
+    void Core::initRandomNumberGenerator()
+    {
+        static bool bInitialized = false;
+        if (!bInitialized && this->bInitRandomNumberGenerator_)
+        {
+            srand(static_cast<unsigned int>(time(0)));
+            rand();
+            bInitialized = true;
+        }
     }
 
@@ -327,60 +262,8 @@
     }
 
-    /**
-        @brief Returns the softDebugLevel for the given device (returns a default-value if the class is right about to be created).
-        @param device The device
-        @return The softDebugLevel
-    */
-    /*static*/ int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
-    {
-        switch (device)
-        {
-        case OutputHandler::LD_All:
-            return Core::getInstance().configuration_->softDebugLevel_;
-        case OutputHandler::LD_Console:
-            return Core::getInstance().configuration_->softDebugLevelConsole_;
-        case OutputHandler::LD_Logfile:
-            return Core::getInstance().configuration_->softDebugLevelLogfile_;
-        case OutputHandler::LD_Shell:
-            return Core::getInstance().configuration_->softDebugLevelShell_;
-        default:
-            assert(0);
-            return 2;
-        }
-    }
-
-     /**
-        @brief Sets the softDebugLevel for the given device. Please use this only temporary and restore the value afterwards, as it overrides the configured value.
-        @param device The device
-        @param level The level
-    */
-    /*static*/ void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
-    {
-        if (device == OutputHandler::LD_All)
-            Core::getInstance().configuration_->softDebugLevel_ = level;
-        else if (device == OutputHandler::LD_Console)
-            Core::getInstance().configuration_->softDebugLevelConsole_ = level;
-        else if (device == OutputHandler::LD_Logfile)
-            Core::getInstance().configuration_->softDebugLevelLogfile_ = level;
-        else if (device == OutputHandler::LD_Shell)
-            Core::getInstance().configuration_->softDebugLevelShell_ = level;
-
-        OutputHandler::setSoftDebugLevel(device, level);
-    }
-
-    /**
-        @brief Returns the configured language.
-    */
-    /*static*/ const std::string& Core::getLanguage()
-    {
-        return Core::getInstance().configuration_->language_;
-    }
-
-    /**
-        @brief Sets the language in the config-file back to the default.
-    */
-    /*static*/ void Core::resetLanguage()
-    {
-        Core::getInstance().configuration_->resetLanguage();
+    //! Sets the language in the config-file back to the default.
+    void Core::resetLanguage()
+    {
+        ResetConfigValue(language_);
     }
 
@@ -433,25 +316,31 @@
     void Core::preUpdate(const Clock& time)
     {
-        // singletons from other libraries
-        ScopedSingletonManager::update<ScopeID::Root>(time);
+        // Update singletons before general ticking
+        ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
         if (this->bGraphicsLoaded_)
         {
-            // process input events
-            this->inputManager_->update(time);
-            // process gui events
-            this->guiManager_->update(time);
-            // graphics singletons from other libraries
-            ScopedSingletonManager::update<ScopeID::Graphics>(time);
-        }
-        // process thread commands
-        this->tclThreadManager_->update(time);
+            // Process input events
+            this->inputManager_->preUpdate(time);
+            // Update GUI
+            this->guiManager_->preUpdate(time);
+            // Update singletons before general ticking
+            ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
+        }
+        // Process console events and status line
+        this->ioConsole_->preUpdate(time);
+        // Process thread commands
+        this->tclThreadManager_->preUpdate(time);
     }
 
     void Core::postUpdate(const Clock& time)
     {
+        // Update singletons just before rendering
+        ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
         if (this->bGraphicsLoaded_)
         {
+            // Update singletons just before rendering
+            ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);
             // Render (doesn't throw)
-            this->graphicsManager_->update(time);
+            this->graphicsManager_->postUpdate(time);
         }
     }
Index: code/branches/pickup2/src/libraries/core/Core.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Core.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Core.h	(revision 6412)
@@ -35,13 +35,10 @@
 #include <cassert>
 #include <boost/scoped_ptr.hpp>
-#include "util/OutputHandler.h"
-#include "util/Scope.h"
 #include "util/ScopeGuard.h"
 #include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
 
 namespace orxonox
 {
-    class CoreConfiguration;
-
     /**
     @brief
@@ -50,5 +47,5 @@
         You should only create this singleton once because it destroys the identifiers!
     */
-    class _CoreExport Core : public Singleton<Core>
+    class _CoreExport Core : public Singleton<Core>, public OrxonoxClass
     {
         typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
@@ -69,11 +66,14 @@
             void setConfigValues();
 
-            static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
-            static void  setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
-            static const std::string& getLanguage();
-            static void  resetLanguage();
+            //! Returns the configured language.
+            const std::string& getLanguage()
+                { return this->language_; }
+            void resetLanguage();
 
         private:
             Core(const Core&); //!< Don't use (undefined symbol)
+
+            void languageChanged();
+            void initRandomNumberGenerator();
 
             void preUpdate(const Clock& time);
@@ -84,5 +84,5 @@
 
             void setThreadAffinity(int limitToCPU);
-
+            // MANAGED SINGLETONS/OBJECTS
             // Mind the order for the destruction!
             scoped_ptr<PathConfig>        pathConfig_;
@@ -93,17 +93,20 @@
             scoped_ptr<ConfigFileManager> configFileManager_;
             scoped_ptr<Language>          languageInstance_;
-            scoped_ptr<CoreConfiguration> configuration_;
+            scoped_ptr<IOConsole>         ioConsole_;
             scoped_ptr<TclBind>           tclBind_;
             scoped_ptr<TclThreadManager>  tclThreadManager_;
-            scoped_ptr<Shell>             shell_;
+            scoped_ptr<Scope<ScopeID::Root> >     rootScope_;
             // graphical
             scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
             scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
             scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
-            scoped_ptr<Scope<ScopeID::Root> >     rootScope_;
             scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;
 
             bool                          bGraphicsLoaded_;
-            static Core* singletonPtr_s;
+            int                           softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
+            std::string                   language_;                   //!< The language
+            bool                          bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
+
+            static Core*                  singletonPtr_s;
     };
 }
Index: code/branches/pickup2/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/pickup2/src/libraries/core/CorePrereqs.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/CorePrereqs.h	(revision 6412)
@@ -116,5 +116,5 @@
     class ClassTreeMaskObjectIterator;
     class CommandEvaluation;
-    class CommandLine;
+    class CommandLineParser;
     class CommandLineArgument;
     class ConfigFile;
@@ -148,4 +148,5 @@
     class GUIManager;
     class Identifier;
+    class IOConsole;
     class IRC;
     template <class T>
Index: code/branches/pickup2/src/libraries/core/DynLib.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/DynLib.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/DynLib.cc	(revision 6412)
@@ -70,5 +70,5 @@
         COUT(2) << "Loading module " << mName << std::endl;
 
-		std::string name = mName;
+        const std::string& name = mName;
 #ifdef ORXONOX_PLATFORM_LINUX
         // dlopen() does not add .so to the filename, like windows does for .dll
@@ -93,10 +93,10 @@
 
         if( DYNLIB_UNLOAD( m_hInst ) )
-		{
+        {
             ThrowException(
                 General,
                 "Could not unload dynamic library " + mName +
                 ".  System Error: " + dynlibError());
-		}
+        }
 
     }
@@ -132,5 +132,5 @@
         return std::string(mac_errorBundle());
 #else
-        return std::string("");
+        return "";
 #endif
     }
Index: code/branches/pickup2/src/libraries/core/DynLib.h
===================================================================
--- code/branches/pickup2/src/libraries/core/DynLib.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/DynLib.h	(revision 6412)
@@ -72,8 +72,8 @@
             Resource
     */
-	class _CoreExport DynLib
+    class _CoreExport DynLib
     {
-	protected:
-		std::string mName;
+    protected:
+        std::string mName;
         /// Gets the last loading error
         std::string dynlibError(void);
@@ -95,6 +95,6 @@
         */
         void unload();
-		/// Get the name of the library
-		const std::string& getName(void) const { return mName; }
+        /// Get the name of the library
+        const std::string& getName(void) const { return mName; }
 
         /**
Index: code/branches/pickup2/src/libraries/core/DynLibManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/DynLibManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/DynLibManager.cc	(revision 6412)
@@ -41,35 +41,35 @@
 
     //-----------------------------------------------------------------------
-	DynLibManager::DynLibManager()
-	{
-	}
-	//-----------------------------------------------------------------------
+    DynLibManager::DynLibManager()
+    {
+    }
+    //-----------------------------------------------------------------------
     DynLib* DynLibManager::load( const std::string& filename)
     {
-		DynLibList::iterator i = mLibList.find(filename);
-		if (i != mLibList.end())
-		{
-			return i->second;
-		}
-		else
-		{
-	        DynLib* pLib = new DynLib(filename);
-			pLib->load();
-        	mLibList[filename] = pLib;
-	        return pLib;
-		}
+        DynLibList::iterator i = mLibList.find(filename);
+        if (i != mLibList.end())
+        {
+            return i->second;
+        }
+        else
+        {
+            DynLib* pLib = new DynLib(filename);
+            pLib->load();
+            mLibList[filename] = pLib;
+            return pLib;
+        }
     }
-	//-----------------------------------------------------------------------
-	void DynLibManager::unload(DynLib* lib)
-	{
-		DynLibList::iterator i = mLibList.find(lib->getName());
-		if (i != mLibList.end())
-		{
-			mLibList.erase(i);
-		}
-		lib->unload();
-		delete lib;
-	}
-	//-----------------------------------------------------------------------
+    //-----------------------------------------------------------------------
+    void DynLibManager::unload(DynLib* lib)
+    {
+        DynLibList::iterator i = mLibList.find(lib->getName());
+        if (i != mLibList.end())
+        {
+            mLibList.erase(i);
+        }
+        lib->unload();
+        delete lib;
+    }
+    //-----------------------------------------------------------------------
     DynLibManager::~DynLibManager()
     {
Index: code/branches/pickup2/src/libraries/core/Event.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Event.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Event.cc	(revision 6412)
@@ -45,5 +45,5 @@
     /**
         @brief Processes an event (calls the set-function if the necessary conditions are met).
-        
+
         @param event     The fired event
         @param object    The object whose state is affected by the event (only needed for debug output)
@@ -53,5 +53,5 @@
         if (this->bProcessingEvent_)
         {
-            COUT(2) << "Warning: Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << "\"" << std::endl;
+            COUT(2) << "Warning: Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << '"' << std::endl;
             return;
         }
Index: code/branches/pickup2/src/libraries/core/Event.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Event.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Event.h	(revision 6412)
@@ -50,5 +50,5 @@
     /**
         @brief The EventState contains information about an event state.
-        
+
         An event state is a state of an object, which can be changed by events.
         Event states are changed through functions. Possible functions headers for set event states are:
@@ -56,8 +56,8 @@
          - boolean state:    function(bool state)
          - individual state: function(bool state, SomeClass originator)
-         
+
         Note that SomeClass may be any class deriving from BaseObject. You will not receive events from originators of other classes.
         The actual class for SomeClass must be specified as the second argument of the XMLPortEventState macro.
-        
+
         The this pointer of the affected object is hidden in the functors, because the events are processed in the BaseObject, but some
         statefunctions may be from child-classes.
@@ -70,5 +70,5 @@
 
             void process(const Event& event, BaseObject* object);
-            
+
             Functor* getFunctor() const
                 { return this->statefunction_; }
Index: code/branches/pickup2/src/libraries/core/EventIncludes.h
===================================================================
--- code/branches/pickup2/src/libraries/core/EventIncludes.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/EventIncludes.h	(revision 6412)
@@ -36,5 +36,5 @@
 /**
     @brief Defines a new event state (a state of the object which can be changed by events).
-    
+
     @param classname    The name of this class
     @param subclassname Usually BaseObject - if different, only instances of this class can send events to this object
@@ -66,12 +66,12 @@
 
 #define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \
-    static orxonox::ExecutorMember<classname>* xmlsetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + "(" + statename + ")")->setDefaultValue(1, statename); \
-    static orxonox::ExecutorMember<classname>* xmlgetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + "(" + statename + ")")->setDefaultValue(1, statename); \
+    static orxonox::ExecutorMember<classname>* xmlsetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \
+    static orxonox::ExecutorMember<classname>* xmlgetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \
     XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
-    
+
 
 /**
     @brief Defines a new event name for a class. Named events can only have names which were defined with this macro.
-    
+
     @param classname The name of the class
     @param name      The name of the event
@@ -82,7 +82,7 @@
 /**
     @brief This macro is needed to fire an event with this name. The event name must previously be declared with @ref CreateEventName.
-*/    
+*/
 #define FireEventName(classname, name) \
     eventname##classname##name
- 
+
 #endif /* _EventIncludes_H__ */
Index: code/branches/pickup2/src/libraries/core/Executor.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Executor.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Executor.cc	(revision 6412)
@@ -73,6 +73,5 @@
         {
             // only one param: check if there are params given, otherwise try to use default values
-            std::string temp = getStripped(params);
-            if ((temp != "") && (temp.size() != 0))
+            if (!getStripped(params).empty())
             {
                 param[0] = params;
Index: code/branches/pickup2/src/libraries/core/Executor.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Executor.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Executor.h	(revision 6412)
@@ -63,6 +63,6 @@
     else if (paramCount == 1) \
     { \
-        std::string temp = getStripped(params); \
-        if ((temp != "") && (temp.size() != 0)) \
+        const std::string& temp = getStripped(params); \
+        if (!temp.empty()) \
         { \
             COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \
@@ -187,5 +187,5 @@
                 { return this->functor_->getTypenameReturnvalue(); }
 
-            inline void setName(const std::string name)
+            inline void setName(const std::string& name)
                 { this->name_ = name; }
             inline const std::string& getName() const
Index: code/branches/pickup2/src/libraries/core/Functor.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Functor.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Functor.h	(revision 6412)
@@ -35,5 +35,4 @@
 #include "util/Debug.h"
 #include "util/MultiType.h"
-#include "util/StringUtils.h"
 
 namespace orxonox
Index: code/branches/pickup2/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/GUIManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/GUIManager.cc	(revision 6412)
@@ -40,4 +40,5 @@
 #include <CEGUIResourceProvider.h>
 #include <CEGUISystem.h>
+#include <CEGUIWindow.h>
 #include <ogreceguirenderer/OgreCEGUIRenderer.h>
 
@@ -50,7 +51,9 @@
 
 #include "util/Clock.h"
+#include "util/Convert.h"
 #include "util/Debug.h"
 #include "util/Exception.h"
 #include "util/OrxAssert.h"
+#include "ConsoleCommand.h"
 #include "Core.h"
 #include "LuaState.h"
@@ -60,4 +63,8 @@
 namespace orxonox
 {
+    static void key_esc()
+        { GUIManager::getInstance().keyESC(); }
+    SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
+
     class CEGUILogger : public CEGUI::DefaultLogger
     {
@@ -75,5 +82,5 @@
                 default: OrxAssert(false, "CEGUI log level out of range, inpect immediately!");
             }
-            OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+            OutputHandler::getOutStream(orxonoxLevel)
                 << "CEGUI: " << message << std::endl;
 
@@ -85,4 +92,7 @@
 
     GUIManager* GUIManager::singletonPtr_s = 0;
+
+    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
+    SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
 
     /**
@@ -102,4 +112,5 @@
         , resourceProvider_(0)
         , camera_(NULL)
+        , bShowIngameGUI_(false)
     {
         using namespace CEGUI;
@@ -114,4 +125,7 @@
         // setup scripting
         luaState_.reset(new LuaState());
+        rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua");
+        // This is necessary to ensure that input events also use the right resource info when triggering lua functions
+        luaState_->setDefaultResourceInfo(this->rootFileInfo_);
         scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState()));
 
@@ -121,5 +135,5 @@
         // set the log level according to ours (translate by subtracting 1)
         ceguiLogger->setLoggingLevel(
-            static_cast<LoggingLevel>(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));
+            static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1));
         this->ceguiLogger_ = ceguiLogger.release();
 
@@ -127,12 +141,11 @@
         guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get()));
 
-        // Initialise the basic lua code
-        rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI");
-        this->luaState_->doFile("InitialiseGUI.lua", "GUI", false);
+        // Initialise the basic Lua code
+        this->luaState_->doFile("InitialiseGUI.lua");
 
         // Align CEGUI mouse with OIS mouse
         guiSystem_->injectMousePosition(mousePosition.first, mousePosition.second);
 
-        // Hide the mouse cursor unless playing in fullscreen mode
+        // Hide the mouse cursor unless playing in full screen mode
         if (!bFullScreen)
             CEGUI::MouseCursor::getSingleton().hide();
@@ -157,5 +170,5 @@
         This time value is then used to provide a fluent animation of the GUI.
     */
-    void GUIManager::update(const Clock& time)
+    void GUIManager::preUpdate(const Clock& time)
     {
         assert(guiSystem_);
@@ -204,7 +217,37 @@
         For more details check out loadGUI_2.lua where the function presides.
     */
-    void GUIManager::showGUI(const std::string& name)
-    {
-        this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_);
+    /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor)
+    {
+        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ")");
+    }
+
+    /**
+    @brief
+        Hack-ish. Needed for GUIOverlay.
+    */
+    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious, bool showCursor)
+    {
+        this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
+    }
+
+    /**
+    @brief
+        Hides specified GUI.
+    @param name
+        The name of the GUI.
+    */
+    /*static*/ void GUIManager::hideGUI(const std::string& name)
+    {
+        GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")");
+    }
+
+    void GUIManager::keyESC()
+    {
+        this->executeCode("keyESC()");
+    }
+
+    void GUIManager::setBackground(const std::string& name)
+    {
+        this->executeCode("setBackground(\"" + name + "\")");
     }
 
@@ -280,5 +323,5 @@
         code of the mouse button as it is used by CEGUI
 
-        Simple convertion from mouse event code in Orxonox to the one used in CEGUI.
+        Simple conversion from mouse event code in Orxonox to the one used in CEGUI.
      */
     static inline CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button)
@@ -305,3 +348,8 @@
         }
     }
+
+    void GUIManager::subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function)
+    {
+        window->subscribeScriptedEvent(event, function);
+    }
 }
Index: code/branches/pickup2/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/pickup2/src/libraries/core/GUIManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/GUIManager.h	(revision 6412)
@@ -34,4 +34,5 @@
 
 #include <map>
+#include <set>
 #include <string>
 #include <CEGUIForwardRefs.h>
@@ -43,6 +44,6 @@
 #include "input/InputHandler.h"
 
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
     class PlayerInfo; // Forward declaration
 
@@ -58,6 +59,7 @@
         Those input events are then injected into CEGUI in Lua.
     */
-    class _CoreExport GUIManager : public Singleton<GUIManager>, public InputHandler
-    {
+    class _CoreExport GUIManager // tolua_export
+        : public Singleton<GUIManager>, public InputHandler
+    { // tolua_export
         friend class Singleton<GUIManager>;
     public:
@@ -65,8 +67,11 @@
         ~GUIManager();
 
-        void update(const Clock& time);
+        void preUpdate(const Clock& time);
 
-        void showGUI(const std::string& name);
-        void executeCode(const std::string& str);
+        static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true);
+        void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
+        static void hideGUI(const std::string& name);
+        void keyESC();
+        void setBackground(const std::string& name);
 
         void setCamera(Ogre::Camera* camera);
@@ -80,6 +85,11 @@
             { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; }
 
+        // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
+        static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
+
     private:
         GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class)
+
+        void executeCode(const std::string& str);
 
         // keyHandler functions
@@ -105,7 +115,8 @@
 
         static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
+        bool                                 bShowIngameGUI_;
 
-    };
-}
+    }; // tolua_export
+} // tolua_export
 
 #endif /* _GUIManager_H__ */
Index: code/branches/pickup2/src/libraries/core/Game.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Game.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Game.cc	(revision 6412)
@@ -44,5 +44,5 @@
 #include "util/Sleep.h"
 #include "util/SubString.h"
-#include "CommandLine.h"
+#include "CommandLineParser.h"
 #include "ConsoleCommand.h"
 #include "Core.h"
@@ -51,4 +51,5 @@
 #include "GameMode.h"
 #include "GameState.h"
+#include "GUIManager.h"
 
 namespace orxonox
@@ -67,9 +68,5 @@
     Game* Game::singletonPtr_s = 0;
 
-
-    /**
-    @brief
-        Represents one node of the game state tree.
-    */
+    //! Represents one node of the game state tree.
     struct GameStateTreeNode
     {
@@ -79,40 +76,4 @@
     };
 
-
-    /**
-    @brief
-        Another helper class for the Game singleton: we cannot derive
-        Game from OrxonoxClass because we need to handle the Identifier
-        destruction in the Core destructor.
-    */
-    class GameConfiguration : public OrxonoxClass
-    {
-    public:
-        GameConfiguration()
-        {
-            RegisterRootObject(GameConfiguration);
-            this->setConfigValues();
-        }
-
-        void setConfigValues()
-        {
-            SetConfigValue(statisticsRefreshCycle_, 250000)
-                .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
-            SetConfigValue(statisticsAvgLength_, 1000000)
-                .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
-            SetConfigValue(fpsLimit_, 50)
-                .description("Sets the desired framerate (0 for no limit).");
-        }
-
-        unsigned int statisticsRefreshCycle_;
-        unsigned int statisticsAvgLength_;
-        unsigned int fpsLimit_;
-    };
-
-
-    /**
-    @brief
-        Non-initialising constructor.
-    */
     Game::Game(const std::string& cmdLine)
         // Destroy factories before the Core!
@@ -128,4 +89,13 @@
 #endif
 
+        // reset statistics
+        this->statisticsStartTime_ = 0;
+        this->statisticsTickTimes_.clear();
+        this->periodTickTime_ = 0;
+        this->periodTime_ = 0;
+        this->avgFPS_ = 0.0f;
+        this->avgTickTime_ = 0.0f;
+        this->excessSleepTime_ = 0;
+
         // Create an empty root state
         this->declareGameState<GameState>("GameState", "emptyRootGameState", true, false);
@@ -136,4 +106,8 @@
         // Create the Core
         this->core_.reset(new Core(cmdLine));
+
+        // Do this after the Core creation!
+        ClassIdentifier<Game>::getIdentifier("Game")->initialiseObject(this, "Game", true);
+        this->setConfigValues();
 
         // After the core has been created, we can safely instantiate the GameStates that don't require graphics
@@ -150,7 +124,4 @@
         this->loadedTopStateNode_ = this->rootStateNode_;
         this->loadedStates_.push_back(this->getState(rootStateNode_->name_));
-
-        // Do this after the Core creation!
-        this->configuration_.reset(new GameConfiguration());
     }
 
@@ -161,4 +132,16 @@
     Game::~Game()
     {
+        // Remove us from the object lists again to avoid problems when destroying them
+        this->unregisterObject();
+    }
+
+    void Game::setConfigValues()
+    {
+        SetConfigValue(statisticsRefreshCycle_, 250000)
+            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+        SetConfigValue(statisticsAvgLength_, 1000000)
+            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
+        SetConfigValue(fpsLimit_, 50)
+            .description("Sets the desired frame rate (0 for no limit).");
     }
 
@@ -176,13 +159,4 @@
             COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl;
 
-        // reset statistics
-        this->statisticsStartTime_ = 0;
-        this->statisticsTickTimes_.clear();
-        this->periodTickTime_ = 0;
-        this->periodTime_ = 0;
-        this->avgFPS_ = 0.0f;
-        this->avgTickTime_ = 0.0f;
-        this->excessSleepTime_ = 0;
-
         // START GAME
         // first delta time should be about 0 seconds
@@ -204,5 +178,5 @@
             this->updateGameStateStack();
 
-            // Core preUpdate (doesn't throw)
+            // Core preUpdate
             try
                 { this->core_->preUpdate(*this->gameClock_); }
@@ -218,5 +192,5 @@
             this->updateGameStates();
 
-            // Core postUpdate (doesn't throw)
+            // Core postUpdate
             try
                 { this->core_->postUpdate(*this->gameClock_); }
@@ -232,5 +206,5 @@
             this->updateStatistics();
 
-            // Limit framerate
+            // Limit frame rate
             this->updateFPSLimiter();
         }
@@ -312,9 +286,9 @@
         this->statisticsTickTimes_.back().tickLength += currentRealTime - currentTime;
         this->periodTickTime_ += currentRealTime - currentTime;
-        if (this->periodTime_ > this->configuration_->statisticsRefreshCycle_)
+        if (this->periodTime_ > this->statisticsRefreshCycle_)
         {
             std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
             assert(it != this->statisticsTickTimes_.end());
-            int64_t lastTime = currentTime - this->configuration_->statisticsAvgLength_;
+            int64_t lastTime = currentTime - this->statisticsAvgLength_;
             if (static_cast<int64_t>(it->tickTime) < lastTime)
             {
@@ -330,8 +304,9 @@
 
             uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
-            this->avgFPS_ = static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
+            // Why minus 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too low
+            this->avgFPS_ = -1 + static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
             this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
 
-            this->periodTime_ -= this->configuration_->statisticsRefreshCycle_;
+            this->periodTime_ -= this->statisticsRefreshCycle_;
         }
     }
@@ -339,6 +314,5 @@
     void Game::updateFPSLimiter()
     {
-        // Why configuration_->fpsLimit_ - 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too high
-        uint32_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / (configuration_->fpsLimit_ - 1));
+        uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / fpsLimit_);
         uint64_t currentRealTime = gameClock_->getRealMicroseconds();
         while (currentRealTime < nextTime - minimumSleepTime_)
@@ -584,5 +558,5 @@
 
         shared_ptr<GameState> state = this->getState(name);
-        state->activate();
+        state->activateInternal();
         if (!this->loadedStates_.empty())
             this->loadedStates_.back()->activity_.topState = false;
@@ -603,5 +577,5 @@
             if (!this->loadedStates_.empty())
                 this->loadedStates_.back()->activity_.topState = true;
-            state->deactivate();
+            state->deactivateInternal();
         }
         catch (...)
Index: code/branches/pickup2/src/libraries/core/Game.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Game.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Game.h	(revision 6412)
@@ -50,4 +50,5 @@
 #include "util/ScopeGuard.h"
 #include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
 
 /**
@@ -58,8 +59,8 @@
 #define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
     static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
-
+// tolua_begin
 namespace orxonox
 {
-    class GameConfiguration;
+// tolua_end
 
     //! Helper object required before GameStates are being constructed
@@ -78,6 +79,9 @@
         You should only create this singleton once because it owns the Core class! (see remark there)
     */
-    class _CoreExport Game : public Singleton<Game>
-    {
+// tolua_begin
+    class _CoreExport Game
+// tolua_end
+        : public Singleton<Game>, public OrxonoxClass
+    { // tolua_export
         friend class Singleton<Game>;
         typedef std::vector<shared_ptr<GameState> > GameStateVector;
@@ -89,4 +93,6 @@
         ~Game();
 
+        void setConfigValues();
+
         void setStateHierarchy(const std::string& str);
         shared_ptr<GameState> getState(const std::string& name);
@@ -95,7 +101,9 @@
         void stop();
 
-        void requestState(const std::string& name);
-        void requestStates(const std::string& names);
-        void popState();
+        static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export
+
+        void requestState(const std::string& name); //tolua_export
+        void requestStates(const std::string& names); //tolua_export
+        void popState(); //tolua_export
 
         const Clock& getGameClock() { return *this->gameClock_; }
@@ -160,5 +168,4 @@
         scoped_ptr<Core>                   core_;
         ObjScopeGuard                      gsFactoryDestroyer_;
-        scoped_ptr<GameConfiguration>      configuration_;
 
         GameStateMap                       constructedStates_;
@@ -181,7 +188,12 @@
         unsigned int                       minimumSleepTime_;
 
+        // config values
+        unsigned int                       statisticsRefreshCycle_;
+        unsigned int                       statisticsAvgLength_;
+        unsigned int                       fpsLimit_;
+
         static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
         static Game* singletonPtr_s;        //!< Pointer to the Singleton
-    };
+    }; //tolua_export
 
     template <class T>
@@ -209,5 +221,5 @@
         return true;
     }
-}
+} //tolua_export
 
 #endif /* _Game_H__ */
Index: code/branches/pickup2/src/libraries/core/GameMode.h
===================================================================
--- code/branches/pickup2/src/libraries/core/GameMode.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/GameMode.h	(revision 6412)
@@ -37,11 +37,14 @@
 #include "CorePrereqs.h"
 
+// tolua_begin
 namespace orxonox
 {
     class _CoreExport GameMode
     {
+// tolua_end
         friend class Core;
 
         public:
+// tolua_begin
             static bool showsGraphics() { return bShowsGraphics_s; }
             static bool playsSound()    { return bPlaysSound_s; }
@@ -50,4 +53,5 @@
             static bool isStandalone()  { return bIsStandalone_s; }
             static bool isMaster()      { return bIsMaster_s; }
+// tolua_end
 
             static void setPlaysSound   (bool val) { bPlaysSound_s    = val; }
@@ -72,6 +76,6 @@
             static bool bIsStandalone_s;
             static bool bIsMaster_s;
-    };
-}
+    }; // tolua_export
+} // tolua_export
 
 #endif /* _GameMode_H__ */
Index: code/branches/pickup2/src/libraries/core/GameState.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/GameState.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/GameState.cc	(revision 6412)
@@ -83,5 +83,5 @@
         this->activity_.active = false;
         this->activity_.deactivating = true;
-        this->activate();
+        this->deactivate();
         this->activity_.deactivating = false;
         this->activity_.suspended = false;
Index: code/branches/pickup2/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/GraphicsManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/GraphicsManager.cc	(revision 6412)
@@ -98,11 +98,9 @@
         // Ogre setup procedure (creating Ogre::Root)
         this->loadOgreRoot();
-        // load all the required plugins for Ogre
-        this->loadOgrePlugins();
 
         // At first, add the root paths of the data directories as resource locations
-        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getDataPathString(), "FileSystem", "dataRoot", false);
+        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getDataPathString(), "FileSystem");
         // Load resources
-        resources_.reset(new XMLFile("resources.oxr", "dataRoot"));
+        resources_.reset(new XMLFile("DefaultResources.oxr"));
         resources_->setLuaSupport(false);
         Loader::open(resources_.get());
@@ -111,6 +109,6 @@
         if (PathConfig::isDevelopmentRun())
         {
-            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getExternalDataPathString(), "FileSystem", "externalDataRoot", false);
-            extResources_.reset(new XMLFile("resources.oxr", "externalDataRoot"));
+            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getExternalDataPathString(), "FileSystem");
+            extResources_.reset(new XMLFile("resources.oxr"));
             extResources_->setLuaSupport(false);
             Loader::open(extResources_.get());
@@ -171,4 +169,7 @@
         if (renderWindow_ != NULL)
             return;
+
+        // load all the required plugins for Ogre
+        this->loadOgrePlugins();
 
         this->loadRenderer();
@@ -207,5 +208,5 @@
                 shared_array<char> data(new char[output.str().size()]);
                 // Debug optimisations
-                const std::string outputStr = output.str();
+                const std::string& outputStr = output.str();
                 char* rawData = data.get();
                 for (unsigned i = 0; i < outputStr.size(); ++i)
@@ -237,10 +238,10 @@
         COUT(3) << "Setting up Ogre..." << std::endl;
 
-        if (ogreConfigFile_ == "")
+        if (ogreConfigFile_.empty())
         {
             COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
             ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
         }
-        if (ogreLogFile_ == "")
+        if (ogreLogFile_.empty())
         {
             COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
@@ -284,6 +285,6 @@
     {
         // just to make sure the next statement doesn't segfault
-        if (ogrePluginsDirectory_ == "")
-            ogrePluginsDirectory_ = ".";
+        if (ogrePluginsDirectory_.empty())
+            ogrePluginsDirectory_ = '.';
 
         boost::filesystem::path folder(ogrePluginsDirectory_);
@@ -340,5 +341,5 @@
         need the time. So we shouldn't run into problems.
     */
-    void GraphicsManager::update(const Clock& time)
+    void GraphicsManager::postUpdate(const Clock& time)
     {
         Ogre::FrameEvent evt;
@@ -394,20 +395,31 @@
     {
         int orxonoxLevel;
-        switch (lml)
-        {
-        case Ogre::LML_TRIVIAL:
-            orxonoxLevel = this->ogreLogLevelTrivial_;
-            break;
-        case Ogre::LML_NORMAL:
-            orxonoxLevel = this->ogreLogLevelNormal_;
-            break;
-        case Ogre::LML_CRITICAL:
-            orxonoxLevel = this->ogreLogLevelCritical_;
-            break;
-        default:
-            orxonoxLevel = 0;
-        }
-        OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
-            << "Ogre: " << message << std::endl;
+        std::string introduction;
+        // Do not show caught OGRE exceptions in front
+        if (message.find("EXCEPTION") != std::string::npos)
+        {
+            orxonoxLevel = OutputLevel::Debug;
+            introduction = "Ogre, caught exception: ";
+        }
+        else
+        {
+            switch (lml)
+            {
+            case Ogre::LML_TRIVIAL:
+                orxonoxLevel = this->ogreLogLevelTrivial_;
+                break;
+            case Ogre::LML_NORMAL:
+                orxonoxLevel = this->ogreLogLevelNormal_;
+                break;
+            case Ogre::LML_CRITICAL:
+                orxonoxLevel = this->ogreLogLevelCritical_;
+                break;
+            default:
+                orxonoxLevel = 0;
+            }
+            introduction = "Ogre: ";
+        }
+        OutputHandler::getOutStream(orxonoxLevel)
+            << introduction << message << std::endl;
     }
 
@@ -439,6 +451,5 @@
     {
         assert(this->renderWindow_);
-       
-        this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".jpg");
+        this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".png");
     }
 }
Index: code/branches/pickup2/src/libraries/core/GraphicsManager.h
===================================================================
--- code/branches/pickup2/src/libraries/core/GraphicsManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/GraphicsManager.h	(revision 6412)
@@ -63,5 +63,5 @@
         void setConfigValues();
 
-        void update(const Clock& time);
+        void postUpdate(const Clock& time);
 
         Ogre::Viewport* getViewport()         { return this->viewport_; }
@@ -106,11 +106,11 @@
 
         // config values
-        std::string         ogreConfigFile_;           //!< ogre config file name
+        std::string         ogreConfigFile_;           //!< ogre config filename
         std::string         ogrePluginsDirectory_;     //!< Directory where the Ogre plugins are located
         std::string         ogrePlugins_;              //!< Comma separated list of all plugins to load
-        std::string         ogreLogFile_;              //!< log file name for Ogre log messages
-        int                 ogreLogLevelTrivial_;      //!< Corresponding Orxonx debug level for LL_TRIVIAL
-        int                 ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
-        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
+        std::string         ogreLogFile_;              //!< log filename for Ogre log messages
+        int                 ogreLogLevelTrivial_;      //!< Corresponding Orxonox debug level for LL_TRIVIAL
+        int                 ogreLogLevelNormal_;       //!< Corresponding Orxonox debug level for LL_NORMAL
+        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonox debug level for LL_CRITICAL
 
         // console commands
Index: code/branches/pickup2/src/libraries/core/IOConsole.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/IOConsole.cc	(revision 6412)
+++ code/branches/pickup2/src/libraries/core/IOConsole.cc	(revision 6412)
@@ -0,0 +1,799 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "IOConsole.h"
+
+#include <iomanip>
+#include <iostream>
+
+#include "util/Clock.h"
+#include "util/Math.h"
+#include "core/Game.h"
+#include "core/input/InputBuffer.h"
+
+// ##########################
+// ###   Mutual methods   ###
+// ##########################
+namespace orxonox
+{
+    IOConsole* IOConsole::singletonPtr_s = NULL;
+
+    // ###############################
+    // ###  ShellListener methods  ###
+    // ###############################
+
+    //! Called if all output-lines have to be reprinted
+    void IOConsole::linesChanged()
+    {
+        // Method only gets called upon start to draw all the lines
+        // or when scrolling. But scrolling is disabled and the output
+        // is already in std::cout when we start the IOConsole
+    }
+
+    //! Called if a command is about to be executed
+    void IOConsole::executed()
+    {
+        this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);
+    }
+
+    //! Called if the console gets closed
+    void IOConsole::exit()
+    {
+        // Exit is not an option, just do nothing (Shell doesn't really exit too)
+    }
+}
+
+#ifdef ORXONOX_PLATFORM_UNIX
+// ###############################
+// ###   Unix Implementation   ###
+// ###############################
+
+#include <termios.h>
+#include <sys/ioctl.h>
+
+namespace orxonox
+{
+    namespace EscapeMode
+    {
+        enum Value
+        {
+            None,
+            First,
+            Second
+        };
+    }
+
+    IOConsole::IOConsole()
+        : shell_(new Shell("IOConsole", false))
+        , buffer_(shell_->getInputBuffer())
+        , cout_(std::cout.rdbuf())
+        , promptString_("orxonox # ")
+        , bStatusPrinted_(false)
+        , originalTerminalSettings_(0)
+    {
+        this->setTerminalMode();
+        this->shell_->registerListener(this);
+
+        // Manually set the widths of the individual status lines
+        this->statusLineWidths_.push_back(29);
+        this->statusLineMaxWidth_ = 29;
+
+        this->getTerminalSize();
+        this->lastTerminalWidth_ = this->terminalWidth_;
+        this->lastTerminalHeight_ = this->terminalHeight_;
+
+        // Disable standard std::cout logging
+        OutputHandler::getInstance().disableCout();
+        // Redirect std::cout to an ostringstream
+        // (Other part is in the initialiser list)
+        std::cout.rdbuf(this->origCout_.rdbuf());
+
+        // Make sure we make way for the status lines
+        this->preUpdate(Game::getInstance().getGameClock());
+    }
+
+    IOConsole::~IOConsole()
+    {
+        // Process output written to std::cout in the meantime
+        std::cout.flush();
+        if (!this->origCout_.str().empty())
+            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+        // Erase input and status lines
+        this->cout_ << "\033[1G\033[J";
+        // Move cursor to the bottom
+        this->cout_ << "\033[" << this->statusLineWidths_.size() << 'B';
+        // Scroll terminal to compensate for erased lines
+        this->cout_ << "\033[" << this->statusLineWidths_.size() << 'T';
+
+        resetTerminalMode();
+        this->shell_->destroy();
+
+        // Restore this->cout_ redirection
+        std::cout.rdbuf(this->cout_.rdbuf());
+        // Enable standard std::cout logging again
+        OutputHandler::getInstance().enableCout();
+    }
+
+    void IOConsole::preUpdate(const Clock& time)
+    {
+        unsigned char c;
+        std::string escapeSequence;
+        EscapeMode::Value escapeMode = EscapeMode::None;
+        while (std::cin.good())
+        {
+            c = std::cin.get();
+            if (!std::cin.good())
+                break;
+
+            if (escapeMode == EscapeMode::First && (c == '[' || c=='O') )
+                escapeMode = EscapeMode::Second;
+            // Get Alt+Tab combination when switching applications
+            else if (escapeMode == EscapeMode::First && c == '\t')
+            {
+                this->buffer_->buttonPressed(KeyEvent(KeyCode::Tab, '\t', KeyboardModifier::Alt));
+                escapeMode = EscapeMode::None;
+            }
+            else if (escapeMode == EscapeMode::Second)
+            {
+                escapeSequence += c;
+                escapeMode = EscapeMode::None;
+                if      (escapeSequence == "A")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Up,       0, 0));
+                else if (escapeSequence == "B")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Down,     0, 0));
+                else if (escapeSequence == "C")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Right,    0, 0));
+                else if (escapeSequence == "D")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Left,     0, 0));
+                else if (escapeSequence == "1~" || escapeSequence == "H")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Home,     0, 0));
+                else if (escapeSequence == "2~")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Insert,   0, 0));
+                else if (escapeSequence == "3~")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Delete,   0, 0));
+                else if (escapeSequence == "4~" || escapeSequence == "F")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::End,      0, 0));
+                else if (escapeSequence == "5~")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::PageUp,   0, 0));
+                else if (escapeSequence == "6~")
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::PageDown, 0, 0));
+                else
+                    // Waiting for sequence to complete
+                    // If the user presses ESC and then '[' or 'O' while the loop is not
+                    // running (for instance while loading), the whole sequence gets dropped
+                    escapeMode = EscapeMode::Second;
+            }
+            else // not in an escape sequence OR user might have pressed just ESC
+            {
+                if (escapeMode == EscapeMode::First)
+                {
+                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, c, 0));
+                    escapeMode = EscapeMode::None;
+                }
+                if (c == '\033')
+                {
+                    escapeMode = EscapeMode::First;
+                    escapeSequence.clear();
+                }
+                else
+                {
+                    KeyCode::ByEnum code;
+                    switch (c)
+                    {
+                    case '\n'  : case '\r': code = KeyCode::Return; break;
+                    case '\177': case '\b': code = KeyCode::Back;   break;
+                    case '\t'             : code = KeyCode::Tab;    break;
+                    default:
+                        // We don't encode the key code (would be a very large switch)
+                        // because the InputBuffer will only insert the text anyway
+                        // Replacement character is simply KeyCode::A
+                        code = KeyCode::A;
+                    }
+                    this->buffer_->buttonPressed(KeyEvent(code, c, 0));
+                }
+            }
+        }
+        // Reset error flags in std::cin
+        std::cin.clear();
+
+        // If there is still an escape key pending (escape key ONLY), then
+        // it sure isn't an escape sequence anymore
+        if (escapeMode == EscapeMode::First)
+            this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, '\033', 0));
+
+        // Determine terminal width and height
+        this->lastTerminalWidth_ = this->terminalWidth_;
+        this->lastTerminalHeight_ = this->terminalHeight_;
+        this->getTerminalSize();
+
+        int heightDiff = this->terminalHeight_ - this->lastTerminalHeight_;
+        if (this->bStatusPrinted_ && heightDiff < 0)
+        {
+            // Terminal width has shrunk. The cursor will still be on the input line,
+            // but that line might very well be the last
+            int newLines = std::min((int)this->statusLineWidths_.size(), -heightDiff);
+            // Scroll terminal to create new lines
+            this->cout_ << "\033[" << newLines << 'S';
+        }
+
+        if (!this->bStatusPrinted_ && this->willPrintStatusLines())
+        {
+            // Scroll console to make way for status lines
+            this->cout_ << "\033[" << this->statusLineWidths_.size() << 'S';
+            this->bStatusPrinted_ = true;
+        }
+
+        // We always assume that the cursor is on the input line.
+        // But we cannot always be sure about that, esp. if we scroll the console
+        this->cout_ << "\033[" << this->statusLineWidths_.size() << 'B';
+        this->cout_ << "\033[" << this->statusLineWidths_.size() << 'A';
+
+        // Erase status and input lines
+        this->cout_ << "\033[1G\033[J";
+        this->printInputLine();
+        this->printStatusLines();
+        this->cout_.flush();
+
+        // Process output written to std::cout
+        std::cout.flush();
+        if (!this->origCout_.str().empty())
+        {
+            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+            this->origCout_.str("");
+        }
+    }
+
+    void IOConsole::printOutputLine(const std::string& text, Shell::LineType type)
+    {
+/*
+        // Colour line
+        switch (type)
+        {
+        case Shell::None:    this->cout_ << "\033[37m"; break;
+        case Shell::Error:   this->cout_ << "\033[91m"; break;
+        case Shell::Warning: this->cout_ << "\033[31m"; break;
+        case Shell::Info:    this->cout_ << "\033[34m"; break;
+        case Shell::Debug:   this->cout_ << "\033[36m"; break;
+        case Shell::Verbose: this->cout_ << "\033[35m"; break;
+        case Shell::Ultra:   this->cout_ << "\033[37m"; break;
+        default: break;
+        }
+*/
+
+        // Print output line
+        this->cout_ << text;
+
+        // Reset colour to white
+//        this->cout_ << "\033[37m";
+    }
+
+    void IOConsole::printInputLine()
+    {
+        // Set cursor to the beginning of the line and erase the line
+        this->cout_ << "\033[1G\033[K";
+        // Indicate a command prompt
+        this->cout_ << this->promptString_;
+        // Save cursor position
+        this->cout_ << "\033[s";
+        // Print command line buffer
+        this->cout_ << this->shell_->getInput();
+        // Restore cursor position and move it to the right
+        this->cout_ << "\033[u";
+        if (this->buffer_->getCursorPosition() > 0)
+            this->cout_ << "\033[" << this->buffer_->getCursorPosition() << 'C';
+    }
+
+    void IOConsole::printStatusLines()
+    {
+        if (this->willPrintStatusLines())
+        {
+            // Save cursor position
+            this->cout_ << "\033[s";
+            // Move cursor down (don't create a new line here because the buffer might flush then!)
+            this->cout_ << "\033[1B\033[1G";
+            this->cout_ << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
+            this->cout_ <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
+            // Restore cursor position
+            this->cout_ << "\033[u";
+            this->bStatusPrinted_ = true;
+        }
+        else
+            this->bStatusPrinted_ = false;
+    }
+
+    void IOConsole::setTerminalMode()
+    {
+        termios new_settings;
+        this->originalTerminalSettings_ = new termios();
+
+        tcgetattr(0, this->originalTerminalSettings_);
+        new_settings = *this->originalTerminalSettings_;
+        new_settings.c_lflag &= ~(ICANON | ECHO);
+        //new_settings.c_lflag |= (ISIG | IEXTEN);
+        new_settings.c_cc[VTIME] = 0;
+        new_settings.c_cc[VMIN]  = 0;
+        tcsetattr(0, TCSANOW, &new_settings);
+        atexit(&IOConsole::resetTerminalMode);
+    }
+
+    /*static*/ void IOConsole::resetTerminalMode()
+    {
+        if(IOConsole::singletonPtr_s && IOConsole::singletonPtr_s->originalTerminalSettings_)
+        {
+            tcsetattr(0, TCSANOW, IOConsole::singletonPtr_s->originalTerminalSettings_);
+            delete IOConsole::singletonPtr_s->originalTerminalSettings_;
+            IOConsole::singletonPtr_s->originalTerminalSettings_ = 0;
+        }
+    }
+
+    void IOConsole::getTerminalSize()
+    {
+#ifdef TIOCGSIZE
+        struct ttysize win;
+        if (!ioctl(STDIN_FILENO, TIOCGSIZE, &win))
+        {
+            this->terminalWidth_  = win.ts_cols;
+            this->terminalHeight_ = win.ts_lines;
+            return;
+        }
+#elif defined TIOCGWINSZ
+        struct winsize win;
+        if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &win))
+        {
+            this->terminalWidth_  = win.ws_col;
+            this->terminalHeight_ = win.ws_row;
+            return;
+        }
+#else
+        const char* s = getenv("COLUMNS");
+        this->terminalWidth_  = s ? strtol(s, NULL, 10) : 80;
+        s = getenv("LINES");
+        this->terminalHeight_ = s ? strtol(s, NULL, 10) : 24;
+        return;
+#endif
+        this->terminalWidth_  = 80;
+        this->terminalHeight_ = 24;
+    }
+
+    inline bool IOConsole::willPrintStatusLines()
+    {
+        return !this->statusLineWidths_.empty()
+             && this->terminalWidth_  >= this->statusLineMaxWidth_
+             && this->terminalHeight_ >= this->minOutputLines_ + (int)this->statusLineWidths_.size();
+    }
+
+    // ###############################
+    // ###  ShellListener methods  ###
+    // ###############################
+
+    //! Called if only the last output-line has changed
+    void IOConsole::onlyLastLineChanged()
+    {
+        // Save cursor position and move it to the beginning of the first output line
+        this->cout_ << "\033[s\033[1A\033[1G";
+        // Erase the line
+        this->cout_ << "\033[K";
+        // Reprint the last output line
+        this->printOutputLine(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second);
+        // Restore cursor
+        this->cout_ << "\033[u";
+        this->cout_.flush();
+    }
+
+    //! Called if a new output-line was added
+    void IOConsole::lineAdded()
+    {
+        int newLines = this->shell_->getNewestLineIterator()->first.size() / this->terminalWidth_ + 1;
+        // Create new lines by scrolling the screen
+        this->cout_ << "\033[" << newLines << 'S';
+        // Move cursor to the beginning of the new (last) output line
+        this->cout_ << "\033[" << newLines << "A\033[1G";
+        // Erase screen from here
+        this->cout_ << "\033[J";
+        // Print the new output lines
+        for (int i = 0; i < newLines; ++i)
+        {
+            Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
+            this->printOutputLine(it->first.substr(i*this->terminalWidth_, this->terminalWidth_), it->second);
+        }
+        // Move cursor down
+        this->cout_ << "\033[1B\033[1G";
+        // Print status and input lines
+        this->printInputLine();
+        this->printStatusLines();
+        this->cout_.flush();
+    }
+
+    //! Called if the text in the input-line has changed
+    void IOConsole::inputChanged()
+    {
+        this->printInputLine();
+        this->cout_.flush();
+    }
+
+    //! Called if the position of the cursor in the input-line has changed
+    void IOConsole::cursorChanged()
+    {
+        this->printInputLine();
+        this->cout_.flush();
+    }
+}
+
+#elif defined(ORXONOX_PLATFORM_WINDOWS)
+// ##################################
+// ###   Windows Implementation   ###
+// ##################################
+
+#include <windows.h>
+
+namespace orxonox
+{
+    //! Redirects std::cout, creates the corresponding Shell and changes the terminal mode
+    IOConsole::IOConsole()
+        : shell_(new Shell("IOConsole", false))
+        , buffer_(shell_->getInputBuffer())
+        , cout_(std::cout.rdbuf())
+        , promptString_("orxonox # ")
+        , inputLineHeight_(1)
+        , statusLines_(1)
+        , lastOutputLineHeight_(0)
+    {
+        // Disable standard this->cout_ logging
+        OutputHandler::getInstance().disableCout();
+        // Redirect std::cout to an ostringstream
+        // (Other part is in the initialiser list)
+        std::cout.rdbuf(this->origCout_.rdbuf());
+
+        this->setTerminalMode();
+        CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
+        GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
+        this->terminalWidth_  = screenBufferInfo.dwSize.X;
+        this->terminalHeight_ = screenBufferInfo.dwSize.Y;
+        // Determines where we are in respect to output already written with std::cout
+        this->inputLineRow_ = screenBufferInfo.dwCursorPosition.Y;
+/*
+        this->lastTerminalWidth_  = this->terminalWidth_;
+        this->lastTerminalHeight_ = this->terminalHeight_;
+*/
+
+        // Cursor already at the end of the screen buffer?
+        // (assuming the current input line height is 1)
+        if (this->inputLineRow_ >= this->terminalHeight_ - this->statusLines_)
+            SetConsoleCursorPosition(this->stdOutHandle_, makeCOORD(0, this->terminalHeight_ - this->statusLines_));
+
+        // Prevent input line from overflowing
+        int maxInputLength = (this->terminalHeight_ - this->statusLines_) * this->terminalWidth_ - 1 - this->promptString_.size();
+        // Consider that the echo of a command might include the command plus some other characters (assumed max 80)
+        // Also put a minimum so the config file parser is not overwhelmed with the command history
+        this->buffer_->setMaxLength(std::min(8192, (maxInputLength - 80) / 2));
+
+        // Print input and status line and position cursor
+        this->inputChanged();
+        this->cursorChanged();
+        this->lastRefreshTime_ = Game::getInstance().getGameClock().getRealMicroseconds();
+        this->preUpdate(Game::getInstance().getGameClock());
+
+        this->shell_->registerListener(this);
+    }
+
+    //! Resets std::cout redirection and restores the terminal mode
+    IOConsole::~IOConsole()
+    {
+        // Process output written to std::cout in the meantime
+        std::cout.flush();
+        if (!this->origCout_.str().empty())
+            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+
+        this->shell_->unregisterListener(this);
+
+        // Erase input and status lines
+        COORD pos = {0, this->inputLineRow_};
+        this->writeText(std::string((this->inputLineHeight_ + this->statusLines_) * this->terminalWidth_, ' '), pos);
+        // Move cursor to the beginning of the line
+        SetConsoleCursorPosition(stdOutHandle_, pos);
+
+        // Restore this->cout_ redirection
+        std::cout.rdbuf(this->cout_.rdbuf());
+        // Enable standard this->cout_ logging again
+        OutputHandler::getInstance().enableCout();
+
+        resetTerminalMode();
+        this->shell_->destroy();
+    }
+
+    //! Processes the pending input key strokes, refreshes the status lines and handles std::cout (redirected)
+    void IOConsole::preUpdate(const Clock& time)
+    {
+        // Process input
+        while (true)
+        {
+            DWORD count;
+            INPUT_RECORD inrec;
+            PeekConsoleInput(this->stdInHandle_, &inrec, 1, &count);
+            if (count == 0)
+                break;
+            ReadConsoleInput(this->stdInHandle_, &inrec, 1, &count);
+            if (inrec.EventType == KEY_EVENT && inrec.Event.KeyEvent.bKeyDown)
+            {
+                // Process keyboard modifiers (Ctrl, Alt and Shift)
+                DWORD modifiersIn = inrec.Event.KeyEvent.dwControlKeyState;
+                int modifiersOut = 0;
+                if ((modifiersIn & (LEFT_ALT_PRESSED  | RIGHT_ALT_PRESSED))  != 0)
+                    modifiersOut |= KeyboardModifier::Alt;
+                if ((modifiersIn & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0)
+                    modifiersOut |= KeyboardModifier::Ctrl;
+                if ((modifiersIn & SHIFT_PRESSED) != 0)
+                    modifiersOut |= KeyboardModifier::Shift;
+
+                // ASCII character (0 for special keys)
+                char asciiChar = inrec.Event.KeyEvent.uChar.AsciiChar;
+
+                // Process special keys and if not found, use Key::A as dummy (InputBuffer uses the ASCII text anyway)
+                switch (inrec.Event.KeyEvent.wVirtualKeyCode)
+                {
+                case VK_BACK:   this->buffer_->buttonPressed(KeyEvent(KeyCode::Back,     asciiChar, modifiersOut)); break;
+                case VK_TAB:    this->buffer_->buttonPressed(KeyEvent(KeyCode::Tab,      asciiChar, modifiersOut)); break;
+                case VK_RETURN: this->buffer_->buttonPressed(KeyEvent(KeyCode::Return,   asciiChar, modifiersOut)); break;
+                case VK_PAUSE:  this->buffer_->buttonPressed(KeyEvent(KeyCode::Pause,    asciiChar, modifiersOut)); break;
+                case VK_ESCAPE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape,   asciiChar, modifiersOut)); break;
+                case VK_SPACE:  this->buffer_->buttonPressed(KeyEvent(KeyCode::Space,    asciiChar, modifiersOut)); break;
+                case VK_PRIOR:  this->buffer_->buttonPressed(KeyEvent(KeyCode::PageUp,   asciiChar, modifiersOut)); break;
+                case VK_NEXT:   this->buffer_->buttonPressed(KeyEvent(KeyCode::PageDown, asciiChar, modifiersOut)); break;
+                case VK_END:    this->buffer_->buttonPressed(KeyEvent(KeyCode::End,      asciiChar, modifiersOut)); break;
+                case VK_HOME:   this->buffer_->buttonPressed(KeyEvent(KeyCode::Home,     asciiChar, modifiersOut)); break;
+                case VK_LEFT:   this->buffer_->buttonPressed(KeyEvent(KeyCode::Left,     asciiChar, modifiersOut)); break;
+                case VK_UP:     this->buffer_->buttonPressed(KeyEvent(KeyCode::Up,       asciiChar, modifiersOut)); break;
+                case VK_RIGHT:  this->buffer_->buttonPressed(KeyEvent(KeyCode::Right,    asciiChar, modifiersOut)); break;
+                case VK_DOWN:   this->buffer_->buttonPressed(KeyEvent(KeyCode::Down,     asciiChar, modifiersOut)); break;
+                case VK_INSERT: this->buffer_->buttonPressed(KeyEvent(KeyCode::Insert,   asciiChar, modifiersOut)); break;
+                case VK_DELETE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Delete,   asciiChar, modifiersOut)); break;
+                default:        this->buffer_->buttonPressed(KeyEvent(KeyCode::A,        asciiChar, modifiersOut));
+                }
+            }
+        }
+
+        // TODO: Respect screen buffer size changes
+/*
+        // The user can manually adjust the screen buffer size on Windows
+        // And we don't want to screw the console because of that
+        this->lastTerminalWidth_ = this->terminalWidth_;
+        this->lastTerminalHeight_ = this->terminalHeight_;
+        this->getTerminalSize(); // Also sets this->inputLineRow_ according to the cursor position
+        // Is there still enough space below the cursor for the status line(s)?
+        if (this->inputLineRow_ >= this->terminalHeight_ - this->statusLines_)
+            this->moveCursor(0, -this->inputLineRow_ + this->terminalHeight_ - this->statusLines_ - 1);
+*/
+
+        // Refresh status line 5 times per second
+        if (time.getMicroseconds() > this->lastRefreshTime_ + 1000000)
+        {
+            this->printStatusLines();
+            this->lastRefreshTime_ = time.getMicroseconds();
+        }
+
+        // Process output written to std::cout
+        std::cout.flush();
+        if (!this->origCout_.str().empty())
+        {
+            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+            this->origCout_.str("");
+        }
+    }
+
+    //! Prints output text. Similar to writeText, but sets the colour according to the output level
+    void IOConsole::printOutputLine(const std::string& text, Shell::LineType type, const COORD& pos)
+    {
+        // Colour line
+        WORD colour = 0;
+        switch (type)
+        {
+        case Shell::Error:   colour = FOREGROUND_INTENSITY                    | FOREGROUND_RED; break;
+        case Shell::Warning: colour = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED; break;
+        case Shell::Info:
+        case Shell::Debug:
+        case Shell::Verbose:
+        case Shell::Ultra:   colour = FOREGROUND_INTENSITY                                     ; break;
+        case Shell::Command: colour =                        FOREGROUND_GREEN                  | FOREGROUND_BLUE; break;
+        case Shell::Hint:    colour =                        FOREGROUND_GREEN | FOREGROUND_RED                  ; break;
+        default:             colour =                        FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break;
+        }
+
+        // Print output line
+        this->writeText(text, pos, colour);
+    }
+
+    //! Prints all status lines with current content
+    void IOConsole::printStatusLines()
+    {
+        // Prepare text to be written
+        std::ostringstream oss;
+        oss << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
+        oss <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
+        // Clear rest of the line by inserting spaces
+        oss << std::string(this->terminalWidth_ - oss.str().size(), ' ');
+        this->writeText(oss.str(), makeCOORD(0, this->inputLineRow_ + this->inputLineHeight_), FOREGROUND_GREEN);
+    }
+
+    //! Changes the console parameters for unbuffered input
+    void IOConsole::setTerminalMode()
+    {
+        // Set the console mode to no-echo, raw input, and no window or mouse events
+        this->stdOutHandle_ = GetStdHandle(STD_OUTPUT_HANDLE);
+        this->stdInHandle_  = GetStdHandle(STD_INPUT_HANDLE);
+        if (this->stdInHandle_ == INVALID_HANDLE_VALUE
+            || !GetConsoleMode(this->stdInHandle_, &this->originalTerminalSettings_)
+            || !SetConsoleMode(this->stdInHandle_, 0))
+        {
+            COUT(1) << "Error: Could not set Windows console settings" << std::endl;
+            return;
+        }
+        FlushConsoleInputBuffer(this->stdInHandle_);
+    }
+
+    //! Restores the console parameters
+    void IOConsole::resetTerminalMode()
+    {
+        SetConsoleMode(this->stdInHandle_, this->originalTerminalSettings_);
+    }
+
+    //! Sets this->terminalWidth_ and this->terminalHeight_
+    void IOConsole::getTerminalSize()
+    {
+        CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
+        GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
+        this->terminalWidth_  = screenBufferInfo.dwSize.X;
+        this->terminalHeight_ = screenBufferInfo.dwSize.Y;
+    }
+
+    //! Writes arbitrary text to the console with a certain colour and screen buffer position
+    void IOConsole::writeText(const std::string& text, const COORD& coord, WORD attributes)
+    {
+        DWORD count;
+        WriteConsoleOutputCharacter(stdOutHandle_, text.c_str(), text.size(), coord, &count);
+        FillConsoleOutputAttribute(stdOutHandle_, attributes, text.size(), coord, &count);
+    }
+
+    /** Scrolls the console screen buffer to create empty lines above the input line.
+    @details
+        If the input and status lines are already at the bottom of the screen buffer
+        the whole output gets scrolled up. In the other case the input and status
+        lines get scrolled down.
+        In any case the status and input lines get scrolled down as far as possible.
+    @param lines
+        Number of lines to be inserted. Behavior for negative values is undefined.
+    */
+    void IOConsole::createNewOutputLines(int lines)
+    {
+        CHAR_INFO fillChar = {{' '}, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
+        // Lines to scroll input/status down (if possible)
+        int linesDown = clamp(terminalHeight_ - inputLineRow_ - inputLineHeight_ - statusLines_, 0, lines);
+        if (linesDown > 0)
+        {
+            // Scroll input and status lines down
+            SMALL_RECT oldRect = {0, this->inputLineRow_,
+                this->terminalWidth_ - 1, this->inputLineRow_ + this->inputLineHeight_ + this->statusLines_ - 1};
+            this->inputLineRow_ += linesDown;
+            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, this->inputLineRow_), &fillChar);
+            // Move cursor down to the new bottom so the user can see the status lines
+            COORD pos = {0, this->inputLineRow_ + this->inputLineHeight_ - 1 + this->statusLines_};
+            SetConsoleCursorPosition(stdOutHandle_, pos);
+            // Get cursor back to the right position
+            this->cursorChanged();
+        }
+        // Check how many lines we still have to scroll up the output
+        if (lines - linesDown > 0)
+        {
+            // Scroll output up
+            SMALL_RECT oldRect = {0, lines - linesDown, this->terminalWidth_ - 1, this->inputLineRow_ - 1};
+            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, 0), &fillChar);
+        }
+    }
+
+    // ###############################
+    // ###  ShellListener methods  ###
+    // ###############################
+
+    //! Called if the text in the input line has changed
+    void IOConsole::inputChanged()
+    {
+        int newInputLineLength = this->promptString_.size() + this->shell_->getInput().size();
+        int newInputLineHeight = 1 + newInputLineLength / this->terminalWidth_;
+        int newLines = newInputLineHeight - this->inputLineHeight_;
+        if (newLines > 0)
+        {
+            // Abuse this function to scroll the console
+            this->createNewOutputLines(newLines);
+            // Either Compensate for side effects (input/status lines scrolled down)
+            // or we have to do this anyway (output scrolled up)
+            this->inputLineRow_ -= newLines;
+        }
+        else if (newLines < 0)
+        {
+            // Scroll status lines up
+            int statusLineRow = this->inputLineRow_ + this->inputLineHeight_;
+            SMALL_RECT oldRect = {0, statusLineRow, this->terminalWidth_ - 1, statusLineRow + this->statusLines_};
+            CHAR_INFO fillChar = {{' '}, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
+            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, statusLineRow + newLines), &fillChar);
+            // Clear potential leftovers
+            if (-newLines - this->statusLines_ > 0)
+            {
+                COORD pos = {0, this->inputLineRow_ + newInputLineHeight + this->statusLines_};
+                this->writeText(std::string((-newLines - this->statusLines_) * this->terminalWidth_, ' '), pos);
+            }
+        }
+        this->inputLineHeight_ = newInputLineHeight;
+
+        // Print the whole line, including spaces that erase leftovers
+        std::string inputLine = this->promptString_ + this->shell_->getInput();
+        inputLine += std::string(this->terminalWidth_ - newInputLineLength % this->terminalWidth_, ' ');
+        this->writeText(inputLine, makeCOORD(0, this->inputLineRow_), FOREGROUND_GREEN | FOREGROUND_INTENSITY);
+        // If necessary, move cursor
+        if (newLines != 0)
+            this->cursorChanged();
+    }
+
+    //! Called if the position of the cursor in the input-line has changed
+    void IOConsole::cursorChanged()
+    {
+        int rawCursorPos = this->promptString_.size() + this->buffer_->getCursorPosition();
+        // Compensate for cursor further to the right than the terminal width
+        COORD pos;
+        pos.X = rawCursorPos % this->terminalWidth_;
+        pos.Y = this->inputLineRow_ + rawCursorPos / this->terminalWidth_;
+        SetConsoleCursorPosition(stdOutHandle_, pos);
+    }
+
+    //! Called if only the last output-line has changed
+    void IOConsole::onlyLastLineChanged()
+    {
+        int newLineHeight = 1 + this->shell_->getNewestLineIterator()->first.size() / this->terminalWidth_;
+        // Compute the number of new lines needed
+        int newLines = newLineHeight - this->lastOutputLineHeight_;
+        this->lastOutputLineHeight_ = newLineHeight;
+        // Scroll console if necessary
+        if (newLines > 0) // newLines < 0 is assumed impossible
+            this->createNewOutputLines(newLines);
+        Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
+        this->printOutputLine(it->first, it->second, makeCOORD(0, this->inputLineRow_ - newLineHeight));
+    }
+
+    //! Called if a new output line was added
+    void IOConsole::lineAdded()
+    {
+        Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
+        // Scroll console
+        this->lastOutputLineHeight_ = 1 + it->first.size() / this->terminalWidth_;
+        this->createNewOutputLines(this->lastOutputLineHeight_);
+        // Write the text
+        COORD pos = {0, this->inputLineRow_ - this->lastOutputLineHeight_};
+        this->printOutputLine(it->first, it->second, pos);
+    }
+}
+
+#endif /* ORXONOX_PLATFORM_UNIX */
Index: code/branches/pickup2/src/libraries/core/IOConsole.h
===================================================================
--- code/branches/pickup2/src/libraries/core/IOConsole.h	(revision 6412)
+++ code/branches/pickup2/src/libraries/core/IOConsole.h	(revision 6412)
@@ -0,0 +1,128 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _IOConsole_H__
+#define _IOConsole_H__
+
+#include "CorePrereqs.h"
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include "util/Singleton.h"
+#include "core/Shell.h"
+
+#ifdef ORXONOX_PLATFORM_UNIX
+struct termios;
+#elif defined(ORXONOX_PLATFORM_WINDOWS)
+#define WIN32_LEAN_AND_MEAN
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+#include <windows.h>
+#endif
+
+namespace orxonox
+{
+    class _CoreExport IOConsole : public Singleton<IOConsole>, public ShellListener
+    {
+        friend class Singleton<IOConsole>;
+
+    public:
+        IOConsole();
+        ~IOConsole();
+
+        void preUpdate(const Clock& time);
+
+    private:
+        void setTerminalMode();
+        void getTerminalSize();
+        void printStatusLines();
+        static int extractLogLevel(std::string* text);
+
+        // Methods from ShellListener
+        void linesChanged();
+        void onlyLastLineChanged();
+        void lineAdded();
+        void inputChanged();
+        void cursorChanged();
+        void executed();
+        void exit();
+
+        Shell*                  shell_;
+        InputBuffer*            buffer_;
+        std::ostream            cout_;
+        std::ostringstream      origCout_;
+        int                     terminalWidth_;
+        int                     terminalHeight_;
+        int                     lastTerminalWidth_;
+        int                     lastTerminalHeight_;
+        const std::string       promptString_;
+
+#ifdef ORXONOX_PLATFORM_UNIX
+        bool willPrintStatusLines();
+        void printInputLine();
+        void printOutputLine(const std::string& line, Shell::LineType type);
+        static void resetTerminalMode();
+
+        bool                    bPrintStatusLine_;
+        bool                    bStatusPrinted_;
+        std::vector<int>        statusLineWidths_;
+        int                     statusLineMaxWidth_;
+        static const int        minOutputLines_ = 3;
+        termios*                originalTerminalSettings_;
+
+#elif defined(ORXONOX_PLATFORM_WINDOWS)
+        void resetTerminalMode();
+        void moveCursor(int dx, int dy);
+        void writeText(const std::string& text, const COORD& pos, WORD attributes = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
+        void createNewOutputLines(int lines);
+        void printOutputLine(const std::string& line, Shell::LineType type, const COORD& pos);
+
+        static inline COORD makeCOORD(int x, int y)
+        {
+            COORD val = {x, y};
+            return val;
+        }
+
+        DWORD                   originalTerminalSettings_;
+        HANDLE                  stdInHandle_;
+        HANDLE                  stdOutHandle_;
+        int                     inputLineRow_;
+        int                     inputLineHeight_;
+        const int               statusLines_;
+        int                     lastOutputLineHeight_;
+        uint64_t                lastRefreshTime_;
+#endif
+
+        static IOConsole* singletonPtr_s;
+    };
+}
+
+#endif /* _IOConsole_H__ */
Index: code/branches/pickup2/src/libraries/core/IRC.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/IRC.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/IRC.cc	(revision 6412)
@@ -33,4 +33,5 @@
 #include "util/Convert.h"
 #include "util/Exception.h"
+#include "util/StringUtils.h"
 #include "ConsoleCommand.h"
 #include "CoreIncludes.h"
@@ -103,5 +104,5 @@
     void IRC::say(const std::string& message)
     {
-        if (IRC::eval("irk::say $conn #orxonox {" + message + "}"))
+        if (IRC::eval("irk::say $conn #orxonox {" + message + '}'))
             IRC::tcl_say(Tcl::object(), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
     }
@@ -109,5 +110,5 @@
     void IRC::msg(const std::string& channel, const std::string& message)
     {
-        if (IRC::eval("irk::say $conn " + channel + " {" + message + "}"))
+        if (IRC::eval("irk::say $conn " + channel + " {" + message + '}'))
             IRC::tcl_privmsg(Tcl::object(channel), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
     }
@@ -131,5 +132,5 @@
     void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
     {
-        COUT(0) << "IRC> * " << nick.get() << " " << stripEnclosingBraces(args.get()) << std::endl;
+        COUT(0) << "IRC> * " << nick.get() << ' ' << stripEnclosingBraces(args.get()) << std::endl;
     }
 
Index: code/branches/pickup2/src/libraries/core/Identifier.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Identifier.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Identifier.cc	(revision 6412)
@@ -410,5 +410,5 @@
         if (it != this->configValues_.end())
         {
-            COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl;
+            COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << '.' << std::endl;
             delete (it->second);
         }
@@ -458,5 +458,5 @@
         if (it != this->consoleCommands_.end())
         {
-            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;
+            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << '.' << std::endl;
             delete (it->second);
         }
@@ -524,5 +524,5 @@
         if (it != this->xmlportParamContainers_.end())
         {
-            COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl;
+            COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << '.' << std::endl;
             delete (it->second);
         }
@@ -555,5 +555,5 @@
         if (it != this->xmlportObjectContainers_.end())
         {
-            COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl;
+            COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << '.' << std::endl;
             delete (it->second);
         }
@@ -573,5 +573,5 @@
         {
             if (it != list.begin())
-                out << " ";
+                out << ' ';
             out << (*it)->getName();
         }
Index: code/branches/pickup2/src/libraries/core/Identifier.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Identifier.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Identifier.h	(revision 6412)
@@ -411,5 +411,5 @@
     {
         // Get the name of the class
-        std::string name = typeid(T).name();
+        const std::string& name = typeid(T).name();
 
         // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.
Index: code/branches/pickup2/src/libraries/core/Language.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Language.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Language.cc	(revision 6412)
@@ -62,5 +62,5 @@
     {
         // Check if the translation is more than just an empty string
-        if ((localisation != "") && (localisation.size() > 0))
+        if (!localisation.empty())
         {
             this->localisedEntry_ = localisation;
@@ -130,5 +130,5 @@
         }
 
-        COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << "!" << std::endl;
+        COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << '!' << std::endl;
         return it->second;
     }
@@ -199,5 +199,5 @@
         COUT(4) << "Read default language file." << std::endl;
 
-        std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
 
         // This creates the file if it's not existing
@@ -224,5 +224,5 @@
 
             // Check if the line is empty
-            if ((lineString != "") && (lineString.size() > 0))
+            if (!lineString.empty())
             {
                 size_t pos = lineString.find('=');
@@ -246,7 +246,7 @@
     void Language::readTranslatedLanguageFile()
     {
-        COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
-
-        std::string filepath = PathConfig::getConfigPathString() + getFilename(Core::getLanguage());
+        COUT(4) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << std::endl;
+
+        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getLanguage());
 
         // Open the file
@@ -257,7 +257,7 @@
         {
             COUT(1) << "An error occurred in Language.cc:" << std::endl;
-            COUT(1) << "Error: Couldn't open file " << getFilename(Core::getLanguage()) << " to read the translated language entries!" << std::endl;
-            Core::resetLanguage();
-            COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl;
+            COUT(1) << "Error: Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << std::endl;
+            Core::getInstance().resetLanguage();
+            COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << '.' << std::endl;
             return;
         }
@@ -270,5 +270,5 @@
 
             // Check if the line is empty
-            if ((lineString != "") && (lineString.size() > 0))
+            if (!lineString.empty())
             {
                 size_t pos = lineString.find('=');
@@ -287,5 +287,5 @@
                 else
                 {
-                    COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getLanguage()) << std::endl;
+                    COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << std::endl;
                 }
             }
@@ -302,5 +302,5 @@
         COUT(4) << "Language: Write default language file." << std::endl;
 
-        std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
 
         // Open the file
@@ -318,5 +318,5 @@
         for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
         {
-            file << (*it).second->getLabel() << "=" << (*it).second->getDefault() << std::endl;
+            file << it->second->getLabel() << '=' << it->second->getDefault() << std::endl;
         }
 
Index: code/branches/pickup2/src/libraries/core/Language.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Language.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Language.h	(revision 6412)
@@ -116,5 +116,5 @@
     {
         friend class Singleton<Language>;
-        friend class CoreConfiguration;
+        friend class Core;
 
         public:
Index: code/branches/pickup2/src/libraries/core/Loader.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Loader.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Loader.cc	(revision 6412)
@@ -80,5 +80,5 @@
         for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
         {
-            if ((*it).first == file)
+            if (it->first == file)
             {
                 Loader::files_s.erase(it);
@@ -92,5 +92,5 @@
         bool success = true;
         for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
-            if (!Loader::load((*it).first, (*it).second * mask))
+            if (!Loader::load(it->first, it->second * mask))
                 success = false;
 
@@ -128,10 +128,10 @@
             scoped_ptr<LuaState> luaState(new LuaState());
             luaState->setIncludeParser(&Loader::replaceLuaTags);
-            luaState->includeFile(file->getFilename(), file->getResourceGroup(), false);
+            luaState->includeFile(file->getFilename());
             xmlInput = luaState->getOutput().str();
         }
         else
         {
-            shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename(), file->getResourceGroup());
+            shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename());
             if (info == NULL)
             {
@@ -139,5 +139,5 @@
                 return false;
             }
-            xmlInput = Resource::open(file->getFilename(), file->getResourceGroup())->getAsString();
+            xmlInput = Resource::open(file->getFilename())->getAsString();
         }
 
@@ -165,5 +165,5 @@
             rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
 
-            COUT(0) << "Finished loading " << file->getFilename() << "." << std::endl;
+            COUT(0) << "Finished loading " << file->getFilename() << '.' << std::endl;
 
             COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString("  ") << std::endl;
@@ -174,5 +174,5 @@
         {
             COUT(1) << std::endl;
-            COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
+            COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
             COUT(1) << ex.what() << std::endl;
             COUT(1) << "Loading aborted." << std::endl;
@@ -182,5 +182,5 @@
         {
             COUT(1) << std::endl;
-            COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
+            COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
             COUT(1) << ex.what() << std::endl;
             COUT(1) << "Loading aborted." << std::endl;
@@ -190,5 +190,5 @@
         {
             COUT(1) << std::endl;
-            COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
+            COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
             COUT(1) << Exception::handleMessage() << std::endl;
             COUT(1) << "Loading aborted." << std::endl;
@@ -218,5 +218,5 @@
     std::string Loader::replaceLuaTags(const std::string& text)
     {
-        // chreate map with all Lua tags
+        // create map with all Lua tags
         std::map<size_t, bool> luaTags;
         {
@@ -291,5 +291,5 @@
             {
                 if (it != luaTags.end())
-                    end = (*(it++)).first;
+                    end = (it++)->first;
                 else
                     end = std::string::npos;
@@ -300,5 +300,5 @@
                 {
                     // count ['='[ and ]'='] and replace tags with print([[ and ]])
-                    std::string temp = text.substr(start, end - start);
+                    const std::string& temp = text.substr(start, end - start);
                     {
                     size_t pos = 0;
@@ -345,10 +345,10 @@
                         }
                     }
-                    std::string equalSigns = "";
+                    std::string equalSigns;
                     for(unsigned int i = 0; i < equalSignCounter; i++)
                     {
-                        equalSigns += "=";
+                        equalSigns += '=';
                     }
-                    output << "print([" + equalSigns + "[" + temp + "]" + equalSigns +"])";
+                    output << "print([" + equalSigns + '[' + temp + ']' + equalSigns +"])";
                     start = end + 5;
                 }
Index: code/branches/pickup2/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/LuaState.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/LuaState.cc	(revision 6412)
@@ -86,35 +86,24 @@
     }
 
-    shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
-    {
-        shared_ptr<ResourceInfo> sourceInfo;
-        if (resourceGroup != "NoResourceGroupProvided")
-            sourceInfo = Resource::getInfo(filename, resourceGroup);
-
-        // Continue search if not explicitely forbidden
-        if (bSearchOtherPaths && sourceInfo == NULL)
-        {
-            // Call might be relative to the file currently being processed
-            sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename, sourceFileInfo_->group);
-            if (sourceInfo == NULL)
-            {
-                // Maybe find something in the same group but in the root path
-                sourceInfo = Resource::getInfo(filename, sourceFileInfo_->group);
-            }
-        }
+    shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename)
+    {
+        // Look in the current directory first
+        shared_ptr<ResourceInfo> sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename);
+        // Continue search in root directories
+        if (sourceInfo == NULL && !sourceFileInfo_->path.empty())
+            sourceInfo = Resource::getInfo(filename);
         return sourceInfo;
     }
 
-    void LuaState::includeFile(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
-    {
-        shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
+    void LuaState::includeFile(const std::string& filename)
+    {
+        shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
         if (sourceInfo != NULL)
-            this->includeString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo);
-        else
-            COUT(2) << "LuaState: Cannot include file '" << filename << "' in resource group '"
-                    << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
-    }
-
-    void LuaState::includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
+            this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
+        else
+            COUT(2) << "LuaState: Cannot include file '" << filename << "'." << std::endl;
+    }
+
+    void LuaState::includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
     {
         // Parse string with provided include parser (otherwise don't preparse at all)
@@ -128,17 +117,16 @@
     }
 
-    void LuaState::doFile(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
-    {
-        shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
+    void LuaState::doFile(const std::string& filename)
+    {
+        shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
         if (sourceInfo != NULL)
-            this->doString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo);
-        else
-            COUT(2) << "LuaState: Cannot do file '" << filename << "' in resource group '"
-                << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
-    }
-
-    void LuaState::doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
-    {
-        // Save the oold source file info
+            this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
+        else
+            COUT(2) << "LuaState: Cannot do file '" << filename << "'." << std::endl;
+    }
+
+    void LuaState::doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
+    {
+        // Save the old source file info
         shared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_;
         // Only override if sourceFileInfo provides useful information
@@ -164,5 +152,5 @@
             if (sourceFileInfo != NULL)
                 origin = " originating from " + sourceFileInfo_->filename;
-            COUT(2) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
+            COUT(1) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
             // return value is nil
             lua_pushnil(luaState_);
@@ -182,10 +170,10 @@
     void LuaState::luaLog(unsigned int level, const std::string& message)
     {
-        OutputHandler::getOutStream().setOutputLevel(level) << message << std::endl;
-    }
-
-    bool LuaState::fileExists(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
-    {
-        shared_ptr<ResourceInfo> info =  this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
+        OutputHandler::getOutStream(level) << message << std::endl;
+    }
+
+    bool LuaState::fileExists(const std::string& filename)
+    {
+        shared_ptr<ResourceInfo> info = this->getFileInfo(filename);
         if (info == NULL)
             return false;
@@ -263,3 +251,15 @@
         }
     }
+
+
+    LuaFunctor::LuaFunctor(const std::string& code, LuaState* luaState)
+    {
+        this->code_ = code;
+        this->lua_ = luaState;
+    }
+
+    void LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    {
+        lua_->doString(this->code_);
+    }
 }
Index: code/branches/pickup2/src/libraries/core/LuaState.h
===================================================================
--- code/branches/pickup2/src/libraries/core/LuaState.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/LuaState.h	(revision 6412)
@@ -40,29 +40,44 @@
 
 #include "util/ScopeGuard.h"
+#include "core/Functor.h"
 #include "ToluaInterface.h"
 
-// tolua_begin
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
+    class Functor; // tolua_export
+
+    //! Functor subclass that simply executes code with 0 arguments.
+    class _CoreExport LuaFunctor : public Functor
+    {
+        public:
+            LuaFunctor(const std::string& code, LuaState* luaState);
+            void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);
+            void evaluateParam(unsigned int index, MultiType& param) const {}
+
+        private:
+            std::string code_;
+            LuaState*   lua_;
+    };
+
+
     /**
     @brief
         Representation of an interface to lua
     */
-    class _CoreExport LuaState
-    {
-// tolua_end
+    class _CoreExport LuaState // tolua_export
+    { // tolua_export
     public:
         LuaState();
         ~LuaState();
 
-        void doFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
-        void doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
+        void doFile(const std::string& filename); // tolua_export
+        void doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
 
-        void includeFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
-        void includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
+        void includeFile(const std::string& filename); // tolua_export
+        void includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
 
         void luaPrint(const std::string& str); // tolua_export
         void luaLog(unsigned int level, const std::string& message); // tolua_export
-        bool fileExists(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
+        bool fileExists(const std::string& filename); // tolua_export
 
         const std::stringstream& getOutput() const { return output_; }
@@ -72,4 +87,9 @@
         lua_State* getInternalLuaState() { return luaState_; }
 
+        void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
+        const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
+
+        Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
+
         static bool addToluaInterface(int (*function)(lua_State*), const std::string& name);
         static bool removeToluaInterface(const std::string& name);
@@ -78,5 +98,5 @@
 
     private:
-        shared_ptr<ResourceInfo> getFileInfo(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths);
+        shared_ptr<ResourceInfo> getFileInfo(const std::string& filename);
 
 #if LUA_VERSION_NUM != 501
Index: code/branches/pickup2/src/libraries/core/MemoryArchive.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/MemoryArchive.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/MemoryArchive.cc	(revision 6412)
@@ -64,5 +64,5 @@
     }
 
-    void MemoryArchive::findFiles(const String& pattern, bool bRecursive, 
+    void MemoryArchive::findFiles(const String& pattern, bool bRecursive,
         bool bDirs, StringVector* simpleList, FileInfoList* detailList)
     {
@@ -118,5 +118,5 @@
     }
 
-    FileInfoListPtr MemoryArchive::findFileInfo(const String& pattern, 
+    FileInfoListPtr MemoryArchive::findFileInfo(const String& pattern,
         bool recursive, bool dirs)
     {
Index: code/branches/pickup2/src/libraries/core/MemoryArchive.h
===================================================================
--- code/branches/pickup2/src/libraries/core/MemoryArchive.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/MemoryArchive.h	(revision 6412)
@@ -79,5 +79,5 @@
 
     private:
-        void findFiles(const Ogre::String& pattern, bool bRecursive, 
+        void findFiles(const Ogre::String& pattern, bool bRecursive,
             bool bDirs, Ogre::StringVector* simpleList, Ogre::FileInfoList* detailList);
 
Index: code/branches/pickup2/src/libraries/core/Namespace.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Namespace.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Namespace.cc	(revision 6412)
@@ -173,5 +173,5 @@
         {
             if (i > 0)
-                output += "\n";
+                output += '\n';
 
             output += (*it)->toString(indentation);
Index: code/branches/pickup2/src/libraries/core/NamespaceNode.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/NamespaceNode.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/NamespaceNode.cc	(revision 6412)
@@ -43,5 +43,5 @@
     {
         for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); )
-            delete ((*(it++)).second);
+            delete (it++)->second;
     }
 
@@ -50,5 +50,5 @@
         std::set<NamespaceNode*> nodes;
 
-        if ((name.size() == 0) || (name == ""))
+        if (name.empty())
         {
             nodes.insert(this);
@@ -89,5 +89,5 @@
                     it = this->subnodes_.insert(this->subnodes_.begin(), std::pair<std::string, NamespaceNode*>(firstPart, new NamespaceNode(firstPart, this)));
 
-                if ((*it).second->isHidden())
+                if (it->second->isHidden())
                 {
                     COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl;
@@ -96,5 +96,5 @@
                 else
                 {
-                    nodes = (*it).second->getNodeRelative(secondPart);
+                    nodes = it->second->getNodeRelative(secondPart);
                 }
             }
@@ -105,7 +105,7 @@
                 for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
                 {
-                    if ((*it).first.find(firstPart) == ((*it).first.size() - firstPart.size()))
+                    if (it->first.find(firstPart) == (it->first.size() - firstPart.size()))
                     {
-                        std::set<NamespaceNode*> temp2 = (*it).second->getNodeRelative(secondPart);
+                        std::set<NamespaceNode*> temp2 = it->second->getNodeRelative(secondPart);
                         nodes.insert(temp2.begin(), temp2.end());
                         bFoundMatchingNamespace = true;
@@ -133,5 +133,5 @@
         {
             for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
-                if ((*it).second->includes(ns))
+                if (it->second->includes(ns))
                     return true;
         }
@@ -154,8 +154,8 @@
                     output += ", ";
 
-                output += (*it).second->toString();
+                output += it->second->toString();
             }
 
-            output += ")";
+            output += ')';
         }
 
@@ -165,8 +165,8 @@
     std::string NamespaceNode::toString(const std::string& indentation) const
     {
-        std::string output = (indentation + this->name_ + "\n");
+        std::string output = (indentation + this->name_ + '\n');
 
         for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
-            output += (*it).second->toString(indentation + "  ");
+            output += it->second->toString(indentation + "  ");
 
         return output;
Index: code/branches/pickup2/src/libraries/core/OrxonoxClass.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/OrxonoxClass.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/OrxonoxClass.cc	(revision 6412)
@@ -34,4 +34,5 @@
 #include "OrxonoxClass.h"
 
+#include <cassert>
 #include "MetaObjectList.h"
 #include "Identifier.h"
@@ -48,4 +49,6 @@
         this->referenceCount_ = 0;
         this->requestedDestruction_ = false;
+        // Optimisation
+        this->objectPointers_.reserve(6);
     }
 
@@ -54,14 +57,14 @@
     {
 //        if (!this->requestedDestruction_)
-//            COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ")" << std::endl;
+//            COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << std::endl;
 
         assert(this->referenceCount_ <= 0);
 
-        delete this->metaList_;
+        this->unregisterObject();
 
         // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
         if (this->parents_)
             delete this->parents_;
-            
+
         // reset all weak pointers pointing to this object
         for (std::set<WeakPtr<OrxonoxClass>*>::iterator it = this->weakPointers_.begin(); it != this->weakPointers_.end(); )
@@ -72,7 +75,19 @@
     void OrxonoxClass::destroy()
     {
+        assert(this); // Just in case someone tries to delete a NULL pointer
         this->requestedDestruction_ = true;
         if (this->referenceCount_ == 0)
-            delete this;
+        {
+            this->preDestroy();
+            if (this->referenceCount_ == 0)
+                delete this;
+        }
+    }
+
+    void OrxonoxClass::unregisterObject()
+    {
+        if (this->metaList_)
+            delete this->metaList_;
+        this->metaList_ = 0;
     }
 
Index: code/branches/pickup2/src/libraries/core/OrxonoxClass.h
===================================================================
--- code/branches/pickup2/src/libraries/core/OrxonoxClass.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/OrxonoxClass.h	(revision 6412)
@@ -43,4 +43,11 @@
 #include <vector>
 
+/**
+@def CCOUT
+    Acts almost exactly like COUT(x), but prepends "ClassName: "
+*/
+#define CCOUT(level) \
+    COUT(level) << this->getIdentifier()->getName() << ": "
+
 namespace orxonox
 {
@@ -66,4 +73,5 @@
 
             void destroy();
+            void unregisterObject();
 
             /** @brief Function to collect the SetConfigValue-macro calls. */
@@ -127,4 +135,7 @@
             {   return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID);   }
 
+        protected:
+            virtual void preDestroy() {}
+
         private:
             /** @brief Increments the reference counter (for smart pointers). */
@@ -133,6 +144,10 @@
             /** @brief Decrements the reference counter (for smart pointers). */
             inline void decrementReferenceCount()
-                { --this->referenceCount_; if (this->referenceCount_ == 0 && this->requestedDestruction_) { delete this; } }
-                
+            {
+                --this->referenceCount_;
+                if (this->referenceCount_ == 0 && this->requestedDestruction_)
+                    this->destroy();
+            }
+
             /** @brief Register a weak pointer which points to this object. */
             template <class T>
Index: code/branches/pickup2/src/libraries/core/PathConfig.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/PathConfig.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/PathConfig.cc	(revision 6412)
@@ -54,5 +54,5 @@
 #include "util/Debug.h"
 #include "util/Exception.h"
-#include "CommandLine.h"
+#include "CommandLineParser.h"
 
 // Boost 1.36 has some issues with deprecated functions that have been omitted
@@ -186,6 +186,6 @@
 
             // Check for data path override by the command line
-            if (!CommandLine::getArgument("externalDataPath")->hasDefaultValue())
-                externalDataPath_ = CommandLine::getValue("externalDataPath").getString();
+            if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
+                externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();
             else
                 externalDataPath_ = specialConfig::externalDataDevDirectory;
@@ -224,7 +224,7 @@
 
         // Option to put all the config and log files in a separate folder
-        if (!CommandLine::getArgument("writingPathSuffix")->hasDefaultValue())
-        {
-            std::string directory(CommandLine::getValue("writingPathSuffix").getString());
+        if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
+        {
+            const std::string& directory(CommandLineParser::getValue("writingPathSuffix").getString());
             configPath_ = configPath_ / directory;
             logPath_    = logPath_    / directory;
@@ -256,10 +256,14 @@
 
         // We search for helper files with the following extension
-        std::string moduleextension = specialConfig::moduleExtension;
+        const std::string& moduleextension = specialConfig::moduleExtension;
         size_t moduleextensionlength = moduleextension.size();
 
         // Add that path to the PATH variable in case a module depends on another one
-        std::string pathVariable = getenv("PATH");
-        putenv(const_cast<char*>(("PATH=" + pathVariable + ";" + modulePath_.string()).c_str()));
+        std::string pathVariable(getenv("PATH"));
+        putenv(const_cast<char*>(("PATH=" + pathVariable + ';' + modulePath_.string()).c_str()));
+
+        // Make sure the path exists, otherwise don't load modules
+        if (!boost::filesystem::exists(modulePath_))
+            return modulePaths;
 
         boost::filesystem::directory_iterator file(modulePath_);
@@ -269,5 +273,5 @@
         while (file != end)
         {
-            std::string filename = file->BOOST_LEAF_FUNCTION();
+            const std::string& filename = file->BOOST_LEAF_FUNCTION();
 
             // Check if the file ends with the exension in question
@@ -277,5 +281,5 @@
                 {
                     // We've found a helper file
-                    std::string library = filename.substr(0, filename.size() - moduleextensionlength);
+                    const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);
                     modulePaths.push_back((modulePath_ / library).file_string());
                 }
Index: code/branches/pickup2/src/libraries/core/PathConfig.h
===================================================================
--- code/branches/pickup2/src/libraries/core/PathConfig.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/PathConfig.h	(revision 6412)
@@ -36,6 +36,8 @@
 #include "util/Singleton.h"
 
+//tolua_begin
 namespace orxonox
 {
+//tolua_end
     /**
     @brief
@@ -50,6 +52,7 @@
         - externalData only for development builds in the build tree
     */
-    class _CoreExport PathConfig : public Singleton<PathConfig>
-    {
+    class _CoreExport PathConfig //tolua_export
+        : public Singleton<PathConfig>
+    { //tolua_export
         friend class Singleton<PathConfig>;
         friend class Core;
@@ -99,5 +102,5 @@
             static std::string getExternalDataPathString();
             //! Returns the path to the config files as std::string
-            static std::string getConfigPathString();
+            static std::string getConfigPathString(); //tolua_export
             //! Returns the path to the log files as std::string
             static std::string getLogPathString();
@@ -132,6 +135,6 @@
             bool                     bDevRun_;               //!< True for runs in the build directory (not installed)
             static PathConfig* singletonPtr_s;
-    };
-}
+    }; //tolua_export
+} //tolua_export
 
 #endif /* _PathConfig_H__ */
Index: code/branches/pickup2/src/libraries/core/Resource.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Resource.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Resource.cc	(revision 6412)
@@ -34,21 +34,46 @@
     std::string Resource::DEFAULT_GROUP(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
 
-    DataStreamPtr Resource::open(const std::string& name, const std::string& group, bool bSearchGroupsIfNotFound)
+    DataStreamPtr Resource::open(const std::string& name)
     {
-        return Ogre::ResourceGroupManager::getSingleton().openResource(name, group, bSearchGroupsIfNotFound);
+        return Ogre::ResourceGroupManager::getSingleton().openResource(name,
+            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
     }
 
-    DataStreamListPtr Resource::openMulti(const std::string& pattern, const std::string& group)
+    DataStreamListPtr Resource::openMulti(const std::string& pattern)
     {
-        return Ogre::ResourceGroupManager::getSingleton().openResources(pattern, group);
+        DataStreamListPtr resources(new Ogre::DataStreamList());
+        const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+        for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)
+        {
+            DataStreamListPtr temp = Ogre::ResourceGroupManager::getSingleton().openResources(pattern, *it);
+            resources->insert(resources->end(), temp->begin(), temp->end());
+        }
+        return resources;
     }
 
-    bool Resource::exists(const std::string& name, const std::string& group)
+    bool Resource::exists(const std::string& name)
     {
-        return Ogre::ResourceGroupManager::getSingleton().resourceExists(group, name);
+        try
+        {
+            Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource(name);
+            return true;
+        }
+        catch (const Ogre::Exception&)
+        {
+            return false;
+        }
     }
 
-    shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name, const std::string& group)
+    shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name)
     {
+        std::string group;
+        try
+        {
+            group = Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource(name);
+        }
+        catch (const Ogre::Exception&)
+        {
+            return shared_ptr<ResourceInfo>();
+        }
         Ogre::FileInfoListPtr infos = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(group, name);
         for (std::vector<Ogre::FileInfo>::const_iterator it = infos->begin(); it != infos->end(); ++it)
@@ -67,3 +92,15 @@
         return shared_ptr<ResourceInfo>();
     }
+
+    StringVectorPtr Resource::findResourceNames(const std::string& pattern)
+    {
+        StringVectorPtr resourceNames(new Ogre::StringVector());
+        const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+        for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)
+        {
+            StringVectorPtr temp = Ogre::ResourceGroupManager::getSingleton().findResourceNames(*it, pattern);
+            resourceNames->insert(resourceNames->end(), temp->begin(), temp->end());
+        }
+        return resourceNames;
+    }
 }
Index: code/branches/pickup2/src/libraries/core/Resource.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Resource.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Resource.h	(revision 6412)
@@ -34,4 +34,5 @@
 #include <boost/shared_ptr.hpp>
 #include <OgreDataStream.h>
+#include <OgreStringVector.h>
 
 namespace orxonox
@@ -40,4 +41,6 @@
     using Ogre::DataStreamList;
     using Ogre::DataStreamListPtr;
+    using Ogre::StringVector;
+    using Ogre::StringVectorPtr;
 
     //! Stores basic information about a Resource from Ogre
@@ -56,7 +59,6 @@
     };
 
-    /**
-    @brief
-        Provides simple functions to easily access the Ogre::ResourceGroupManager
+    /** Provides simple functions to easily access the Ogre::ResourceGroupManager.
+        The wrapper functions also avoid having to deal with resource groups.
     */
     class _CoreExport Resource
@@ -72,22 +74,20 @@
             Even if resource locations are added recursively, you
             must provide a fully qualified name to this method.
-        @param groupName
-            The name of the resource group; this determines which 
-            locations are searched. 
-        @param searchGroupsIfNotFound
-            If true, if the resource is not found in 
-            the group specified, other groups will be searched.
         @return
             Shared pointer to data stream containing the data. Will be
             destroyed automatically when no longer referenced.
         */
-        static DataStreamPtr open(const std::string& name,
-            const std::string& group = Resource::DEFAULT_GROUP,
-            bool bSearchGroupsIfNotFound = false);
+        static DataStreamPtr open(const std::string& name);
+
+        //! Similar to open(string, string, bool), but with a fileInfo struct
+        static DataStreamPtr open(shared_ptr<ResourceInfo> fileInfo)
+        {
+            return open(fileInfo->filename);
+        }
 
         /**
         @brief
             Open all resources matching a given pattern (which can contain
-            the character '*' as a wildcard), and return a collection of 
+            the character '*' as a wildcard), and return a collection of
             DataStream objects on them.
         @param pattern
@@ -95,30 +95,32 @@
             added recursively, subdirectories will be searched too so this
             does not need to be fully qualified.
-        @param groupName
-            The resource group; this determines which locations
-            are searched.
         @return
             Shared pointer to a data stream list , will be
             destroyed automatically when no longer referenced
         */
-        static DataStreamListPtr openMulti(const std::string& pattern, const std::string& group = Resource::DEFAULT_GROUP);
+        static DataStreamListPtr openMulti(const std::string& pattern);
 
         /**
-            Find out if the named file exists in a group. 
+            Find out if the named file exists.
         @param filename
             Fully qualified name of the file to test for
-        @param group
-            The name of the resource group
         */
-        static bool exists(const std::string& name, const std::string& group = Resource::DEFAULT_GROUP);
+        static bool exists(const std::string& name);
 
         /**
-            Get struct with information about group, path and size.
+            Get struct with information about path and size.
         @param filename
             Fully qualified name of the file to test for
-        @param group
-            The name of the resource group
         */
-        static shared_ptr<ResourceInfo> getInfo(const std::string& name, const std::string& group = Resource::DEFAULT_GROUP);
+        static shared_ptr<ResourceInfo> getInfo(const std::string& name);
+
+        /**
+            Retrieves a list with all resources matching a certain pattern.
+        @param pattern
+            The pattern to look for. If resource locations have been
+            added recursively, subdirectories will be searched too so this
+            does not need to be fully qualified.
+        */
+        static StringVectorPtr findResourceNames(const std::string& pattern);
 
         //! Name of the default resource group (usually "General")
Index: code/branches/pickup2/src/libraries/core/ScopedSingletonManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/ScopedSingletonManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ScopedSingletonManager.cc	(revision 6412)
@@ -47,13 +47,3 @@
         getManagersByScope().insert(std::make_pair(manager->scope_, manager));
     }
-
-    /*static*/ void ScopedSingletonManager::removeManager(ScopedSingletonManager* manager)
-    {
-        getManagers().erase(getManagers().find(manager->className_));
-        for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(manager->scope_); it != getManagersByScope().upper_bound(manager->scope_);)
-            if (it->second == manager)
-                getManagersByScope().erase(it++);
-            else
-                ++it;
-    }
 }
Index: code/branches/pickup2/src/libraries/core/ScopedSingletonManager.h
===================================================================
--- code/branches/pickup2/src/libraries/core/ScopedSingletonManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ScopedSingletonManager.h	(revision 6412)
@@ -39,4 +39,5 @@
 
 #define ManageScopedSingleton(className, scope, allowedToFail) \
+    className* className::singletonPtr_s = NULL; \
     static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
 
@@ -52,14 +53,21 @@
             virtual ~ScopedSingletonManager() { }
             static void addManager(ScopedSingletonManager* manager);
-            static void removeManager(ScopedSingletonManager* manager);
 
             template<ScopeID::Value scope>
-            static void update(const Clock& time)
+            static void preUpdate(const Clock& time)
             {
                 assert(Scope<scope>::isActive());
                 for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
-                    it->second->update(time);
+                    it->second->preUpdate(time);
             }
-            virtual void update(const Clock& time) = 0;
+            virtual void preUpdate(const Clock& time) = 0;
+            template<ScopeID::Value scope>
+            static void postUpdate(const Clock& time)
+            {
+                assert(Scope<scope>::isActive());
+                for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
+                    it->second->postUpdate(time);
+            }
+            virtual void postUpdate(const Clock& time) = 0;
 
             static std::map<std::string, ScopedSingletonManager*>& getManagers();
@@ -86,6 +94,4 @@
         ~ClassScopedSingletonManager()
         {
-            //assert(singletonPtr_ == NULL); // Might get triggered in the SignalHandler
-            ScopedSingletonManager::removeManager(this);
         }
 
@@ -115,9 +121,17 @@
 
         //! Called every frame by the ScopedSingletonManager
-        void update(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            singletonPtr_->updateSingleton(time);
+        void preUpdate(const Clock& time)
+        {
+            assert(Scope<scope>::isActive());
+            // assuming T inherits Singleton<T>
+            singletonPtr_->preUpdateSingleton(time);
+        }
+
+        //! Called every frame by the ScopedSingletonManager
+        void postUpdate(const Clock& time)
+        {
+            assert(Scope<scope>::isActive());
+            // assuming T inherits Singleton<T>
+            singletonPtr_->postUpdateSingleton(time);
         }
 
@@ -140,6 +154,4 @@
         ~ClassScopedSingletonManager()
         {
-            assert(singletonPtr_ == NULL);
-            ScopedSingletonManager::removeManager(this);
         }
 
@@ -150,4 +162,6 @@
             try
                 { singletonPtr_ = new T(); }
+            catch (const InitialisationAbortedException& ex)
+                { COUT(3) << ex.getDescription() << std::endl; }
             catch (...)
                 { COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }
@@ -174,10 +188,19 @@
 
         //! Called every frame by the ScopedSingletonManager
-        void update(const Clock& time)
+        void preUpdate(const Clock& time)
         {
             assert(Scope<scope>::isActive());
             // assuming T inherits Singleton<T>
             if (singletonPtr_ != NULL)
-                singletonPtr_->updateSingleton(time);
+                singletonPtr_->preUpdateSingleton(time);
+        }
+
+        //! Called every frame by the ScopedSingletonManager
+        void postUpdate(const Clock& time)
+        {
+            assert(Scope<scope>::isActive());
+            // assuming T inherits Singleton<T>
+            if (singletonPtr_ != NULL)
+                singletonPtr_->postUpdateSingleton(time);
         }
 
Index: code/branches/pickup2/src/libraries/core/Shell.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Shell.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Shell.cc	(revision 6412)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -30,19 +30,13 @@
 
 #include "util/OutputHandler.h"
+#include "util/StringUtils.h"
+#include "util/SubString.h"
 #include "CommandExecutor.h"
 #include "CoreIncludes.h"
 #include "ConfigValueIncludes.h"
-#include "Core.h"
 #include "ConsoleCommand.h"
-
-#define SHELL_UPDATE_LISTENERS(function) \
-    for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) \
-        (*(it++))->function()
 
 namespace orxonox
 {
-    SetConsoleCommand(Shell, clearShell, true);
-    SetConsoleCommand(Shell, history, true);
-
     SetConsoleCommandShortcut(OutputHandler, log);
     SetConsoleCommandShortcut(OutputHandler, error);
@@ -51,11 +45,10 @@
     SetConsoleCommandShortcut(OutputHandler, debug);
 
-    Shell* Shell::singletonPtr_s = 0;
-
-    Shell::Shell()
-    {
-        int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell);
-        Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1);
-
+    Shell::Shell(const std::string& consoleName, bool bScrollable)
+        : OutputListener(consoleName)
+        , inputBuffer_(new InputBuffer())
+        , consoleName_(consoleName)
+        , bScrollable_(bScrollable)
+    {
         RegisterRootObject(Shell);
 
@@ -64,38 +57,54 @@
         this->historyPosition_ = 0;
         this->historyOffset_ = 0;
-        this->finishedLastLine_ = true;
-        this->bAddOutputLevel_ = false;
-
-        this->clearLines();
-
-        this->inputBuffer_ = new InputBuffer();
+        this->bFinishedLastLine_ = true;
+
+        this->clearOutput();
         this->configureInputBuffer();
 
-        this->outputBuffer_.registerListener(this);
-        OutputHandler::getOutStream().setOutputBuffer(&this->outputBuffer_);
-
-        // Get a config file for the command history
-        this->commandHistoryConfigFileType_ = ConfigFileManager::getInstance().getNewConfigFileType();
-        ConfigFileManager::getInstance().setFilename(this->commandHistoryConfigFileType_, "commandHistory.ini");
+        // Specify file for the command history
+        ConfigFileManager::getInstance().setFilename(ConfigFileType::CommandHistory, "commandHistory.ini");
+
+        // Use a stringstream object to buffer the output
+        this->outputStream_ = &this->outputBuffer_;
 
         this->setConfigValues();
 
-        Core::setSoftDebugLevel(OutputHandler::LD_Shell, level);
+        // Get the previous output and add it to the Shell
+        for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin();
+            it != OutputHandler::getInstance().getOutputVectorEnd(); ++it)
+        {
+            if (it->first <= this->getSoftDebugLevel())
+            {
+                this->outputBuffer_ << it->second;
+                this->outputChanged(it->first);
+            }
+        }
+
+        // Register the shell as output listener
+        OutputHandler::getInstance().registerOutputListener(this);
     }
 
     Shell::~Shell()
     {
-        OutputHandler::getOutStream().setOutputBuffer(0);
-        if (this->inputBuffer_)
-            this->inputBuffer_->destroy();
+        OutputHandler::getInstance().unregisterOutputListener(this);
+        this->inputBuffer_->destroy();
     }
 
     void Shell::setConfigValues()
     {
-        SetConfigValueGeneric(commandHistoryConfigFileType_, maxHistoryLength_, 100)
+        SetConfigValue(maxHistoryLength_, 100)
             .callback(this, &Shell::commandHistoryLengthChanged);
-        SetConfigValueGeneric(commandHistoryConfigFileType_, historyOffset_, 0)
+        SetConfigValue(historyOffset_, 0)
             .callback(this, &Shell::commandHistoryOffsetChanged);
-        SetConfigValueVectorGeneric(commandHistoryConfigFileType_, commandHistory_, std::vector<std::string>());
+        setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
+
+#ifdef ORXONOX_RELEASE
+        const unsigned int defaultLevel = 1;
+#else
+        const unsigned int defaultLevel = 3;
+#endif
+        setConfigValueGeneric(this, &softDebugLevel_, ConfigFileType::Settings, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
+            .description("The maximal level of debug output shown in the Shell");
+        this->setSoftDebugLevel(this->softDebugLevel_);
     }
 
@@ -121,24 +130,30 @@
     {
         this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
-        this->inputBuffer_->registerListener(this, &Shell::execute, '\r', false);
-        this->inputBuffer_->registerListener(this, &Shell::hintandcomplete, '\t', true);
-        this->inputBuffer_->registerListener(this, &Shell::backspace, '\b', true);
-        this->inputBuffer_->registerListener(this, &Shell::deletechar, KeyCode::Delete);
-        this->inputBuffer_->registerListener(this, &Shell::exit, static_cast<char>(27), true);
-        this->inputBuffer_->registerListener(this, &Shell::cursor_right, KeyCode::Right);
-        this->inputBuffer_->registerListener(this, &Shell::cursor_left, KeyCode::Left);
-        this->inputBuffer_->registerListener(this, &Shell::cursor_end, KeyCode::End);
-        this->inputBuffer_->registerListener(this, &Shell::cursor_home, KeyCode::Home);
-        this->inputBuffer_->registerListener(this, &Shell::history_up, KeyCode::Up);
-        this->inputBuffer_->registerListener(this, &Shell::history_down, KeyCode::Down);
-        this->inputBuffer_->registerListener(this, &Shell::scroll_up, KeyCode::PageUp);
-        this->inputBuffer_->registerListener(this, &Shell::scroll_down, KeyCode::PageDown);
-    }
-
-    void Shell::clearShell()
-    {
-        Shell::getInstance().clearLines();
-    }
-
+        this->inputBuffer_->registerListener(this, &Shell::execute,         '\r',   false);
+        this->inputBuffer_->registerListener(this, &Shell::execute,         '\n',   false);
+        this->inputBuffer_->registerListener(this, &Shell::hintAndComplete, '\t',   true);
+        this->inputBuffer_->registerListener(this, &Shell::backspace,       '\b',   true);
+        this->inputBuffer_->registerListener(this, &Shell::backspace,       '\177', true);
+        this->inputBuffer_->registerListener(this, &Shell::exit,            '\033', true); // escape
+        this->inputBuffer_->registerListener(this, &Shell::deleteChar,      KeyCode::Delete);
+        this->inputBuffer_->registerListener(this, &Shell::cursorRight,     KeyCode::Right);
+        this->inputBuffer_->registerListener(this, &Shell::cursorLeft,      KeyCode::Left);
+        this->inputBuffer_->registerListener(this, &Shell::cursorEnd,       KeyCode::End);
+        this->inputBuffer_->registerListener(this, &Shell::cursorHome,      KeyCode::Home);
+        this->inputBuffer_->registerListener(this, &Shell::historyUp,       KeyCode::Up);
+        this->inputBuffer_->registerListener(this, &Shell::historyDown,     KeyCode::Down);
+        if (this->bScrollable_)
+        {
+            this->inputBuffer_->registerListener(this, &Shell::scrollUp,    KeyCode::PageUp);
+            this->inputBuffer_->registerListener(this, &Shell::scrollDown,  KeyCode::PageDown);
+        }
+        else
+        {
+            this->inputBuffer_->registerListener(this, &Shell::historySearchUp,   KeyCode::PageUp);
+            this->inputBuffer_->registerListener(this, &Shell::historySearchDown, KeyCode::PageDown);
+        }
+    }
+
+    /*
     void Shell::history()
     {
@@ -146,12 +161,13 @@
 
         for (unsigned int i = instance.historyOffset_; i < instance.commandHistory_.size(); ++i)
-            instance.addLine(instance.commandHistory_[i], -1);
+            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
         for (unsigned int i =  0; i < instance.historyOffset_; ++i)
-            instance.addLine(instance.commandHistory_[i], -1);
-    }
+            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
+    }
+    */
 
     void Shell::registerListener(ShellListener* listener)
     {
-        this->listeners_.insert(this->listeners_.end(), listener);
+        this->listeners_.push_back(listener);
     }
 
@@ -161,5 +177,5 @@
         {
             if ((*it) == listener)
-                this->listeners_.erase(it++);
+                it = this->listeners_.erase(it);
             else
                 ++it;
@@ -170,47 +186,35 @@
     {
         this->inputBuffer_->setCursorPosition(cursor);
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::setInput(const std::string& input)
-    {
-        this->inputBuffer_->set(input);
-        this->inputChanged();
-    }
-
-    void Shell::addLine(const std::string& line, int level)
-    {
-        int original_level = OutputHandler::getOutStream().getOutputLevel();
-        OutputHandler::getOutStream().setOutputLevel(level);
-
-        if (!this->finishedLastLine_)
-            this->outputBuffer_ << std::endl;
-
-        this->outputBuffer_ << line << std::endl;
-        OutputHandler::getOutStream().setOutputLevel(original_level);
-    }
-
-    void Shell::clearLines()
-    {
-        this->lines_.clear();
-        this->scrollIterator_ = this->lines_.begin();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::addOutput(const std::string& text, LineType type)
+    {
+        this->outputBuffer_ << text;
+        this->outputChanged(type);
+    }
+
+    void Shell::clearOutput()
+    {
+        this->outputLines_.clear();
+        this->scrollIterator_ = this->outputLines_.begin();
 
         this->scrollPosition_ = 0;
-        this->finishedLastLine_ = true;
-
-        SHELL_UPDATE_LISTENERS(linesChanged);
-    }
-
-    std::list<std::string>::const_iterator Shell::getNewestLineIterator() const
+        this->bFinishedLastLine_ = true;
+
+        this->updateListeners<&ShellListener::linesChanged>();
+    }
+
+    Shell::LineList::const_iterator Shell::getNewestLineIterator() const
     {
         if (this->scrollPosition_)
             return this->scrollIterator_;
         else
-            return this->lines_.begin();
-    }
-
-    std::list<std::string>::const_iterator Shell::getEndIterator() const
-    {
-        return this->lines_.end();
+            return this->outputLines_.begin();
+    }
+
+    Shell::LineList::const_iterator Shell::getEndIterator() const
+    {
+        return this->outputLines_.end();
     }
 
@@ -222,5 +226,5 @@
     }
 
-    std::string Shell::getFromHistory() const
+    const std::string& Shell::getFromHistory() const
     {
         unsigned int index = mod(static_cast<int>(this->historyOffset_) - static_cast<int>(this->historyPosition_), this->maxHistoryLength_);
@@ -228,118 +232,150 @@
             return this->commandHistory_[index];
         else
-            return "";
-    }
-
-    void Shell::outputChanged()
-    {
-        std::string output;
-        bool newline;
+            return BLANKSTRING;
+    }
+
+    void Shell::outputChanged(int lineType)
+    {
+        bool newline = false;
         do
         {
-            newline = this->outputBuffer_.getLine(&output);
-
-            if (!newline && output == "")
+            std::string output;
+            std::getline(this->outputBuffer_, output);
+
+            bool eof = this->outputBuffer_.eof();
+            bool fail = this->outputBuffer_.fail();
+            if (eof)
+                this->outputBuffer_.flush();
+            if (eof || fail)
+                this->outputBuffer_.clear();
+            newline = (!eof && !fail);
+
+            if (!newline && output.empty())
                 break;
 
-            if (this->finishedLastLine_)
+            if (this->bFinishedLastLine_)
             {
-                if (this->bAddOutputLevel_)
-                    output.insert(0, 1, static_cast<char>(OutputHandler::getOutStream().getOutputLevel()));
-
-                this->lines_.insert(this->lines_.begin(), output);
+                this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
 
                 if (this->scrollPosition_)
                     this->scrollPosition_++;
                 else
-                    this->scrollIterator_ = this->lines_.begin();
-
-                this->finishedLastLine_ = newline;
+                    this->scrollIterator_ = this->outputLines_.begin();
+
+                this->bFinishedLastLine_ = newline;
 
                 if (!this->scrollPosition_)
-                {
-                    SHELL_UPDATE_LISTENERS(lineAdded);
-                }
+                    this->updateListeners<&ShellListener::lineAdded>();
             }
             else
             {
-                (*this->lines_.begin()) += output;
-                this->finishedLastLine_ = newline;
-                SHELL_UPDATE_LISTENERS(onlyLastLineChanged);
+                this->outputLines_.front().first += output;
+                this->bFinishedLastLine_ = newline;
+                this->updateListeners<&ShellListener::onlyLastLineChanged>();
             }
+            this->bFinishedLastLine_ = newline;
 
         } while (newline);
     }
 
-    void Shell::inputChanged()
-    {
-        SHELL_UPDATE_LISTENERS(inputChanged);
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::execute()
-    {
-        this->addToHistory(this->inputBuffer_->get());
-        this->addLine(this->inputBuffer_->get(), 0);
-
-        if (!CommandExecutor::execute(this->inputBuffer_->get()))
-            this->addLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", 1);
-
-        this->clear();
-    }
-
-    void Shell::hintandcomplete()
-    {
-        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
-        this->addLine(CommandExecutor::hint(this->inputBuffer_->get()), -1);
-
-        this->inputChanged();
-    }
-
-    void Shell::backspace()
-    {
-        this->inputBuffer_->removeBehindCursor();
-        SHELL_UPDATE_LISTENERS(inputChanged);
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::deletechar()
-    {
-        this->inputBuffer_->removeAtCursor();
-        SHELL_UPDATE_LISTENERS(inputChanged);
-    }
-
-    void Shell::clear()
+    void Shell::clearInput()
     {
         this->inputBuffer_->clear();
         this->historyPosition_ = 0;
-        SHELL_UPDATE_LISTENERS(inputChanged);
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::cursor_right()
+        this->updateListeners<&ShellListener::inputChanged>();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::setPromptPrefix(const std::string& str)
+    {
+    }
+
+
+    // ##########################################
+    // ###   InputBuffer callback functions   ###
+    // ##########################################
+
+    void Shell::inputChanged()
+    {
+        this->updateListeners<&ShellListener::inputChanged>();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::execute()
+    {
+        this->addToHistory(this->inputBuffer_->get());
+        this->updateListeners<&ShellListener::executed>();
+
+        if (!CommandExecutor::execute(this->inputBuffer_->get()))
+        {
+            this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl;
+            this->outputChanged(Error);
+        }
+
+        this->clearInput();
+    }
+
+    void Shell::hintAndComplete()
+    {
+        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
+        this->outputBuffer_ << CommandExecutor::hint(this->inputBuffer_->get()) << std::endl;
+        this->outputChanged(Hint);
+
+        this->inputChanged();
+    }
+
+    void Shell::backspace()
+    {
+        this->inputBuffer_->removeBehindCursor();
+        this->updateListeners<&ShellListener::inputChanged>();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::exit()
+    {
+        if (this->inputBuffer_->getSize() > 0)
+        {
+            this->clearInput();
+            return;
+        }
+
+        this->clearInput();
+        this->scrollPosition_ = 0;
+        this->scrollIterator_ = this->outputLines_.begin();
+
+        this->updateListeners<&ShellListener::exit>();
+    }
+
+    void Shell::deleteChar()
+    {
+        this->inputBuffer_->removeAtCursor();
+        this->updateListeners<&ShellListener::inputChanged>();
+    }
+
+    void Shell::cursorRight()
     {
         this->inputBuffer_->increaseCursor();
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::cursor_left()
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::cursorLeft()
     {
         this->inputBuffer_->decreaseCursor();
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::cursor_end()
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::cursorEnd()
     {
         this->inputBuffer_->setCursorToEnd();
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::cursor_home()
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::cursorHome()
     {
         this->inputBuffer_->setCursorToBegin();
-        SHELL_UPDATE_LISTENERS(cursorChanged);
-    }
-
-    void Shell::history_up()
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::historyUp()
     {
         if (this->historyPosition_ < this->commandHistory_.size())
@@ -350,5 +386,5 @@
     }
 
-    void Shell::history_down()
+    void Shell::historyDown()
     {
         if (this->historyPosition_ > 0)
@@ -359,39 +395,60 @@
     }
 
-    void Shell::scroll_up()
-    {
-        if (this->scrollIterator_ != this->lines_.end())
+    void Shell::historySearchUp()
+    {
+        if (this->historyPosition_ == this->historyOffset_)
+            return;
+        unsigned int cursorPosition = this->getCursorPosition();
+        const std::string& input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning of the inputline until the cursor position
+        for (unsigned int newPos = this->historyPosition_ + 1; newPos <= this->historyOffset_; newPos++)
+        {
+            if (getLowercase(this->commandHistory_[this->historyOffset_ - newPos]).find(getLowercase(input_str)) == 0) // search case insensitive
+            {
+                this->historyPosition_ = newPos;
+                this->inputBuffer_->set(this->getFromHistory());
+                this->setCursorPosition(cursorPosition);
+                return;
+            }
+        }
+    }
+
+    void Shell::historySearchDown()
+    {
+        if (this->historyPosition_ == 0)
+            return;
+        unsigned int cursorPosition = this->getCursorPosition();
+        const std::string& input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning
+        for (unsigned int newPos = this->historyPosition_ - 1; newPos > 0; newPos--)
+        {
+            if (getLowercase(this->commandHistory_[this->historyOffset_ - newPos]).find(getLowercase(input_str)) == 0) // sear$
+            {
+                this->historyPosition_ = newPos;
+                this->inputBuffer_->set(this->getFromHistory());
+                this->setCursorPosition(cursorPosition);
+                return;
+            }
+        }
+    }
+
+    void Shell::scrollUp()
+    {
+        if (this->scrollIterator_ != this->outputLines_.end())
         {
             ++this->scrollIterator_;
             ++this->scrollPosition_;
 
-            SHELL_UPDATE_LISTENERS(linesChanged);
-        }
-    }
-
-    void Shell::scroll_down()
-    {
-        if (this->scrollIterator_ != this->lines_.begin())
+            this->updateListeners<&ShellListener::linesChanged>();
+        }
+    }
+
+    void Shell::scrollDown()
+    {
+        if (this->scrollIterator_ != this->outputLines_.begin())
         {
             --this->scrollIterator_;
             --this->scrollPosition_;
 
-            SHELL_UPDATE_LISTENERS(linesChanged);
-        }
-    }
-
-    void Shell::exit()
-    {
-        if (this->inputBuffer_->getSize() > 0)
-        {
-            this->clear();
-            return;
-        }
-
-        this->clear();
-        this->scrollPosition_ = 0;
-        this->scrollIterator_ = this->lines_.begin();
-
-        SHELL_UPDATE_LISTENERS(exit);
+            this->updateListeners<&ShellListener::linesChanged>();
+        }
     }
 }
Index: code/branches/pickup2/src/libraries/core/Shell.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Shell.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Shell.h	(revision 6412)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -32,13 +32,13 @@
 #include "CorePrereqs.h"
 
-#include <cassert>
 #include <list>
+#include <sstream>
 #include <string>
 #include <vector>
 
-#include "util/OutputBuffer.h"
-#include "input/InputBuffer.h"
+#include "util/OutputHandler.h"
 #include "OrxonoxClass.h"
 #include "ConfigFileManager.h"
+#include "input/InputBuffer.h"
 
 namespace orxonox
@@ -57,18 +57,30 @@
             virtual void inputChanged() {}
             virtual void cursorChanged() {}
+            virtual void executed() {}
             virtual void exit() {}
     };
 
-    class _CoreExport Shell : public Singleton<Shell>, virtual public OrxonoxClass, public OutputBufferListener
+
+    class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
     {
-        friend class Singleton<Shell>;
         public:
-            Shell();
-            virtual ~Shell();
+            enum LineType
+            {
+                None    = OutputLevel::None,
+                Warning = OutputLevel::Warning,
+                Error   = OutputLevel::Error,
+                Info    = OutputLevel::Info,
+                Debug   = OutputLevel::Debug,
+                Verbose = OutputLevel::Verbose,
+                Ultra   = OutputLevel::Ultra,
+                Input,
+                Command,
+                Hint
+            };
 
-            static void clearShell();
-            static void history();
+            Shell(const std::string& consoleName, bool bScrollable);
+            ~Shell();
 
-            virtual void setConfigValues();
+            void setConfigValues();
             void commandHistoryOffsetChanged();
             void commandHistoryLengthChanged();
@@ -79,6 +91,4 @@
             inline InputBuffer* getInputBuffer()
                 { return this->inputBuffer_; }
-            inline OutputBuffer& getOutputBuffer()
-                { return this->outputBuffer_; }
 
             void setCursorPosition(unsigned int cursor);
@@ -86,66 +96,76 @@
                 { return this->inputBuffer_->getCursorPosition(); }
 
-            void setInput(const std::string& input);
-
-            inline void clearInput()
-                { this->setInput(""); }
-            inline std::string getInput() const
+            inline const std::string& getInput() const
                 { return this->inputBuffer_->get(); }
 
-            std::list<std::string>::const_iterator getNewestLineIterator() const;
-            std::list<std::string>::const_iterator getEndIterator() const;
+            typedef std::list<std::pair<std::string, LineType> > LineList;
+            LineList::const_iterator getNewestLineIterator() const;
+            LineList::const_iterator getEndIterator() const;
 
-            void addLine(const std::string& line, int level = 0);
-            void clearLines();
+            void addOutput(const std::string& text, LineType type = None);
+            void clearOutput();
 
             inline unsigned int getNumLines() const
-                { return this->lines_.size(); }
+                { return this->outputLines_.size(); }
             inline unsigned int getScrollPosition() const
                 { return this->scrollPosition_; }
 
-            inline void addOutputLevel(bool bAddOutputLevel)
-                { this->bAddOutputLevel_ = bAddOutputLevel; }
+            inline const std::string& getPromptPrefix() const { return this->promptPrefix_; }
+            void setPromptPrefix(const std::string& str);
 
         private:
             Shell(const Shell& other);
 
+            void addToHistory(const std::string& command);
+            const std::string& getFromHistory() const;
+            void clearInput();
+            // OutputListener
+            void outputChanged(int level);
+
             void configureInputBuffer();
 
-            void addToHistory(const std::string& command);
-            std::string getFromHistory() const;
-
-            virtual void outputChanged();
+            // InputBuffer callbacks
             void inputChanged();
             void execute();
-            void hintandcomplete();
+            void hintAndComplete();
             void backspace();
-            void deletechar();
-            void clear();
-            void cursor_right();
-            void cursor_left();
-            void cursor_end();
-            void cursor_home();
-            void history_up();
-            void history_down();
-            void scroll_up();
-            void scroll_down();
+            void deleteChar();
+            void cursorRight();
+            void cursorLeft();
+            void cursorEnd();
+            void cursorHome();
+            void historyUp();
+            void historyDown();
+            void historySearchUp();
+            void historySearchDown();
+            void scrollUp();
+            void scrollDown();
             void exit();
 
+            template <void (ShellListener::*F)()>
+            void updateListeners()
+            {
+                for (std::list<ShellListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+                    ((*(it++))->*F)();
+            }
+
             std::list<ShellListener*> listeners_;
-            InputBuffer* inputBuffer_;
-            OutputBuffer outputBuffer_;
-            bool finishedLastLine_;
-            std::list<std::string> lines_;
-            std::list<std::string>::const_iterator scrollIterator_;
-            unsigned int scrollPosition_;
-            std::vector<std::string> commandHistory_;
-            unsigned int maxHistoryLength_;
-            unsigned int historyPosition_;
-            unsigned int historyOffset_;
-            bool bAddOutputLevel_;
+            InputBuffer*              inputBuffer_;
+            std::stringstream         outputBuffer_;
+            bool                      bFinishedLastLine_;
+            LineList                  outputLines_;
+            LineList::const_iterator  scrollIterator_;
+            unsigned int              scrollPosition_;
+            unsigned int              historyPosition_;
 
-            ConfigFileType commandHistoryConfigFileType_;
+            std::string               promptPrefix_;
+            const std::string         consoleName_;
+            const bool                bScrollable_;
 
-            static Shell* singletonPtr_s;
+            // Config values
+            unsigned int              maxHistoryLength_;
+            unsigned int              historyOffset_;
+            std::vector<std::string>  commandHistory_;
+            int                       softDebugLevel_;
     };
 }
Index: code/branches/pickup2/src/libraries/core/SmartPtr.h
===================================================================
--- code/branches/pickup2/src/libraries/core/SmartPtr.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/SmartPtr.h	(revision 6412)
@@ -84,5 +84,5 @@
                     this->base_->decrementReferenceCount();
             }
-            
+
             inline const SmartPtr& operator=(int)
             {
Index: code/branches/pickup2/src/libraries/core/SubclassIdentifier.h
===================================================================
--- code/branches/pickup2/src/libraries/core/SubclassIdentifier.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/SubclassIdentifier.h	(revision 6412)
@@ -98,5 +98,5 @@
                     if (identifier)
                     {
-                        COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+                        COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;
                         COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
                     }
@@ -166,5 +166,5 @@
                     {
                         COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
-                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;
                         COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
                     }
Index: code/branches/pickup2/src/libraries/core/TclBind.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/TclBind.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/TclBind.cc	(revision 6412)
@@ -101,10 +101,10 @@
     {
         Tcl::interpreter* interpreter = new Tcl::interpreter();
-        std::string libpath = TclBind::getTclLibraryPath();
+        const std::string& libpath = TclBind::getTclLibraryPath();
 
         try
         {
-            if (libpath != "")
-                interpreter->eval("set tcl_library \"" + libpath + "\"");
+            if (!libpath.empty())
+                interpreter->eval("set tcl_library \"" + libpath + '"');
 
             Tcl_Init(interpreter->get());
@@ -136,5 +136,5 @@
         COUT(4) << "Tcl_query: " << args.get() << std::endl;
 
-        std::string command = stripEnclosingBraces(args.get());
+        const std::string& command = stripEnclosingBraces(args.get());
 
         if (!CommandExecutor::execute(command, false))
@@ -152,5 +152,5 @@
     {
         COUT(4) << "Tcl_execute: " << args.get() << std::endl;
-        std::string command = stripEnclosingBraces(args.get());
+        const std::string& command = stripEnclosingBraces(args.get());
 
         if (!CommandExecutor::execute(command, false))
@@ -166,6 +166,6 @@
             try
             {
-                std::string output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
-                if (output != "")
+                const std::string& output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
+                if (!output.empty())
                 {
                     COUT(0) << "tcl> " << output << std::endl;
@@ -182,5 +182,5 @@
     }
 
-    void TclBind::bgerror(std::string error)
+    void TclBind::bgerror(const std::string& error)
     {
         COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
Index: code/branches/pickup2/src/libraries/core/TclBind.h
===================================================================
--- code/branches/pickup2/src/libraries/core/TclBind.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/TclBind.h	(revision 6412)
@@ -46,5 +46,5 @@
 
             static std::string tcl(const std::string& tclcode);
-            static void bgerror(std::string error);
+            static void bgerror(const std::string& error);
 
             void setDataPath(const std::string& datapath);
Index: code/branches/pickup2/src/libraries/core/TclThreadManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/TclThreadManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/TclThreadManager.cc	(revision 6412)
@@ -39,4 +39,5 @@
 #include "util/Convert.h"
 #include "util/Exception.h"
+#include "util/StringUtils.h"
 #include "CommandExecutor.h"
 #include "ConsoleCommand.h"
@@ -122,5 +123,5 @@
         @brief The "main loop" of the TclThreadManager. Creates new threads if needed and handles queries and queued commands for the main interpreter.
     */
-    void TclThreadManager::update(const Clock& time)
+    void TclThreadManager::preUpdate(const Clock& time)
     {
         // Get the bundle of the main interpreter (0)
@@ -252,5 +253,5 @@
     void TclThreadManager::initialize(TclInterpreterBundle* bundle)
     {
-        std::string id_string = getConvertedValue<unsigned int, std::string>(bundle->id_);
+        const std::string& id_string = getConvertedValue<unsigned int, std::string>(bundle->id_);
 
         // Initialize the new interpreter
@@ -403,8 +404,8 @@
             {
                 // This query would lead to a deadlock - return with an error
-                TclThreadManager::error("Error: Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + " " + getConvertedValue<unsigned int, std::string>(source_bundle->id_) \
+                TclThreadManager::error("Error: Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + getConvertedValue<unsigned int, std::string>(source_bundle->id_) \
                             + " -> " + getConvertedValue<unsigned int, std::string>(target_bundle->id_) \
                             + "), couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target_bundle->id_) \
-                            + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(source_bundle->id_) + ".");
+                            + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(source_bundle->id_) + '.');
             }
             else
@@ -524,9 +525,9 @@
     std::string TclThreadManager::dumpList(const std::list<unsigned int>& list)
     {
-        std::string output = "";
+        std::string output;
         for (std::list<unsigned int>::const_iterator it = list.begin(); it != list.end(); ++it)
         {
             if (it != list.begin())
-                output += " ";
+                output += ' ';
 
             output += getConvertedValue<unsigned int, std::string>(*it);
@@ -600,5 +601,5 @@
         @param command the Command to execute
     */
-    void tclThread(TclInterpreterBundle* bundle, std::string command)
+    void tclThread(TclInterpreterBundle* bundle, const std::string& command)
     {
         TclThreadManager::debug("TclThread_execute: " + command);
@@ -613,5 +614,5 @@
         @param file The name of the file that should be executed by the non-interactive interpreter.
     */
-    void sourceThread(std::string file)
+    void sourceThread(const std::string& file)
     {
         TclThreadManager::debug("TclThread_source: " + file);
@@ -651,7 +652,7 @@
 
         // Initialize the non-interactive interpreter (like in @ref TclBind::createTclInterpreter but exception safe)
-        std::string libpath = TclBind::getTclLibraryPath();
-        if (libpath != "")
-            TclThreadManager::eval(bundle, "set tcl_library \"" + libpath + "\"", "source");
+        const std::string& libpath = TclBind::getTclLibraryPath();
+        if (!libpath.empty())
+            TclThreadManager::eval(bundle, "set tcl_library \"" + libpath + '"', "source");
         int cc = Tcl_Init(interp);
         TclThreadManager::eval(bundle, "source \"" + TclBind::getInstance().getTclDataPath() + "/init.tcl\"", "source");
Index: code/branches/pickup2/src/libraries/core/TclThreadManager.h
===================================================================
--- code/branches/pickup2/src/libraries/core/TclThreadManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/TclThreadManager.h	(revision 6412)
@@ -48,6 +48,6 @@
         friend class Singleton<TclThreadManager>;
         friend class TclBind;
-        friend _CoreExport void tclThread(TclInterpreterBundle* bundle, std::string command);
-        friend _CoreExport void sourceThread(std::string file);
+        friend _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
+        friend _CoreExport void sourceThread(const std::string& file);
         friend _CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
 
@@ -66,5 +66,5 @@
             static void debug(const std::string& error);
 
-            void update(const Clock& time);
+            void preUpdate(const Clock& time);
 
             std::list<unsigned int> getThreadList() const;
@@ -95,6 +95,6 @@
     };
 
-    _CoreExport void tclThread(TclInterpreterBundle* bundle, std::string command);
-    _CoreExport void sourceThread(std::string file);
+    _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
+    _CoreExport void sourceThread(const std::string& file);
     _CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
 }
Index: code/branches/pickup2/src/libraries/core/Template.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Template.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Template.cc	(revision 6412)
@@ -79,5 +79,5 @@
         SUPER(Template, changedName);
 
-        if (this->getName() != "")
+        if (!this->getName().empty())
         {
             std::map<std::string, Template*>::iterator it;
Index: code/branches/pickup2/src/libraries/core/Template.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Template.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Template.h	(revision 6412)
@@ -48,5 +48,5 @@
 
             inline void setLink(const std::string& link)
-                { this->link_ = link; this->bIsLink_ = (link != ""); }
+                { this->link_ = link; this->bIsLink_ = !link.empty(); }
             inline const std::string& getLink() const
                 { return this->link_; }
Index: code/branches/pickup2/src/libraries/core/Thread.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/Thread.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Thread.cc	(revision 6412)
@@ -41,6 +41,6 @@
 {
     boost::posix_time::millisec THREAD_WAIT_BEFORE_DETACH(1000);
-    
-    
+
+
     Thread::Thread():
         executor_(0),
@@ -53,5 +53,5 @@
         this->workerThread_ = new boost::thread( boost::bind(&Thread::threadLoop, this) );
     }
-    
+
     Thread::~Thread()
     {
@@ -66,5 +66,5 @@
         delete this->isWorkingMutex_;
     }
-    
+
     bool Thread::isWorking()
     {
@@ -74,5 +74,5 @@
       return isWorking;
     }
-    
+
     bool Thread::evaluateExecutor( Executor* executor )
     {
@@ -85,5 +85,5 @@
         return true;
     }
-    
+
     void Thread::threadLoop()
     {
@@ -114,5 +114,5 @@
         }
     }
-    
+
     void Thread::waitUntilFinished()
     {
Index: code/branches/pickup2/src/libraries/core/Thread.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Thread.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/Thread.h	(revision 6412)
@@ -50,5 +50,5 @@
     private:
         void            threadLoop();
-        
+
         Executor*       executor_;
         bool            isWorking_;
Index: code/branches/pickup2/src/libraries/core/ThreadPool.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/ThreadPool.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ThreadPool.cc	(revision 6412)
@@ -37,5 +37,5 @@
     {
     }
-    
+
     ThreadPool::~ThreadPool()
     {
@@ -43,5 +43,5 @@
         assert(a == 0);
     }
-    
+
     void ThreadPool::addThreads( unsigned int nr )
     {
@@ -80,5 +80,5 @@
         }
     }
-    
+
     bool ThreadPool::passFunction( Executor* executor, bool addThread )
     {
@@ -103,5 +103,5 @@
             return false;
     }
-    
+
     void ThreadPool::synchronise()
     {
Index: code/branches/pickup2/src/libraries/core/ThreadPool.h
===================================================================
--- code/branches/pickup2/src/libraries/core/ThreadPool.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/ThreadPool.h	(revision 6412)
@@ -41,15 +41,15 @@
         ThreadPool();
         virtual ~ThreadPool();
-        
+
         void addThreads( unsigned int nr );
         unsigned int removeThreads( unsigned int nr );
         unsigned int setNrOfThreads( unsigned int nr );
-        
+
         bool passFunction( Executor* executor, bool addThread=false );
         void synchronise();
-        
+
     private:
         std::vector<Thread*> threadPool_;
-        
+
     };
 }
Index: code/branches/pickup2/src/libraries/core/WeakPtr.h
===================================================================
--- code/branches/pickup2/src/libraries/core/WeakPtr.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/WeakPtr.h	(revision 6412)
@@ -44,5 +44,5 @@
     {
         friend class OrxonoxClass;
-        
+
         public:
             inline WeakPtr() : pointer_(0), base_(0), callback_(0)
@@ -79,7 +79,7 @@
                 if (this->callback_)
                     delete this->callback_;
-                    
-            }
-            
+
+            }
+
             inline const WeakPtr& operator=(int)
             {
@@ -145,5 +145,5 @@
                 if (other.base_)
                     other.base_->unregisterWeakPtr(&other);
-                
+
                 {
                     T* temp = this->pointer_;
@@ -167,10 +167,10 @@
                 WeakPtr().swap(*this);
             }
-            
+
             inline void setCallback(Functor* callback)
             {
                 this->callback_ = callback;
             }
-            
+
             inline Functor* getFunctor() const
             {
@@ -186,5 +186,5 @@
                     (*this->callback_)();
             }
-        
+
             T* pointer_;
             OrxonoxClass* base_;
Index: code/branches/pickup2/src/libraries/core/XMLFile.h
===================================================================
--- code/branches/pickup2/src/libraries/core/XMLFile.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/XMLFile.h	(revision 6412)
@@ -40,12 +40,10 @@
     {
         public:
-            XMLFile(const std::string& filename, const std::string& resourceGroup = "General")
+            XMLFile(const std::string& filename)
                 : filename_(filename)
-                , group_(resourceGroup)
                 , bLuaSupport_(true)
             { }
-            XMLFile(const ClassTreeMask& mask, const std::string& filename, const std::string& resourceGroup = "General")
+            XMLFile(const ClassTreeMask& mask, const std::string& filename)
                 : filename_(filename)
-                , group_(resourceGroup)
                 , mask_(mask)
                 , bLuaSupport_(true)
@@ -55,5 +53,4 @@
 
             const std::string& getFilename() const { return this->filename_; }
-            const std::string& getResourceGroup() const { return this->group_; }
             const ClassTreeMask& getMask() const { return this->mask_; }
             bool getLuaSupport() const { return this->bLuaSupport_; }
@@ -61,5 +58,4 @@
         private:
             std::string filename_;
-            std::string group_;
             ClassTreeMask mask_;
             bool bLuaSupport_; // Default is true
Index: code/branches/pickup2/src/libraries/core/XMLPort.h
===================================================================
--- code/branches/pickup2/src/libraries/core/XMLPort.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/XMLPort.h	(revision 6412)
@@ -51,4 +51,5 @@
 #include "util/MultiType.h"
 #include "util/OrxAssert.h"
+#include "util/StringUtils.h"
 #include "Identifier.h"
 #include "Executor.h"
@@ -184,5 +185,5 @@
         ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
     } \
-    containername->port(static_cast<BaseObject*>(this), object, xmlelement, mode)
+    containername->port(dynamic_cast<BaseObject*>(this), object, xmlelement, mode)
 
 // --------------------
@@ -316,5 +317,5 @@
                 { return this->paramname_; }
 
-            virtual XMLPortParamContainer& description(const std::string description) = 0;
+            virtual XMLPortParamContainer& description(const std::string& description) = 0;
             virtual const std::string& getDescription() = 0;
 
@@ -344,5 +345,5 @@
 
         public:
-            XMLPortClassParamContainer(const std::string paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
+            XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
             {
                 this->paramname_ = paramname;
@@ -385,5 +386,5 @@
                         }
                         std::map<std::string, std::string>::const_iterator it = this->owner_->xmlAttributes_.find(getLowercase(this->paramname_));
-                        std::string attributeValue("");
+                        std::string attributeValue;
                         if (it != this->owner_->xmlAttributes_.end())
                             attributeValue = it->second;
@@ -407,5 +408,5 @@
                     {
                         COUT(1) << std::endl;
-                        COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ":" << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ':' << std::endl;
                         COUT(1) << ex.what() << std::endl;
                     }
@@ -435,5 +436,5 @@
             }
 
-            virtual XMLPortParamContainer& description(const std::string description)
+            virtual XMLPortParamContainer& description(const std::string& description)
                 { this->loadexecutor_->setDescription(description); return (*this); }
             virtual const std::string& getDescription()
@@ -497,5 +498,5 @@
                 { return this->sectionname_; }
 
-            virtual XMLPortObjectContainer& description(const std::string description) = 0;
+            virtual XMLPortObjectContainer& description(const std::string& description) = 0;
             virtual const std::string& getDescription() = 0;
 
@@ -513,5 +514,5 @@
     {
         public:
-            XMLPortClassObjectContainer(const std::string sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
+            XMLPortClassObjectContainer(const std::string& sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
             {
                 this->sectionname_ = sectionname;
@@ -538,5 +539,5 @@
                     {
                         Element* xmlsubelement;
-                        if ((this->sectionname_ != "") && (this->sectionname_.size() > 0))
+                        if (!this->sectionname_.empty())
                             xmlsubelement = xmlelement.FirstChildElement(this->sectionname_, false);
                         else
@@ -570,9 +571,9 @@
                                                     {
                                                         newObject->XMLPort(*child, XMLPort::LoadObject);
-                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ")" << std::endl;
+                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
                                                     }
                                                     else
                                                     {
-                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ")" << std::endl;
+                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
                                                     }
 
@@ -609,5 +610,5 @@
                                 else
                                 {
-                                    if (this->sectionname_ != "")
+                                    if (!this->sectionname_.empty())
                                     {
                                         COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
@@ -624,5 +625,5 @@
                     {
                         COUT(1) << std::endl;
-                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << ClassIdentifier<O>::getIdentifier()->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ":" << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << ClassIdentifier<O>::getIdentifier()->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << std::endl;
                         COUT(1) << ex.what() << std::endl;
                     }
@@ -635,5 +636,5 @@
             }
 
-            virtual XMLPortObjectContainer& description(const std::string description)
+            virtual XMLPortObjectContainer& description(const std::string& description)
                 { this->loadexecutor_->setDescription(description); return (*this); }
             virtual const std::string& getDescription()
Index: code/branches/pickup2/src/libraries/core/input/Button.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/Button.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/Button.cc	(revision 6412)
@@ -116,5 +116,5 @@
         for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
         {
-            if (commandStrings[iCommand] != "")
+            if (!commandStrings[iCommand].empty())
             {
                 SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
@@ -123,9 +123,9 @@
                 KeybindMode::Value mode = KeybindMode::None;
                 float paramModifier = 1.0f;
-                std::string commandStr = "";
+                std::string commandStr;
 
                 for (unsigned int iToken = 0; iToken < tokens.size(); ++iToken)
                 {
-                    std::string token = getLowercase(tokens[iToken]);
+                    const std::string& token = getLowercase(tokens[iToken]);
 
                     if (token == "onpress")
@@ -159,9 +159,9 @@
                         // we interpret everything from here as a command string
                         while (iToken != tokens.size())
-                            commandStr += tokens[iToken++] + " ";
-                    }
-                }
-
-                if (commandStr == "")
+                            commandStr += tokens[iToken++] + ' ';
+                    }
+                }
+
+                if (commandStr.empty())
                 {
                     parseError("No command string given.", false);
@@ -242,5 +242,5 @@
     }
 
-    inline void Button::parseError(std::string message, bool serious)
+    inline void Button::parseError(const std::string& message, bool serious)
     {
         if (serious)
Index: code/branches/pickup2/src/libraries/core/input/Button.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/Button.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/Button.h	(revision 6412)
@@ -76,5 +76,5 @@
 
     private:
-        void parseError(std::string message, bool serious);
+        void parseError(const std::string& message, bool serious);
     };
 
Index: code/branches/pickup2/src/libraries/core/input/InputBuffer.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputBuffer.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputBuffer.cc	(revision 6412)
@@ -39,6 +39,6 @@
         RegisterRootObject(InputBuffer);
 
-        this->buffer_ = "";
         this->cursor_ = 0;
+        this->maxLength_ = 1024;
         this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
                                ABCDEFGHIJKLMNOPQRSTUVWXYZ \
@@ -59,6 +59,6 @@
         RegisterRootObject(InputBuffer);
 
+        this->maxLength_ = 1024;
         this->allowedChars_ = allowedChars;
-        this->buffer_ = "";
         this->cursor_ = 0;
 
@@ -80,5 +80,5 @@
     void InputBuffer::setConfigValues()
     {
-        SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat deleay of the input buffer");
+        SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat delay of the input buffer");
         SetConfigValue(keyRepeatTime_, 0.022).description("Key repeat time of the input buffer");
 
@@ -91,4 +91,11 @@
             ResetConfigValue(keyRepeatTime_);
         }
+    }
+
+    void InputBuffer::setMaxLength(unsigned int length)
+    {
+        this->maxLength_ = length;
+        if (this->buffer_.size() > length)
+            this->buffer_.resize(length);
     }
 
@@ -117,4 +124,6 @@
         if (this->charIsAllowed(input))
         {
+            if (this->buffer_.size() >= this->maxLength_)
+                return;
             this->buffer_.insert(this->cursor_, 1, input);
             ++this->cursor_;
@@ -127,5 +136,5 @@
     void InputBuffer::clear(bool update)
     {
-        this->buffer_ = "";
+        this->buffer_.clear();
         this->cursor_ = 0;
 
@@ -177,5 +186,5 @@
     bool InputBuffer::charIsAllowed(const char& input)
     {
-        if (this->allowedChars_ == "")
+        if (this->allowedChars_.empty())
             return true;
         else
@@ -186,4 +195,5 @@
     void InputBuffer::processKey(const KeyEvent& evt)
     {
+        // Prevent disaster when switching applications
         if (evt.isModifierDown(KeyboardModifier::Alt) && evt.getKeyCode() == KeyCode::Tab)
             return;
@@ -222,5 +232,5 @@
 
     /**
-        @brief This update() function is called by the InputManager if the InputBuffer is active.
+        @brief This update() function is called by the InputState if the InputBuffer is active.
         @param dt Delta time
     */
Index: code/branches/pickup2/src/libraries/core/input/InputBuffer.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputBuffer.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputBuffer.h	(revision 6412)
@@ -83,4 +83,7 @@
             void setConfigValues();
 
+            unsigned int getMaxLength() const { return this->maxLength_; }
+            void setMaxLength(unsigned int length);
+
             template <class T>
             void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
@@ -162,8 +165,9 @@
                 { if (this->cursor_ > 0) { --this->cursor_; } }
 
+            void buttonPressed(const KeyEvent& evt);
+
         private:
             bool charIsAllowed(const char& input);
 
-            void buttonPressed(const KeyEvent& evt);
             void buttonHeld   (const KeyEvent& evt);
             void processKey   (const KeyEvent& evt);
@@ -174,4 +178,5 @@
             std::list<BaseInputBufferListenerTuple*> listeners_;
             std::string allowedChars_;
+            unsigned int maxLength_;
             unsigned int cursor_;
 
Index: code/branches/pickup2/src/libraries/core/input/InputCommands.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputCommands.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputCommands.h	(revision 6412)
@@ -71,5 +71,5 @@
     @brief
         Executes a simple command with no additional paramters.
-    @return 
+    @return
         True if command execution was successful, false otherwise.
     */
Index: code/branches/pickup2/src/libraries/core/input/InputDevice.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputDevice.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputDevice.h	(revision 6412)
@@ -203,4 +203,5 @@
         {
             // remove the button from the pressedButtons_ list
+            bool found = false;
             for (unsigned int iButton = 0; iButton < pressedButtons_.size(); iButton++)
             {
@@ -208,7 +209,10 @@
                 {
                     pressedButtons_.erase(pressedButtons_.begin() + iButton);
+                    found = true;
                     break;
                 }
             }
+            if (!found)
+                return; // We ignore release strokes when the press was not captured
 
             // Call states
Index: code/branches/pickup2/src/libraries/core/input/InputHandler.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputHandler.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputHandler.h	(revision 6412)
@@ -73,4 +73,9 @@
             , modifiers_(0)
         { }
+        KeyEvent(KeyCode::ByEnum key, unsigned int text, int modifiers)
+            : key_(key)
+            , text_(text)
+            , modifiers_(modifiers)
+        { }
         bool operator==(const KeyEvent& rhs) const
             { return rhs.key_ == key_; }
@@ -97,8 +102,8 @@
 
         Derive from this class if you wish to receive input events.
-        But keep in mind that this is pointless wihtout first having an InputState.
+        But keep in mind that this is pointless without first having an InputState.
     @note
         The definitions for the button events with the weird arguments are simply
-        to avoid redunant code in the input devices.
+        to avoid redundant code in the input devices.
     */
     class _CoreExport InputHandler
Index: code/branches/pickup2/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputManager.cc	(revision 6412)
@@ -48,5 +48,5 @@
 #include "core/ConfigValueIncludes.h"
 #include "core/ConsoleCommand.h"
-#include "core/CommandLine.h"
+#include "core/CommandLineParser.h"
 #include "core/Functor.h"
 #include "core/GraphicsManager.h"
@@ -170,5 +170,5 @@
         if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
         {
-            if (CommandLine::getValue("keyboard_no_grab").getBool())
+            if (CommandLineParser::getValue("keyboard_no_grab").getBool())
                 paramList.insert(std::make_pair("x11_keyboard_grab", "false"));
             else
@@ -190,5 +190,5 @@
             // Exception-safety
             Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, oisInputManager_);
-            CCOUT(ORX_DEBUG) << "Created OIS input manager." << std::endl;
+            CCOUT(4) << "Created OIS input manager." << std::endl;
 
             if (oisInputManager_->getNumberOfDevices(OIS::OISKeyboard) > 0)
@@ -232,5 +232,5 @@
         }
         else
-            CCOUT(ORX_WARNING) << "Warning: No mouse found! Proceeding without mouse support." << std::endl;
+            CCOUT(2) << "Warning: No mouse found! Proceeding without mouse support." << std::endl;
     }
 
@@ -275,5 +275,5 @@
         // destroy all user InputStates
         while (statesByName_.size() > 0)
-            this->destroyStateInternal((*statesByName_.rbegin()).second);
+            this->destroyStateInternal(statesByName_.rbegin()->second);
 
         if (!(internalState_ & Bad))
@@ -297,5 +297,5 @@
             if (device == NULL)
                 continue;
-            std::string className = device->getClassName();
+            const std::string& className = device->getClassName();
             try
             {
@@ -366,5 +366,5 @@
     // ############################################################
 
-    void InputManager::update(const Clock& time)
+    void InputManager::preUpdate(const Clock& time)
     {
         if (internalState_ & Bad)
@@ -466,5 +466,5 @@
     @brief
         Updates the currently active states (according to activeStates_) for each device.
-        Also, a list of all active states (no duplicates!) is compiled for the general update().
+        Also, a list of all active states (no duplicates!) is compiled for the general preUpdate().
     */
     void InputManager::updateActiveStates()
@@ -508,5 +508,5 @@
         if (mouseStates.empty())
             requestedMode = MouseMode::Nonexclusive;
-        else 
+        else
             requestedMode = mouseStates.front()->getMouseMode();
         if (requestedMode != MouseMode::Dontcare && mouseMode_ != requestedMode)
@@ -554,5 +554,5 @@
     }
 
-    //! Gets called by WindowEventListener upon focus change --> clear buffers 
+    //! Gets called by WindowEventListener upon focus change --> clear buffers
     void InputManager::windowFocusChanged()
     {
@@ -579,5 +579,5 @@
     InputState* InputManager::createInputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority)
     {
-        if (name == "")
+        if (name.empty())
             return 0;
         if (statesByName_.find(name) == statesByName_.end())
@@ -631,9 +631,14 @@
                 {
                     // not scheduled for destruction
-                    // prevents a state being added multiple times
+                    // prevents a state from being added multiple times
                     stateEnterRequests_.insert(it->second);
                     return true;
                 }
             }
+            else if (this->stateLeaveRequests_.find(it->second) != this->stateLeaveRequests_.end())
+            {
+                // State already scheduled for leaving --> cancel
+                this->stateLeaveRequests_.erase(this->stateLeaveRequests_.find(it->second));
+            }
         }
         return false;
@@ -658,4 +663,9 @@
                 return true;
             }
+            else if (this->stateEnterRequests_.find(it->second) != this->stateEnterRequests_.end())
+            {
+                // State already scheduled for entering --> cancel
+                this->stateEnterRequests_.erase(this->stateEnterRequests_.find(it->second));
+            }
         }
         return false;
Index: code/branches/pickup2/src/libraries/core/input/InputManager.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputManager.h	(revision 6412)
@@ -41,4 +41,5 @@
 #include "InputState.h"
 
+// tolua_begin
 namespace orxonox
 {
@@ -47,5 +48,5 @@
         Manages the input devices (mouse, keyboard, joy sticks) and the input states.
 
-        Every input device has its own wrapper class which does the actualy input event
+        Every input device has its own wrapper class which does the actually input event
         distribution. The InputManager only creates reloads (on request) those devices.
 
@@ -58,11 +59,13 @@
           in the InputDevices themselves.
         - The devices_ vector always has at least two elements: Keyboard (first) and mouse.
-          You best access them intenally with InputDeviceEnumerator::Keyboard/Mouse
+          You best access them internally with InputDeviceEnumerator::Keyboard/Mouse
           The first joy stick is accessed with InputDeviceEnumerator::FirstJoyStick.
         - Keyboard construction is mandatory , mouse and joy sticks are not.
           If the OIS::InputManager or the Keyboard fail, an exception is thrown.
     */
-    class _CoreExport InputManager : public Singleton<InputManager>, public WindowEventListener
-    {
+    class _CoreExport InputManager
+// tolua_end
+        : public Singleton<InputManager>, public WindowEventListener
+    { // tolua_export
         friend class Singleton<InputManager>;
     public:
@@ -80,5 +83,5 @@
         @brief
             Loads the devices and initialises the KeyDetector and the Calibrator.
-            
+
             If either the OIS input system and/or the keyboard could not be created,
             the constructor fails with an std::exception.
@@ -94,7 +97,7 @@
 
             Any InpuStates changes (destroy, enter, leave) and happens here. If a reload request
-            was submitted while updating, the request wil be postponed until the next update call.
-        */
-        void update(const Clock& time);
+            was submitted while updating, the request will be postponed until the next update call.
+        */
+        void preUpdate(const Clock& time);
         //! Clears all input device buffers. This usually only includes the pressed button list.
         void clearBuffers();
@@ -105,5 +108,5 @@
             Reloads all the input devices. Use this method to initialise new joy sticks.
         @note
-            Only reloads immediately if the call stack doesn't include the update() method.
+            Only reloads immediately if the call stack doesn't include the preUpdate() method.
         */
         void reload();
@@ -135,9 +138,9 @@
         @brief
             Activates a specific input state.
-            It might not be actually activated if the priority is too low!
+            It might not actually be activated if the priority is too low!
         @return
             False if name was not found, true otherwise.
         */
-        bool enterState(const std::string& name);
+        bool enterState(const std::string& name); // tolua_export
         /**
         @brief
@@ -146,5 +149,5 @@
             False if name was not found, true otherwise.
         */
-        bool leaveState(const std::string& name);
+        bool leaveState(const std::string& name); // tolua_export
         /**
         @brief
@@ -154,5 +157,5 @@
         @remarks
             - You can't remove the internal states "empty", "calibrator" and "detector".
-            - The removal process is being postponed if InputManager::update() is currently running.
+            - The removal process is being postponed if InputManager::preUpdate() is currently running.
         */
         bool destroyState(const std::string& name);
@@ -168,9 +171,11 @@
         std::pair<int, int> getMousePosition() const;
 
+        static InputManager& getInstance() { return Singleton<InputManager>::getInstance(); } // tolua_export
+
     private: // functions
         // don't mess with a Singleton
         InputManager(const InputManager&);
 
-        // Intenal methods
+        // Internal methods
         void loadDevices();
         void loadMouse();
@@ -207,6 +212,6 @@
 
         static InputManager*                singletonPtr_s;        //!< Pointer reference to the singleton
-    };
-}
+    }; // tolua_export
+} // tolua_export
 
 #endif /* _InputManager_H__ */
Index: code/branches/pickup2/src/libraries/core/input/InputPrereqs.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputPrereqs.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputPrereqs.h	(revision 6412)
@@ -202,5 +202,5 @@
             MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
         };
-        
+
         //! Key codes as strings
         const char* const ByString[] =
Index: code/branches/pickup2/src/libraries/core/input/InputState.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/InputState.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/InputState.cc	(revision 6412)
@@ -102,5 +102,5 @@
         if (enterFunctor_)
             (*enterFunctor_)();
-            
+
     }
 
Index: code/branches/pickup2/src/libraries/core/input/JoyStick.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/JoyStick.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/JoyStick.cc	(revision 6412)
@@ -33,4 +33,5 @@
 #include <boost/foreach.hpp>
 
+#include "util/StringUtils.h"
 #include "core/ConfigFileManager.h"
 #include "core/ConfigValueIncludes.h"
@@ -61,9 +62,9 @@
             std::string name = oisDevice_->vendor();
             replaceCharacters(name, ' ', '_');
-            deviceName_ = name + "_";
-        }
-        deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Button))  + "_";
-        deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Axis))    + "_";
-        deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Slider))  + "_";
+            deviceName_ = name + '_';
+        }
+        deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Button))  + '_';
+        deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Axis))    + '_';
+        deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Slider))  + '_';
         deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_POV));
         //deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Vector3));
@@ -74,5 +75,5 @@
             {
                 // Make the ID unique for this execution time.
-                deviceName_ += "_" + multi_cast<std::string>(this->getDeviceName());
+                deviceName_ += '_' + multi_cast<std::string>(this->getDeviceName());
                 break;
             }
Index: code/branches/pickup2/src/libraries/core/input/JoyStickQuantityListener.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/JoyStickQuantityListener.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/JoyStickQuantityListener.h	(revision 6412)
@@ -29,5 +29,5 @@
 /**
 @file
-@brief 
+@brief
 */
 
Index: code/branches/pickup2/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/KeyBinder.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/KeyBinder.cc	(revision 6412)
@@ -29,4 +29,6 @@
 #include "KeyBinder.h"
 
+#include <algorithm>
+#include <sstream>
 #include "util/Convert.h"
 #include "util/Debug.h"
@@ -50,6 +52,6 @@
         mouseRelative_[0] = 0;
         mouseRelative_[1] = 0;
-        mousePosition_[0] = 0;
-        mousePosition_[1] = 0;
+        mousePosition_[0] = 0.0;
+        mousePosition_[1] = 0.0;
 
         RegisterRootObject(KeyBinder);
@@ -59,9 +61,9 @@
         for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
         {
-            std::string keyname = KeyCode::ByString[i];
+            const std::string& keyname = KeyCode::ByString[i];
             if (!keyname.empty())
                 keys_[i].name_ = std::string("Key") + keyname;
             else
-                keys_[i].name_ = "";
+                keys_[i].name_.clear();
             keys_[i].paramCommandBuffer_ = &paramCommandBuffer_;
             keys_[i].groupName_ = "Keys";
@@ -126,6 +128,7 @@
         SetConfigValue(bFilterAnalogNoise_, false)
             .description("Specifies whether to filter small analog values like joy stick fluctuations.");
-        SetConfigValue(mouseSensitivity_, 1.0f)
+        SetConfigValue(mouseSensitivity_, 3.0f)
             .description("Mouse sensitivity.");
+        this->totalMouseSensitivity_ = this->mouseSensitivity_ / this->mouseClippingSize_;
         SetConfigValue(bDeriveMouseInput_, false)
             .description("Whether or not to derive moues movement for the absolute value.");
@@ -185,8 +188,8 @@
         this->joyStickButtons_.resize(joySticks_.size());
 
-        // reinitialise all joy stick binings (doesn't overwrite the old ones)
+        // reinitialise all joy stick bindings (doesn't overwrite the old ones)
         for (unsigned int iDev = 0; iDev < joySticks_.size(); iDev++)
         {
-            std::string deviceName = joySticks_[iDev]->getDeviceName();
+            const std::string& deviceName = joySticks_[iDev]->getDeviceName();
             // joy stick buttons
             for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
@@ -218,10 +221,10 @@
         for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
             if (!keys_[i].name_.empty())
-                allButtons_[keys_[i].groupName_ + "." + keys_[i].name_] = keys_ + i;
+                allButtons_[keys_[i].groupName_ + '.' + keys_[i].name_] = keys_ + i;
         for (unsigned int i = 0; i < numberOfMouseButtons_; i++)
-            allButtons_[mouseButtons_[i].groupName_ + "." + mouseButtons_[i].name_] = mouseButtons_ + i;
+            allButtons_[mouseButtons_[i].groupName_ + '.' + mouseButtons_[i].name_] = mouseButtons_ + i;
         for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
         {
-            allButtons_[mouseAxes_[i].groupName_ + "." + mouseAxes_[i].name_] = mouseAxes_ + i;
+            allButtons_[mouseAxes_[i].groupName_ + '.' + mouseAxes_[i].name_] = mouseAxes_ + i;
             allHalfAxes_.push_back(mouseAxes_ + i);
         }
@@ -229,8 +232,8 @@
         {
             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]);
+                allButtons_[(*joyStickAxes_[iDev])[i].groupName_ + '.' + (*joyStickAxes_[iDev])[i].name_] = &((*joyStickAxes_[iDev])[i]);
                 allHalfAxes_.push_back(&((*joyStickAxes_[iDev])[i]));
             }
@@ -253,5 +256,8 @@
         // Parse bindings and create the ConfigValueContainers if necessary
         for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
+        {
             it->second->readConfigValue(this->configFile_);
+            addButtonToCommand(it->second->bindingString_, it->second);
+        }
 
         COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
@@ -263,4 +269,5 @@
         if (it != allButtons_.end())
         {
+            addButtonToCommand(binding, it->second);
             if (bTemporary)
                 it->second->configContainer_->tset(binding);
@@ -275,4 +282,82 @@
             return false;
         }
+    }
+
+     void KeyBinder::addButtonToCommand(const std::string& command, Button* button)
+     {
+        std::ostringstream stream;
+        stream << button->groupName_  << '.' << button->name_;
+
+        std::vector<std::string>& oldKeynames = this->allCommands_[button->bindingString_];
+        std::vector<std::string>::iterator it = std::find(oldKeynames.begin(), oldKeynames.end(), stream.str());
+        if(it != oldKeynames.end())
+        {
+            oldKeynames.erase(it);
+        }
+
+        if (!command.empty())
+        {
+            std::vector<std::string>& keynames = this->allCommands_[command];
+            if( std::find(keynames.begin(), keynames.end(), stream.str()) == keynames.end())
+            {
+                this->allCommands_[command].push_back(stream.str());
+            }
+        }
+     }
+
+    /**
+    @brief
+        Return the first key name for a specific command
+    */
+    const std::string& KeyBinder::getBinding(const std::string& commandName)
+    {
+        if( this->allCommands_.find(commandName) != this->allCommands_.end())
+        {
+            std::vector<std::string>& keynames = this->allCommands_[commandName];
+            return keynames.front();
+        }
+
+        return BLANKSTRING;
+    }
+
+    /**
+    @brief
+        Return the key name for a specific command at a given index.
+    @param commandName
+        The command name the key name is returned for.
+    @param index
+        The index at which the key name is returned for.
+    */
+    const std::string& KeyBinder::getBinding(const std::string& commandName, unsigned int index)
+    {
+        if( this->allCommands_.find(commandName) != this->allCommands_.end())
+        {
+            std::vector<std::string>& keynames = this->allCommands_[commandName];
+            if(index < keynames.size())
+            {
+                return keynames[index];
+            }
+
+            return BLANKSTRING;
+        }
+
+        return BLANKSTRING;
+    }
+
+    /**
+    @brief
+        Get the number of different key bindings of a specific command.
+    @param commandName
+        The command.
+    */
+    unsigned int KeyBinder::getNumberOfBindings(const std::string& commandName)
+    {
+        if( this->allCommands_.find(commandName) != this->allCommands_.end())
+        {
+            std::vector<std::string>& keynames = this->allCommands_[commandName];
+            return keynames.size();
+        }
+
+        return 0;
     }
 
@@ -395,8 +480,5 @@
 
         // these are the actually useful axis bindings for analog input
-        if (!bFilterAnalogNoise_ || halfAxis.relVal_ > analogThreshold_ || halfAxis.absVal_ > analogThreshold_)
-        {
-            halfAxis.execute();
-        }
+        halfAxis.execute();
     }
 
@@ -426,15 +508,15 @@
                     mouseAxes_[2*i + 0].hasChanged_ = true;
                     mouseAxes_[2*i + 1].hasChanged_ = true;
-                    mousePosition_[i] += rel[i];
+                    mousePosition_[i] += rel[i] * totalMouseSensitivity_;
 
                     // clip absolute position
-                    if (mousePosition_[i] > mouseClippingSize_)
-                        mousePosition_[i] =  mouseClippingSize_;
-                    if (mousePosition_[i] < -mouseClippingSize_)
-                        mousePosition_[i] = -mouseClippingSize_;
-
-                    if (mousePosition_[i] < 0)
+                    if (mousePosition_[i] > 1.0)
+                        mousePosition_[i] =  1.0;
+                    if (mousePosition_[i] < -1.0)
+                        mousePosition_[i] = -1.0;
+
+                    if (mousePosition_[i] < 0.0)
                     {
-                        mouseAxes_[2*i + 0].absVal_ = -mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
+                        mouseAxes_[2*i + 0].absVal_ = -mousePosition_[i];
                         mouseAxes_[2*i + 1].absVal_ = 0.0f;
                     }
@@ -442,5 +524,5 @@
                     {
                         mouseAxes_[2*i + 0].absVal_ = 0.0f;
-                        mouseAxes_[2*i + 1].absVal_ =  mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
+                        mouseAxes_[2*i + 1].absVal_ =  mousePosition_[i];
                     }
                 }
@@ -452,7 +534,7 @@
         {
             if (rel[i] < 0)
-                mouseAxes_[0 + 2*i].relVal_ = -mouseSensitivity_ * rel[i] / mouseClippingSize_;
+                mouseAxes_[0 + 2*i].relVal_ = -rel[i] * totalMouseSensitivity_;
             else
-                mouseAxes_[1 + 2*i].relVal_ =  mouseSensitivity_ * rel[i] / mouseClippingSize_;
+                mouseAxes_[1 + 2*i].relVal_ =  rel[i] * totalMouseSensitivity_;
         }
     }
@@ -474,4 +556,7 @@
     void KeyBinder::axisMoved(unsigned int device, unsigned int axisID, float value)
     {
+        // Filter analog noise
+        if (this->bFilterAnalogNoise_ && std::abs(value) < this->analogThreshold_)
+            value = 0.0;
         int i = axisID * 2;
         JoyStickAxisVector& axis = *joyStickAxes_[device];
Index: code/branches/pickup2/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/KeyBinder.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/KeyBinder.h	(revision 6412)
@@ -35,4 +35,5 @@
 #include <string>
 #include <vector>
+#include <map>
 #include <boost/shared_ptr.hpp>
 
@@ -43,6 +44,8 @@
 #include "JoyStickQuantityListener.h"
 
+// tolua_begin
 namespace orxonox
 {
+    // tolua_end
     /**
     @brief
@@ -54,6 +57,7 @@
         KeyBinders. If you need to load other bindings, just create a new one.
     */
-    class _CoreExport KeyBinder : public InputHandler, public JoyStickQuantityListener
-    {
+    class _CoreExport KeyBinder // tolua_export
+        : public InputHandler, public JoyStickQuantityListener
+    { // tolua_export
     public:
         KeyBinder (const std::string& filename);
@@ -62,4 +66,8 @@
         void clearBindings();
         bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
+        const std::string& getBinding(const std::string& commandName); //tolua_export
+        const std::string& getBinding(const std::string& commandName, unsigned int index); //tolua_export
+        unsigned int getNumberOfBindings(const std::string& commandName); //tolua_export
+
         const std::string& getBindingsFilename()
             { return this->filename_; }
@@ -130,4 +138,6 @@
         //! Pointer list with all half axes
         std::vector<HalfAxis*> allHalfAxes_;
+        //! Maps input commands to all Button names, including half axes
+        std::map< std::string, std::vector<std::string> > allCommands_;
 
         /**
@@ -138,6 +148,6 @@
         std::vector<BufferedParamCommand*> paramCommandBuffer_;
 
-        //! Keeps track of the absolute mouse value (incl. scroll wheel)
-        int mousePosition_[2];
+        //! Keeps track of the absolute mouse value
+        float mousePosition_[2];
         //! Used to derive mouse input if requested
         int mouseRelative_[2];
@@ -150,4 +160,6 @@
 
     private:
+        void addButtonToCommand(const std::string& command, Button* button);
+
         //##### ConfigValues #####
         //! Whether to filter small value analog input
@@ -165,11 +177,14 @@
         //! mouse sensitivity if mouse input is derived
         float mouseSensitivityDerived_;
-        //! Equals one step of the mousewheel
+        //! Equals one step of the mouse wheel
         int mouseWheelStepSize_;
+
+        //! Multiplication of mouse sensitivity and clipping size
+        float totalMouseSensitivity_;
 
         //##### Constant config variables #####
         // Use some value at about 1000. This can be configured with mouseSensitivity_ anyway.
         static const int mouseClippingSize_ = 1024;
-    };
+    };// tolua_export
 
 
@@ -216,5 +231,5 @@
             mouseAxes_[i].relVal_ = 0.0f;
     }
-}
+}// tolua_export
 
 #endif /* _KeyBinder_H__ */
Index: code/branches/pickup2/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/KeyBinderManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/KeyBinderManager.cc	(revision 6412)
@@ -40,5 +40,4 @@
 namespace orxonox
 {
-    KeyBinderManager* KeyBinderManager::singletonPtr_s = 0;
     ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false);
 
@@ -48,6 +47,4 @@
         , bBinding_(false)
     {
-        this->callbackFunction_ = createFunctor(&KeyBinderManager::callback, this);
-
         RegisterObject(KeyBinderManager);
         this->setConfigValues();
@@ -57,4 +54,8 @@
             .defaultValues("");
         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tkeybind, this), "tkeybind"))
+            .defaultValues("");
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::unbind, this), "unbind"))
+            .defaultValues("");
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tunbind, this), "tunbind"))
             .defaultValues("");
 
@@ -68,5 +69,4 @@
         for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
             delete it->second;
-        delete this->callbackFunction_;
     }
 
@@ -91,4 +91,14 @@
         else
             this->bDefaultFileLoaded_ = false;
+    }
+
+    inline void KeyBinderManager::unbind(const std::string& binding)
+    {
+        this->currentBinder_->setBinding("", binding, false);
+    }
+
+    inline void KeyBinderManager::tunbind(const std::string& binding)
+    {
+        this->currentBinder_->setBinding("", binding, true);
     }
 
@@ -146,5 +156,5 @@
         {
             COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-            KeyDetector::getInstance().setCallback(callbackFunction_);
+            KeyDetector::getInstance().setCallback(shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));
             InputManager::getInstance().enterState("detector");
             this->command_ = command;
@@ -156,11 +166,21 @@
 
     // Gets called by the KeyDetector (registered with a Functor)
-    void KeyBinderManager::callback(const std::string& keyName)
+    void KeyBinderManager::keybindKeyPressed(const std::string& keyName)
     {
         if (this->bBinding_)
         {
-            COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;
-            this->currentBinder_->setBinding(command_, keyName, bTemporary_);
+            if (keyName == "Keys.KeyEscape")
+            {
+                COUT(0) << "Keybinding aborted." << std::endl;
+            }
+            else
+            {
+                COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;
+                this->currentBinder_->setBinding(command_, keyName, bTemporary_);
+            }
             InputManager::getInstance().leaveState("detector");
+            // inform whatever was calling the command
+            if (this->callbackFunction_)
+                (*this->callbackFunction_)();
             this->bBinding_ = false;
         }
Index: code/branches/pickup2/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/KeyBinderManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/KeyBinderManager.h	(revision 6412)
@@ -34,9 +34,11 @@
 #include <map>
 #include <string>
+#include <boost/shared_ptr.hpp>
+
 #include "util/Singleton.h"
 #include "core/OrxonoxClass.h"
 
-namespace orxonox
-{
+namespace orxonox //tolua_export
+{ //tolua_export
     /**
     @brief
@@ -46,11 +48,12 @@
         maps to the currently active KeyBinder. You can set that with setCurrent().
         There is also a default one, retrieved with getDefault(). The idea is that
-        mostly the default KeyBinder is active except for special situtations (mini-game for inst).
+        mostly the default KeyBinder is active except for special situations (mini-game for inst).
     @remarks
         You are not forced to use the KeyBinder imposed by getCurrent(). But be aware that "keybind"
         will not work as expected!
     */
-    class _CoreExport KeyBinderManager : public Singleton<KeyBinderManager>, public OrxonoxClass
-    {
+    class _CoreExport KeyBinderManager //tolua_export
+        : public Singleton<KeyBinderManager>, public OrxonoxClass
+    { //tolua_export
         friend class Singleton<KeyBinderManager>;
     public:
@@ -59,7 +62,7 @@
         void setConfigValues();
 
+        static KeyBinderManager& getInstance() { return Singleton<KeyBinderManager>::getInstance(); } //tolua_export
         //! Returns the currently selected KeyBinder
-        KeyBinder*    getCurrent()
-            { return this->currentBinder_; }
+        KeyBinder* getCurrent() { return this->currentBinder_; } //tolua_export
         //! Like getCurrent(), but returns it as InputHandler* (so you don't have to include KeyBinder.h)
         InputHandler* getCurrentAsHandler();
@@ -68,5 +71,5 @@
 
         //! Returns the default KeyBinder
-        KeyBinder*    getDefault()
+        KeyBinder* getDefault()
             { return binders_[this->defaultFilename_]; }
         //! Returns the default KeyBinder as InputHandler* (so you don't have to include KeyBinder.h)
@@ -80,24 +83,26 @@
 
         //! Returns a pointer to a KeyBinder (creates it if not yet loaded)
-        KeyBinder*    get(const std::string& name);
+        KeyBinder* get(const std::string& name);
         //! Like get() but return value is of type InputHandler* (so you don't have to include KeyBinder.h)
         InputHandler* getAsHandler(const std::string& name);
 
         //! Loads a KeyBinder by creating it (no different from get() except for the return value)
-        void load  (const std::string& filename);
+        void load(const std::string& filename);
         //! Destroys a KeyBinder completely (does nothing if not yet loaded)
         void unload(const std::string& filename);
 
         //! Bind 'command' to any key pressed after this call (use with care!)
-        inline void keybind(const std::string& command)
-            { this->keybindInternal(command, false); }
+        inline void keybind(const std::string& command) { this->keybindInternal(command, false); } //tolua_export
         //! Bind 'command' to any key pressed after this call (use with care!), but temporarily (no file save)
         inline void tkeybind(const std::string& command)
             { this->keybindInternal(command, true); }
+        void unbind(const std::string& binding); //tolua_export
+        void tunbind(const std::string& binding);
+        inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } // tolua_export
 
     private:
         KeyBinderManager(const KeyBinderManager&);
         void keybindInternal(const std::string& command, bool bTemporary);
-        void callback(const std::string& keyName);
+        void keybindKeyPressed(const std::string& keyName);
         void defaultFilenameChanged();
 
@@ -109,5 +114,5 @@
 
         // keybind command related
-        Functor* callbackFunction_;                  //! Function to be called when key was pressed after "keybind" command
+        shared_ptr<Functor> callbackFunction_;       //! Function to be called when key was pressed after "keybind" command
         bool bBinding_;                              //! Tells whether a key binding process is active
         bool bTemporary_;                            //! Stores tkeybind/keybind value
@@ -115,6 +120,6 @@
 
         static KeyBinderManager* singletonPtr_s;
-    };
-}
+    }; //tolua_export
+} //tolua_export
 
 #endif /* _KeyBinderManager_H__ */
Index: code/branches/pickup2/src/libraries/core/input/KeyDetector.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/KeyDetector.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/KeyDetector.cc	(revision 6412)
@@ -39,5 +39,4 @@
 {
     std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
-    KeyDetector* KeyDetector::singletonPtr_s = 0;
     ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false);
 
@@ -68,5 +67,5 @@
         for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
         {
-            it->second->bindingString_ = callbackCommand_s + " " + it->second->groupName_ + "." + it->second->name_;
+            it->second->bindingString_ = callbackCommand_s + ' ' + it->second->groupName_ + "." + it->second->name_;
             it->second->parse();
         }
Index: code/branches/pickup2/src/libraries/core/input/KeyDetector.h
===================================================================
--- code/branches/pickup2/src/libraries/core/input/KeyDetector.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/KeyDetector.h	(revision 6412)
@@ -32,4 +32,5 @@
 #include "InputPrereqs.h"
 
+#include <boost/shared_ptr.hpp>
 #include "util/Singleton.h"
 #include "KeyBinder.h"
@@ -45,5 +46,5 @@
         ~KeyDetector();
 
-        void setCallback(Functor* function) { this->callbackFunction_ = function; }
+        void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }
 
     private:
@@ -54,5 +55,5 @@
         void assignCommands();
 
-        Functor* callbackFunction_;
+        shared_ptr<Functor> callbackFunction_;
         InputState* inputState_;
         static std::string callbackCommand_s;
Index: code/branches/pickup2/src/libraries/core/input/Keyboard.cc
===================================================================
--- code/branches/pickup2/src/libraries/core/input/Keyboard.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/core/input/Keyboard.cc	(revision 6412)
@@ -43,4 +43,8 @@
             modifiers_ |= KeyboardModifier::Shift; // shift key
 
+        // Do not distribute the alt+tab event (messes with the operating system)
+        if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB)
+            return true;
+
         KeyEvent evt(arg);
         super::buttonPressed(evt);
Index: code/branches/pickup2/src/libraries/network/Client.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/Client.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Client.cc	(revision 6412)
@@ -62,5 +62,6 @@
   Client::Client():
       isSynched_(false),
-      gameStateFailure_(false)
+      gameStateFailure_(false),
+      timeSinceLastUpdate_(0)
   {
   }
@@ -73,5 +74,6 @@
   Client::Client(const std::string& address, int port):
       isSynched_(false),
-      gameStateFailure_(false)
+      gameStateFailure_(false),
+      timeSinceLastUpdate_(0)
   {
       setPort( port );
@@ -112,4 +114,8 @@
   }
 
+  void Client::printRTT(){
+    COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;
+  }
+
   /**
    * This function implements the method of sending a chat message to the server
@@ -133,5 +139,5 @@
     {
       timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
-      //     COUT(3) << ".";
+      //     COUT(3) << '.';
       if ( isConnected() && isSynched_ )
       {
@@ -149,5 +155,5 @@
     }
     sendPackets(); // flush the enet queue
-    
+
     Connection::processQueue();
     if(gamestate.processGamestates())
@@ -157,8 +163,9 @@
     }
     gamestate.cleanup();
+    Connection::sendPackets();
 
     return;
   }
-  
+
   void Client::connectionClosed()
   {
Index: code/branches/pickup2/src/libraries/network/Client.h
===================================================================
--- code/branches/pickup2/src/libraries/network/Client.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Client.h	(revision 6412)
@@ -72,4 +72,5 @@
     virtual bool chat(const std::string& message);
     virtual bool broadcast(const std::string& message) { return false; }
+    virtual void printRTT();
 
     void update(const Clock& time);
Index: code/branches/pickup2/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/ClientConnection.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/ClientConnection.cc	(revision 6412)
@@ -38,6 +38,6 @@
   const unsigned int NETWORK_CLIENT_WAIT_TIME = 1;
   const unsigned int NETWORK_CLIENT_CONNECTION_TIMEOUT = 3000; //millisecs
-  const unsigned int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
-  const unsigned int NETWORK_CLIENT_CHANNELS = 2;
+  const unsigned int NETWORK_CLIENT_MAX_CONNECTIONS = 1;
+  const unsigned int NETWORK_CLIENT_CHANNELS = 1;
 
 
@@ -69,5 +69,5 @@
   {
     ENetEvent event;
-    
+
     this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
     if ( this->host_ == NULL )
@@ -99,5 +99,5 @@
   bool ClientConnection::closeConnection() {
     ENetEvent event;
-    
+
     if ( !this->established_ )
       return true;
@@ -147,3 +147,9 @@
   }
 
+  uint32_t ClientConnection::getRTT()
+  {
+    assert(server_);
+    return server_->roundTripTime;
+  }
+
 }
Index: code/branches/pickup2/src/libraries/network/ClientConnection.h
===================================================================
--- code/branches/pickup2/src/libraries/network/ClientConnection.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/ClientConnection.h	(revision 6412)
@@ -26,5 +26,5 @@
  *
  */
- 
+
 #ifndef _ClientConnection_H__
 #define _ClientConnection_H__
@@ -40,8 +40,8 @@
     ClientConnection();
     virtual ~ClientConnection();
-    
+
     void setServerAddress( const std::string& serverAddress );
     void setPort( unsigned int port );
-    
+
     ENetEvent *getEvent();
     // check wheter the packet queue is empty
@@ -55,8 +55,9 @@
   protected:
     virtual void connectionClosed()=0;
+    uint32_t getRTT();
   private:
     virtual void addPeer(ENetEvent* event);
     virtual void removePeer(ENetEvent* event);
-    
+
     bool disconnectConnection();
     // enet stuff
Index: code/branches/pickup2/src/libraries/network/ClientConnectionListener.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/ClientConnectionListener.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/ClientConnectionListener.cc	(revision 6412)
@@ -36,6 +36,6 @@
 {
     ClientConnectionListener::ClientConnectionListener()
-    { 
-        RegisterRootObject(ClientConnectionListener); 
+    {
+        RegisterRootObject(ClientConnectionListener);
     }
 
@@ -45,5 +45,5 @@
             it->clientConnected(clientID);
     }
-    
+
     void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID)
     {
Index: code/branches/pickup2/src/libraries/network/ClientConnectionListener.h
===================================================================
--- code/branches/pickup2/src/libraries/network/ClientConnectionListener.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/ClientConnectionListener.h	(revision 6412)
@@ -40,5 +40,5 @@
             ClientConnectionListener();
             virtual ~ClientConnectionListener() {}
-            
+
             static void broadcastClientConnected(unsigned int clientID);
             static void broadcastClientDisconnected(unsigned int clientID);
Index: code/branches/pickup2/src/libraries/network/ClientInformation.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/ClientInformation.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/ClientInformation.cc	(revision 6412)
@@ -42,8 +42,9 @@
 #define WIN32_LEAN_AND_MEAN
 #include <enet/enet.h>
+#include "ClientConnectionListener.h"
 
 namespace orxonox
 {
-  
+
 
   ClientInformation *ClientInformation::head_=0;
@@ -66,4 +67,5 @@
     if(this==head_)
       head_=next();
+    ClientConnectionListener::broadcastClientDisconnected( this->getID() );
   }
 
Index: code/branches/pickup2/src/libraries/network/Connection.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/Connection.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Connection.cc	(revision 6412)
@@ -75,5 +75,5 @@
   void Connection::processQueue() {
     ENetEvent event;
-    
+
     assert(this->host_);
 
Index: code/branches/pickup2/src/libraries/network/Connection.h
===================================================================
--- code/branches/pickup2/src/libraries/network/Connection.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Connection.h	(revision 6412)
@@ -54,5 +54,5 @@
   public:
     virtual ~Connection();
-    
+
     static bool addPacket(ENetPacket *packet, ENetPeer *peer);
     bool sendPackets();
@@ -62,13 +62,13 @@
     Connection();
     static Connection* getInstance(){ return Connection::instance_; }
-    
+
     int service(ENetEvent* event);
     virtual void disconnectPeer(ENetPeer *peer);
-    
+
     void processQueue();
     virtual void addPeer(ENetEvent* event)=0;
     virtual void removePeer(ENetEvent* event)=0;
     virtual bool processPacket(ENetEvent* event);
-    
+
     ENetHost *host_;
   private:
Index: code/branches/pickup2/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/FunctionCallManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/FunctionCallManager.cc	(revision 6412)
@@ -31,5 +31,5 @@
 
 namespace orxonox {
-    
+
 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_;
 
@@ -37,55 +37,55 @@
 
 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)
-{  
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
-  FunctionCallManager::	clientMap_[clientID]->addCallStatic(functionID);
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
+  FunctionCallManager::clientMap_[clientID]->addCallStatic(functionID);
 }
 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)
-{  
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1);
 }
 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
-{  
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
 }
 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{  
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
 }
 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{  
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
 }
 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{  
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
 }
@@ -95,55 +95,55 @@
 
 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)
-{ 
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID);
 }
 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)
-{ 
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
 }
 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
-{ 
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
 }
 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{ 
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
 }
 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{ 
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
 }
 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{ 
-  if(clientMap_.find(clientID)==clientMap_.end()) 
+{
+  if(clientMap_.find(clientID)==clientMap_.end())
   {
-    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
-    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
-  } 
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+  }
   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
 }
Index: code/branches/pickup2/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/branches/pickup2/src/libraries/network/FunctionCallManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/FunctionCallManager.h	(revision 6412)
@@ -37,5 +37,5 @@
 namespace orxonox {
 /**
-	@author
+    @author
 */
 
@@ -49,5 +49,5 @@
   static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
   static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
-  
+
   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID);
   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1);
@@ -56,7 +56,7 @@
   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
-  
+
   static void sendCalls();
-  
+
   static std::map<uint32_t, packet::FunctionCalls*> clientMap_;
 protected:
Index: code/branches/pickup2/src/libraries/network/GamestateClient.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/GamestateClient.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/GamestateClient.cc	(revision 6412)
@@ -54,5 +54,5 @@
       std::map<unsigned int, packet::Gamestate *>::iterator it;
       for ( it = this->gamestateMap_.begin(); it != this->gamestateMap_.end(); ++it )
-          delete (*it).second;
+          delete it->second;
       if( this->tempGamestate_ )
           delete this->tempGamestate_;
@@ -81,8 +81,8 @@
     packet::Gamestate *processed = processGamestate(tempGamestate_);
     assert(processed);
-    
+
     //now call the queued callbacks
     NetworkCallbackManager::callCallbacks();
-    
+
     if (!processed){
       sendAck(0);
@@ -126,5 +126,5 @@
         break;
       // otherwise delete that stuff
-      delete (*it).second;
+      delete it->second;
       temp=it++;
       gamestateMap_.erase(temp);
@@ -137,5 +137,5 @@
     COUT(4) << "gamestates: ";
     for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
-      COUT(4) << it->first << ":" << it->second << "|";
+      COUT(4) << it->first << ':' << it->second << '|';
     }
     COUT(4) << std::endl;
Index: code/branches/pickup2/src/libraries/network/GamestateHandler.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/GamestateHandler.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/GamestateHandler.cc	(revision 6412)
@@ -33,5 +33,5 @@
 
 GamestateHandler *GamestateHandler::instance_=0;
-  
+
 GamestateHandler::GamestateHandler()
 {
Index: code/branches/pickup2/src/libraries/network/GamestateHandler.h
===================================================================
--- code/branches/pickup2/src/libraries/network/GamestateHandler.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/GamestateHandler.h	(revision 6412)
@@ -35,5 +35,5 @@
 
 /**
-	@author Oliver Scheuss
+    @author Oliver Scheuss
 */
 class _NetworkExport GamestateHandler{
Index: code/branches/pickup2/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/GamestateManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/GamestateManager.cc	(revision 6412)
@@ -69,5 +69,5 @@
         delete this->reference;std::map<unsigned int, packet::Gamestate*>::iterator it;
     for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it )
-      delete (*it).second;
+      delete it->second;
     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator it1;
     std::map<unsigned int, packet::Gamestate*>::iterator it2;
@@ -75,5 +75,5 @@
     {
       for( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 )
-        delete (*it2).second;
+        delete it2->second;
     }
     this->trafficControl_->destroy();
@@ -126,5 +126,5 @@
     return true;
   }
-  
+
   void GamestateManager::sendGamestates()
   {
@@ -142,9 +142,9 @@
       COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
       int cid = temp->getID(); //get client id
-      
+
       unsigned int gID = temp->getGamestateID();
       if(!reference)
         return;
-      
+
       packet::Gamestate *client=0;
       if(gID != GAMESTATEID_INITIAL){
@@ -156,8 +156,8 @@
         }
       }
-      
+
       clientGamestates.push(0);
       finishGamestate( cid, &clientGamestates.back(), client, reference );
-      //FunctorMember<GamestateManager>* functor = 
+      //FunctorMember<GamestateManager>* functor =
 //       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
 //       executor->setDefaultValues( cid, &clientGamestates.back(), client, reference );
@@ -165,10 +165,10 @@
 //       this->threadPool_->passFunction( executor, true );
 //       (*functor)( cid, &(clientGamestates.back()), client, reference );
-      
+
       temp = temp->next();
     }
-    
+
 //     threadPool_->synchronise();
-    
+
     while( !clientGamestates.empty() )
     {
@@ -185,5 +185,5 @@
     // save the (undiffed) gamestate in the clients gamestate map
     //chose wheather the next gamestate is the first or not
-    
+
     packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
 //     packet::Gamestate *gs = new packet::Gamestate(*gamestate);
@@ -193,8 +193,8 @@
     gamestateMap_[clientID][gamestate->getID()]=gs;
 //     this->threadMutex_->unlock();
-    
+
     if(base)
     {
-        
+
 //       COUT(3) << "diffing" << std::endl;
 //       packet::Gamestate* gs1  = gs;
@@ -210,6 +210,6 @@
       gs = new packet::Gamestate(*gs);
     }
-    
-    
+
+
     bool b = gs->compressData();
     assert(b);
Index: code/branches/pickup2/src/libraries/network/Host.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/Host.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Host.cc	(revision 6412)
@@ -50,4 +50,6 @@
   assert(instance_==0);
   instance_=this;
+  this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" );
+  CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ );
 }
 
@@ -59,4 +61,6 @@
 {
   instance_=0;
+  if( this->printRTTCC_ )
+    delete this->printRTTCC_;
 }
 
Index: code/branches/pickup2/src/libraries/network/Host.h
===================================================================
--- code/branches/pickup2/src/libraries/network/Host.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Host.h	(revision 6412)
@@ -31,4 +31,5 @@
 
 #include "NetworkPrereqs.h"
+#include "core/CorePrereqs.h"
 
 namespace orxonox {
@@ -44,5 +45,5 @@
 *       - defines static functions available on both server and client
 *       - is the interface to be used when communicating with the network
-*	@author Oliver Scheuss
+*       @author Oliver Scheuss
 */
 class _NetworkExport Host{
@@ -79,5 +80,7 @@
     static bool Broadcast(const std::string& message);
     static bool incomingChat(const std::string& message, unsigned int playerID);
+    virtual void printRTT()=0;
   private:
+    ConsoleCommand* printRTTCC_;
 };
 
Index: code/branches/pickup2/src/libraries/network/NetworkFunction.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/NetworkFunction.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/NetworkFunction.cc	(revision 6412)
@@ -32,10 +32,6 @@
 namespace orxonox
 {
-  std::map<std::string, NetworkFunctionBase*> NetworkFunctionBase::nameMap_;
   std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_;
-  
-  std::map<NetworkFunctionPointer, NetworkFunctionStatic*> NetworkFunctionStatic::functorMap_;
-  std::map<uint32_t, NetworkFunctionStatic*> NetworkFunctionStatic::idMap_;
-      
+
   std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
   std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
@@ -44,54 +40,73 @@
   {
     RegisterRootObject(NetworkFunctionBase);
-    
+
     static uint32_t networkID = 0;
     this->networkID_ = networkID++;
-    
+
     this->name_ = name;
-    nameMap_[name] = this;
+    NetworkFunctionBase::getNameMap()[name] = this;
   }
   NetworkFunctionBase::~NetworkFunctionBase()
   {
   }
-  
-  
+
+
   void NetworkFunctionBase::destroyAllNetworkFunctions()
   {
+    std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
     std::map<std::string, NetworkFunctionBase*>::iterator it;
-    for( it=NetworkFunctionBase::nameMap_.begin(); it!=NetworkFunctionBase::nameMap_.end(); ++it )
+    for( it=map.begin(); it!=map.end(); ++it )
       it->second->destroy();
   }
-  
-  
+
+
+  /*static*/ std::map<std::string, NetworkFunctionBase*>& NetworkFunctionBase::getNameMap()
+  {
+    static std::map<std::string, NetworkFunctionBase*> nameMap_;
+    return nameMap_;
+  }
+
+
   NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p):
     NetworkFunctionBase(name)
   {
     RegisterObject(NetworkFunctionStatic);
-    
+
     this->functor_ = functor;
-    functorMap_[p] = this;
-    idMap_[ this->getNetworkID() ] = this;
+    NetworkFunctionStatic::getFunctorMap()[p] = this;
+    NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
   }
-  
+
   NetworkFunctionStatic::~NetworkFunctionStatic()
   {
     delete this->functor_;
   }
-  
-  
-  
+
+  /*static*/ std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& NetworkFunctionStatic::getFunctorMap()
+  {
+    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
+    return functorMap_;
+  }
+
+  /*static*/ std::map<uint32_t, NetworkFunctionStatic*>& NetworkFunctionStatic::getIdMap()
+  {
+    static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
+    return idMap_;
+  }
+
+
   NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
     NetworkFunctionBase(name)
   {
     RegisterObject(NetworkMemberFunctionBase);
-    
-    functorMap_[p] = this;
-    idMap_[ this->getNetworkID() ] = this;
+
+    this->functorMap_[p] = this;
+    this->idMap_[ this->getNetworkID() ] = this;
   }
-  
+
   NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
   {
   }
-  
+
 
 }
Index: code/branches/pickup2/src/libraries/network/NetworkFunction.h
===================================================================
--- code/branches/pickup2/src/libraries/network/NetworkFunction.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/NetworkFunction.h	(revision 6412)
@@ -74,22 +74,27 @@
     NetworkFunctionBase(const std::string& name);
     ~NetworkFunctionBase();
-    
+
     virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
     inline uint32_t     getNetworkID() const            { return this->networkID_; }
     inline const std::string& getName() const           { return name_; }
     static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
-    
-    static inline void setNetworkID(const std::string& name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }
-    
+
+    static inline void setNetworkID(const std::string& name, uint32_t id)
+    {
+        std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
+        assert( map.find(name)!=map.end() );
+        map[name]->setNetworkID(id);
+    }
+
     static void destroyAllNetworkFunctions();
-    
+
   protected:
     static std::map<uint32_t, bool> isStaticMap_;
-    
-  private:
-    static std::map<std::string, NetworkFunctionBase*> nameMap_;
+
+  private:
+    static std::map<std::string, NetworkFunctionBase*>& getNameMap();
     uint32_t networkID_;
     std::string name_;
-      
+
 };
 
@@ -99,5 +104,5 @@
     NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p);
     ~NetworkFunctionStatic();
-    
+
     inline void call(){ (*this->functor_)(); }
     inline void call(const MultiType& mt1){ (*this->functor_)(mt1); }
@@ -106,16 +111,19 @@
     inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); }
     inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); }
-    
-    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
-    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
-    static NetworkFunctionStatic* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
-    static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
-    
-  private:
-    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
-    static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
-    
+
+    virtual void setNetworkID( uint32_t id )
+        { NetworkFunctionBase::setNetworkID( id ); NetworkFunctionStatic::getIdMap()[id] = this; }
+    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id)
+        { assert( NetworkFunctionStatic::getIdMap().find(id)!=NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
+    static NetworkFunctionStatic* getFunction( uint32_t id )
+        { assert( NetworkFunctionStatic::getIdMap().find(id) != NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
+    static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p )
+        { assert( NetworkFunctionStatic::getFunctorMap().find(p) != NetworkFunctionStatic::getFunctorMap().end() ); return NetworkFunctionStatic::getFunctorMap()[p]; }
+
+  private:
+    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
+    static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
     FunctorStatic* functor_;
-    
+
 };
 
@@ -125,11 +133,11 @@
     NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
     ~NetworkMemberFunctionBase();
-    
+
     virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
     static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
     static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
     static NetworkMemberFunctionBase* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
-    
-    // 
+
+    //
     virtual void call(uint32_t objectID)=0;
     virtual void call(uint32_t objectID, const MultiType& mt1)=0;
@@ -138,5 +146,5 @@
     virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
     virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
-    
+
   private:
     static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_;
@@ -149,36 +157,36 @@
     NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p);
     ~NetworkMemberFunction();
-    
+
     inline void call(uint32_t objectID)
-    { 
+    {
       if ( Synchronisable::getSynchronisable(objectID)!=0 )
         (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)));
     }
     inline void call(uint32_t objectID, const MultiType& mt1)
-    { 
+    {
       if ( Synchronisable::getSynchronisable(objectID)!=0 )
         (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1);
     }
     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
-    { 
+    {
       if ( Synchronisable::getSynchronisable(objectID)!=0 )
         (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
     }
     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-    { 
+    {
       if ( Synchronisable::getSynchronisable(objectID)!=0 )
         (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
     }
     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-    { 
+    {
       if ( Synchronisable::getSynchronisable(objectID)!=0 )
         (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
     }
     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-    { 
+    {
       if ( Synchronisable::getSynchronisable(objectID)!=0 )
         (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
     }
-    
+
   private:
     FunctorMember<T>* functor_;
Index: code/branches/pickup2/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/branches/pickup2/src/libraries/network/NetworkPrereqs.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/NetworkPrereqs.h	(revision 6412)
@@ -144,4 +144,6 @@
   template <class T>
   class NetworkCallback;
+  template <class T, class U>
+  class NetworkCallbackNotify;
   class NetworkCallbackBase;
   class NetworkCallbackManager;
Index: code/branches/pickup2/src/libraries/network/Server.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/Server.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Server.cc	(revision 6412)
@@ -137,13 +137,13 @@
     // receive incoming packets
     Connection::processQueue();
-    
+
     if ( ClientInformation::hasClients() )
     {
       // process incoming gamestates
       GamestateManager::processGamestates();
-      
+
       // send function calls to clients
       FunctionCallManager::sendCalls();
-      
+
       //this steers our network frequency
       timeSinceLastUpdate_+=time.getDeltaTime();
@@ -160,11 +160,17 @@
     return ServerConnection::addPacket(packet, clientID);
   }
-  
-  /**
-   * @brief: returns ping time to client in milliseconds 
+
+  /**
+   * @brief: returns ping time to client in milliseconds
    */
-  unsigned int Server::getPing(unsigned int clientID){
+  unsigned int Server::getRTT(unsigned int clientID){
     assert(ClientInformation::findClient(clientID));
     return ClientInformation::findClient(clientID)->getRTT();
+  }
+
+  void Server::printRTT()
+  {
+    for( ClientInformation* temp=ClientInformation::getBegin(); temp!=0; temp=temp->next() )
+      COUT(0) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;
   }
 
@@ -299,5 +305,5 @@
     {
       //ServerConnection::disconnectClient( client );
-      ClientConnectionListener::broadcastClientDisconnected( client->getID() );
+      //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now
       delete client;
     }
@@ -311,8 +317,8 @@
     }
     COUT(5) << "Con.Man: creating client id: " << temp->getID() << std::endl;
-    
+
     // synchronise class ids
     syncClassid(temp->getID());
-    
+
     // now synchronise functionIDs
     packet::FunctionIDs *fIDs = new packet::FunctionIDs();
@@ -320,5 +326,5 @@
     bool b = fIDs->send();
     assert(b);
-    
+
     temp->setSynched(true);
     COUT(4) << "sending welcome" << std::endl;
@@ -338,10 +344,10 @@
     return true;
   }
-  
+
   void Server::disconnectClient( ClientInformation *client ){
     ServerConnection::disconnectClient( client );
     GamestateManager::removeClient(client);
     // inform all the listeners
-    ClientConnectionListener::broadcastClientDisconnected(client->getID());
+    // ClientConnectionListener::broadcastClientDisconnected(client->getID()); // this is done in ClientInformation now
   }
 
Index: code/branches/pickup2/src/libraries/network/Server.h
===================================================================
--- code/branches/pickup2/src/libraries/network/Server.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/Server.h	(revision 6412)
@@ -57,5 +57,6 @@
     bool queuePacket(ENetPacket *packet, int clientID);
     void update(const Clock& time);
-    unsigned int getPing(unsigned int clientID);
+    unsigned int getRTT(unsigned int clientID);
+    virtual void printRTT();
     double getPacketLoss(unsigned int clientID);
   protected:
@@ -65,8 +66,8 @@
     unsigned int shipID(){return 0;}
     unsigned int playerID(){return 0;}
-    
+
     void addPeer(ENetEvent *event);
     void removePeer(ENetEvent *event);
-    
+
     bool createClient(int clientID);
     void disconnectClient( ClientInformation *client);
Index: code/branches/pickup2/src/libraries/network/ServerConnection.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/ServerConnection.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/ServerConnection.cc	(revision 6412)
@@ -99,10 +99,10 @@
     return true;
   }
-  
+
   void ServerConnection::disconnectClient(ClientInformation *client)
   {
     Connection::disconnectPeer( client->getPeer() );
   }
-  
+
   void ServerConnection::disconnectClient(int clientID){
     ClientInformation *client = ClientInformation::findClient(clientID);
Index: code/branches/pickup2/src/libraries/network/ServerConnection.h
===================================================================
--- code/branches/pickup2/src/libraries/network/ServerConnection.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/ServerConnection.h	(revision 6412)
@@ -50,8 +50,8 @@
   public:
     ~ServerConnection();
-    
+
     void setBindAddress( const std::string& bindAddress );
     void setPort( unsigned int port );
-    
+
     bool openListener();
     bool closeListener();
Index: code/branches/pickup2/src/libraries/network/TrafficControl.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/TrafficControl.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/TrafficControl.cc	(revision 6412)
@@ -64,24 +64,24 @@
 *Initializing protected members
 */
-	TrafficControl *TrafficControl::instance_=0;
-
-	/**
-	* @brief Constructor: assures that only one reference will be created and sets the pointer
-	*/
-	TrafficControl::TrafficControl()
-	{
+    TrafficControl *TrafficControl::instance_=0;
+
+    /**
+    * @brief Constructor: assures that only one reference will be created and sets the pointer
+    */
+    TrafficControl::TrafficControl()
+    {
     RegisterObject(TrafficControl);
-	  assert(instance_==0);
-	  instance_=this;
+      assert(instance_==0);
+      instance_=this;
     this->setConfigValues();
-	}
-
-	/**
-	* @brief Destructor: resets the instance pointer to 0
-	*/
-	TrafficControl::~TrafficControl()
-	{
-	  instance_=0;
-	}
+    }
+
+    /**
+    * @brief Destructor: resets the instance pointer to 0
+    */
+    TrafficControl::~TrafficControl()
+    {
+      instance_=0;
+    }
 
 /**
@@ -121,11 +121,11 @@
 
 
-	void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list)
-	{
-	  currentClientID=clientID;
-	  currentGamestateID=gamestateID;
-	  evaluateList(clientID, list);
-	  return;
-	}
+    void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list)
+    {
+      currentClientID=clientID;
+      currentGamestateID=gamestateID;
+      evaluateList(clientID, list);
+      return;
+    }
 
   TrafficControl *TrafficControl::getInstance()
@@ -135,9 +135,9 @@
   }
 
-	void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
-	{
+    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
+      std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
 
     //assertions to make sure the maps already exist
@@ -145,5 +145,5 @@
     assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
     assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
-    
+
     // shortcut for maps
     std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
@@ -151,22 +151,22 @@
 
     for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
-	  {
-      if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists
-      {
-        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
-        objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back
+      {
+      if(objectListPerm.find(itvec->objID) != objectListPerm.end()) // check whether the obj already exists in our lists
+      {
+        objectListPerm[itvec->objID].objCurGS = gamestateID;
+        objectListPerm[itvec->objID].objValueSched = 0; //set scheduling value back
       }
       else
       {
         assert(0);
-        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
-        objectListPerm[(*itvec).objID].objID = (*itvec).objID;
-        objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
-        objectListPerm[(*itvec).objID].objSize = (*itvec).objSize;
-      }
-	  }
-	   // remove temporary list (with acked objects) from the map
+        objectListPerm[itvec->objID].objCurGS = gamestateID;
+        objectListPerm[itvec->objID].objID = itvec->objID;
+        objectListPerm[itvec->objID].objCreatorID = itvec->objCreatorID;
+        objectListPerm[itvec->objID].objSize = itvec->objSize;
+      }
+      }
+       // remove temporary list (with acked objects) from the map
     objectListTemp.erase( objectListTemp.find(gamestateID) );
-	}
+    }
 
 /**
@@ -174,14 +174,14 @@
 */
 
-	/**
-	*updateClientListPerm
-	*returns void
-	*/
-	void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf)
-	{
-	  std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
+    /**
+    *updateClientListPerm
+    *returns void
+    */
+    void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf)
+    {
+      std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
     unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0;
     clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom);
-	}
+    }
 
   /**
@@ -205,13 +205,13 @@
     for(itvec = list.begin(); itvec != list.end();)
     {
-      assert( (*itvec).objSize < 1000);
-      if ( ( size + (*itvec).objSize ) < targetsize )
-      {
-        size += (*itvec).objSize;//objSize is given in bytes
+      assert( itvec->objSize < 1000);
+      if ( ( size + itvec->objSize ) < targetsize )
+      {
+        size += itvec->objSize;//objSize is given in bytes
         ++itvec;
       }
       else
       {
-        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
+        clientListPerm_[currentClientID][itvec->objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
         list.erase(itvec, list.end());
         break;
@@ -223,9 +223,9 @@
 
 
-	/**
-	*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
-	*/
-	void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list)
-	{
+    /**
+    *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
+    */
+    void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list)
+    {
 
     if( bActive_ )
@@ -236,14 +236,14 @@
       //if listToProcess contains new Objects, add them to clientListPerm
       std::list<obj>::iterator itvec;
-    
+
       std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
-    
+
       for( itvec=list.begin(); itvec != list.end(); itvec++)
       {
-        if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
+        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;
+          objectListPerm[itvec->objID].objDiffGS = currentGamestateID - objectListPerm[itvec->objID].objCurGS;
           continue;//check next objId
         }
@@ -256,10 +256,10 @@
       }
     //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
 //       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
       list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
-      
+
 //       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
 
@@ -277,5 +277,5 @@
 //       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);
@@ -289,17 +289,17 @@
     COUT(0) << "=========== Objectlist ===========" << endl;
     for( it=list.begin(); it!=list.end(); it++)
-      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
+      COUT(0) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl;
   }
 
   void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
   {
-    if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
-      return;
-    if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
+    if ( it1->objCreatorID == OBJECTID_UNKNOWN )
+      return;
+    if( clientListPerm_[clientID][it1->objCreatorID].objCurGS != GAMESTATEID_INITIAL )
       return;
     std::list<obj>::iterator it2, it3=it1;
     for( it2 = ++it3; it2 != list.end(); it2++ )
     {
-      if( (*it2).objID == (*it1).objCreatorID )
+      if( it2->objID == it1->objCreatorID )
       {
         it3 = list.insert(it1, *it2); //insert creator before it1
Index: code/branches/pickup2/src/libraries/network/TrafficControl.h
===================================================================
--- code/branches/pickup2/src/libraries/network/TrafficControl.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/TrafficControl.h	(revision 6412)
@@ -69,5 +69,5 @@
       obj( uint32_t ID, uint32_t creatorID, uint32_t size, uint32_t offset );
   };
-  
+
 
 
@@ -97,7 +97,7 @@
     unsigned int targetSize;
     bool         bActive_;
-    
+
     void insertinClientListPerm(unsigned int clientID, obj objinf);
-    
+
     void cut(std::list<obj>& list, unsigned int targetsize);
     void updateClientListTemp(std::list<obj>& list);//done
@@ -105,12 +105,12 @@
     *evaluates Data given (list) and produces result(->Data to be updated)
     */
-    void evaluateList(unsigned int clientID, std::list<obj>& list);//done    
+    void evaluateList(unsigned int clientID, std::list<obj>& list);//done
     void ack(unsigned int clientID, unsigned int gamestateID);  // this function gets called when the server receives an ack from the client
-    
+
     //ClientConnectionListener functions
     virtual void clientConnected(unsigned int clientID){};
     virtual void clientDisconnected(unsigned int clientID);
 
- 
+
   protected:
     static TrafficControl *instance_;
@@ -121,5 +121,5 @@
     /**
     *is being used by GSManager from Server:
-    *list contains: ObjIds, CreatorIds, Size (in this order) from Client XY 
+    *list contains: ObjIds, CreatorIds, Size (in this order) from Client XY
     *Elements of list are accessed by *list[i]
     *Elements of struct i are therefore: *list[i].objID
@@ -130,6 +130,6 @@
     static void processAck(unsigned int clientID, unsigned int gamestateID)
     { return instance_->ack(clientID, gamestateID); }
-    void deleteObject(unsigned int objectID);				// this function gets called when an object has been deleted (in order to clean up lists and maps)
-    
+    void deleteObject(unsigned int objectID);               // this function gets called when an object has been deleted (in order to clean up lists and maps)
+
     bool prioritySort(uint32_t clientID, obj i, obj j);
     bool dataSort(obj i, obj j);
Index: code/branches/pickup2/src/libraries/network/packet/Acknowledgement.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Acknowledgement.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Acknowledgement.cc	(revision 6412)
@@ -38,5 +38,5 @@
 #define _PACKETID           0
 #define _ACKID              _PACKETID + sizeof(packet::Type::Value)
-  
+
 Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID )
  : Packet()
Index: code/branches/pickup2/src/libraries/network/packet/Acknowledgement.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Acknowledgement.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Acknowledgement.h	(revision 6412)
@@ -37,5 +37,5 @@
 namespace packet {
 /**
-	@author
+    @author
 */
 class _NetworkExport Acknowledgement : public Packet
Index: code/branches/pickup2/src/libraries/network/packet/Chat.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Chat.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Chat.cc	(revision 6412)
@@ -35,5 +35,5 @@
 namespace orxonox {
 namespace packet {
-  
+
 #define   PACKET_FLAGS_CHAT PacketFlag::Reliable
 #define   _PACKETID         0
Index: code/branches/pickup2/src/libraries/network/packet/Chat.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Chat.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Chat.h	(revision 6412)
@@ -36,5 +36,5 @@
 namespace packet {
 /**
-	@author
+    @author
 */
 class _NetworkExport Chat : public Packet
Index: code/branches/pickup2/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/ClassID.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/ClassID.cc	(revision 6412)
@@ -48,5 +48,4 @@
 ClassID::ClassID( ) : Packet(){
   Identifier *id;
-  std::string classname;
   unsigned int nrOfClasses=0;
   unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
@@ -58,8 +57,8 @@
   std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin();
   for(;it != Identifier::getStringIdentifierMapEnd();++it){
-    id = (*it).second;
+    id = it->second;
     if(id == NULL || !id->hasFactory())
       continue;
-    classname = id->getName();
+    const std::string& classname = id->getName();
     network_id = id->getNetworkID();
     // now push the network id and the classname to the stack
Index: code/branches/pickup2/src/libraries/network/packet/ClassID.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/ClassID.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/ClassID.h	(revision 6412)
@@ -36,7 +36,7 @@
 namespace packet {
 
-  
+
 /**
-	@author
+    @author
 */
 class _NetworkExport ClassID : public Packet
Index: code/branches/pickup2/src/libraries/network/packet/DeleteObjects.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/DeleteObjects.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/DeleteObjects.cc	(revision 6412)
@@ -41,5 +41,5 @@
 #define _QUANTITY           _PACKETID + sizeof(Type::Value)
 #define _OBJECTIDS          _QUANTITY + sizeof(uint32_t)
-  
+
 DeleteObjects::DeleteObjects()
  : Packet()
@@ -71,7 +71,6 @@
   for(unsigned int i=0; i<number; i++){
     unsigned int temp = Synchronisable::popDeletedObject();
-//     assert(temp<10000); //ugly hack
     *reinterpret_cast<uint32_t*>(tdata) = temp;
-    COUT(4) << temp << " ";
+    COUT(4) << temp << ' ';
     tdata += sizeof(uint32_t);
   }
Index: code/branches/pickup2/src/libraries/network/packet/DeleteObjects.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/DeleteObjects.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/DeleteObjects.h	(revision 6412)
@@ -35,5 +35,5 @@
 namespace packet {
 /**
-	@author
+    @author
 */
 class _NetworkExport DeleteObjects : public Packet
Index: code/branches/pickup2/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/FunctionCalls.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/FunctionCalls.cc	(revision 6412)
@@ -36,9 +36,9 @@
 namespace orxonox {
 namespace packet {
-  
+
 #define   PACKET_FLAGS_FUNCTIONCALLS PacketFlag::Reliable
 #define   _PACKETID         0
 const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000;
-    
+
 FunctionCalls::FunctionCalls()
  : Packet()
@@ -171,5 +171,5 @@
 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
   assert(!isDataENetAllocated());
-  
+
   // first determine the size that has to be reserved for this call
   uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
@@ -200,5 +200,5 @@
     }
   }
-  
+
   // now allocated mem if neccessary
   if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION )
@@ -210,5 +210,5 @@
     data_ = temp;
   }
-  
+
   // now serialise the mt values and copy the function id and isStatic
   uint8_t* temp = data_+currentSize_;
@@ -240,10 +240,10 @@
   //currentSize_ += callsize;
   currentSize_ = temp-data_;
-  
+
 }
 
 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
   assert(!isDataENetAllocated());
-  
+
   // first determine the size that has to be reserved for this call
   uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID
@@ -274,5 +274,5 @@
     }
   }
-  
+
   // now allocated mem if neccessary
   if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION )
@@ -284,5 +284,5 @@
     data_ = temp;
   }
-  
+
   // now serialise the mt values and copy the function id
   uint8_t* temp = data_+currentSize_;
@@ -314,5 +314,5 @@
   }
   currentSize_ += callsize;
-  
+
 }
 
Index: code/branches/pickup2/src/libraries/network/packet/FunctionCalls.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/FunctionCalls.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/FunctionCalls.h	(revision 6412)
@@ -40,5 +40,5 @@
 namespace packet {
 /**
-	@author
+    @author
 */
 
Index: code/branches/pickup2/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/FunctionIDs.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/FunctionIDs.cc	(revision 6412)
@@ -47,15 +47,14 @@
 
 FunctionIDs::FunctionIDs( ) : Packet(){
-  std::string functionname;
-  unsigned int nrOfFunctions=0; 
+  unsigned int nrOfFunctions=0;
   unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nroffunctions
   uint32_t networkID;
   flags_ = flags_ | PACKET_FLAGS_FUNCTIONIDS;
   std::queue<std::pair<uint32_t, std::string> > tempQueue;
-  
+
   //calculate total needed size (for all strings and integers)
   ObjectList<NetworkFunctionBase>::iterator it;
   for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it){
-    functionname = it->getName();
+    const std::string& functionname = it->getName();
     networkID = it->getNetworkID();
     // now push the network id and the classname to the stack
@@ -64,15 +63,15 @@
     packetSize += (functionname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); // reserver size for the functionname string, the functionname length and the networkID
   }
-  
+
   this->data_=new uint8_t[ packetSize ];
   //set the appropriate packet id
   assert(this->data_);
   *(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs;
-  
+
   uint8_t *temp=data_+sizeof(uint32_t);
   // save the number of all classes
   *(uint32_t*)temp = nrOfFunctions;
   temp += sizeof(uint32_t);
-  
+
   // now save all classids and classnames
   std::pair<uint32_t, std::string> tempPair;
@@ -85,7 +84,7 @@
     temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
   }
-  
+
   COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;
-  
+
 }
 
@@ -106,5 +105,5 @@
   temp += sizeof(uint32_t);
   totalsize += sizeof(uint32_t); // storage size for nr of all classes
-  
+
   for(unsigned int i=0; i<nrOfFunctions; i++){
     totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); // for each network function add size for id, sizeof(string) and length of string itself to totalsize
@@ -121,5 +120,5 @@
   uint32_t stringsize;
   unsigned char *functionname;
-  
+
   COUT(4) << "=== processing functionids: " << endl;
   std::pair<uint32_t, std::string> tempPair;
@@ -127,5 +126,5 @@
   nrOfFunctions = *(uint32_t*)temp;
   temp += sizeof(uint32_t);
-  
+
   for( int i=0; i<nrOfFunctions; i++){
     networkID = *(uint32_t*)temp;
Index: code/branches/pickup2/src/libraries/network/packet/FunctionIDs.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/FunctionIDs.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/FunctionIDs.h	(revision 6412)
@@ -36,7 +36,7 @@
 namespace packet {
 
-  
+
 /**
-	@author
+    @author
 */
 class _NetworkExport FunctionIDs : public Packet
Index: code/branches/pickup2/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Gamestate.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Gamestate.cc	(revision 6412)
@@ -95,5 +95,5 @@
     return false;
   }
-  
+
   // create the header object
   assert( header_ == 0 );
@@ -105,5 +105,5 @@
   ObjectList<Synchronisable>::iterator it;
   for(it = ObjectList<Synchronisable>::begin(); it; ++it){
-    
+
 //     tempsize=it->getSize(id, mode);
 
@@ -111,5 +111,5 @@
     if ( tempsize != 0 )
       dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
-    
+
 #ifndef NDEBUG
     if(currentsize+tempsize > size){
@@ -362,15 +362,15 @@
   assert(!header_->isCompressed() && !base->header_->isCompressed());
   assert(!header_->isDiffed());
-  
+
   uint8_t *basep = GAMESTATE_START(base->data_);
   uint8_t *gs = GAMESTATE_START(this->data_);
   uint32_t dest_length = header_->getDataSize();
-  
+
   if(dest_length==0)
     return NULL;
-  
+
   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
   uint8_t *dest = GAMESTATE_START(ndata);
-  
+
   rawDiff( dest, gs, basep, header_->getDataSize(), base->header_->getDataSize() );
 #ifndef NDEBUG
@@ -398,17 +398,17 @@
   assert(!header_->isCompressed() && !base->header_->isCompressed());
   assert(header_->isDiffed());
-  
+
   uint8_t *basep = GAMESTATE_START(base->data_);
   uint8_t *gs = GAMESTATE_START(this->data_);
   uint32_t dest_length = header_->getDataSize();
-  
+
   if(dest_length==0)
     return NULL;
-  
+
   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
   uint8_t *dest = ndata + GamestateHeader::getSize();
-  
+
   rawDiff( dest, gs, basep, header_->getDataSize(), base->header_->getDataSize() );
-  
+
   Gamestate *g = new Gamestate(ndata, getClientID());
   assert(g->header_);
@@ -437,6 +437,6 @@
 //   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
 //   uint8_t *dest = ndata + GamestateHeader::getSize();
-//   
-//   
+//
+//
 //   // LOOP-UNROLLED DIFFING
 //   uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs;
@@ -465,5 +465,5 @@
 //     }
 //   }
-// 
+//
 //   Gamestate *g = new Gamestate(ndata, getClientID());
 //   *(g->header_) = *header_;
@@ -481,5 +481,5 @@
   uint64_t* bd = (uint64_t*)basedata;
   uint64_t* nd = (uint64_t*)newdata;
-  
+
   unsigned int i;
   for( i=0; i<datalength/8; i++ )
@@ -529,10 +529,10 @@
 //   COUT(0) << "myvector contains:";
 //   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
-//     COUT(0) << " " << (*itt).objID;
+//     COUT(0) << ' ' << (*itt).objID;
 //   COUT(0) << endl;
   for(it=dataVector_.begin(); it!=dataVector_.end();){
     SynchronisableHeader oldobjectheader(origdata);
     SynchronisableHeader newobjectheader(newdata);
-    if ( (*it).objSize == 0 )
+    if ( it->objSize == 0 )
     {
       ++it;
@@ -541,5 +541,5 @@
     objectsize = oldobjectheader.getDataSize();
     objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
-    if ( (*it).objID == oldobjectheader.getObjectID() ){
+    if ( it->objID == oldobjectheader.getObjectID() ){
       memcpy(newdata, origdata, objectsize);
       assert(newobjectheader.isDataAvailable()==true);
Index: code/branches/pickup2/src/libraries/network/packet/Gamestate.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Gamestate.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Gamestate.h	(revision 6412)
@@ -96,5 +96,5 @@
 
 /**
-	@author Oliver Scheuss
+    @author Oliver Scheuss
 */
 class _NetworkExport Gamestate: public Packet{
Index: code/branches/pickup2/src/libraries/network/packet/Packet.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Packet.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Packet.cc	(revision 6412)
@@ -101,6 +101,6 @@
 @brief
     Destroys a packet completely.
-    
-    That also means destroying the ENetPacket if one exists. There 
+
+    That also means destroying the ENetPacket if one exists. There
 */
 Packet::~Packet(){
@@ -230,5 +230,5 @@
 */
 void Packet::deletePacket(ENetPacket *enetPacket){
-  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
+  // Get our Packet from a global map with all Packets created in the send() method of Packet.
   std::map<size_t, Packet*>::iterator it = packetMap_.find(reinterpret_cast<size_t>(enetPacket));
   assert(it != packetMap_.end());
Index: code/branches/pickup2/src/libraries/network/packet/Packet.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Packet.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Packet.h	(revision 6412)
@@ -57,5 +57,5 @@
 
 /**
-	@author Oliver Scheuss <scheusso [at] ee.ethz.ch>
+    @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
 */
 class _NetworkExport Packet{
Index: code/branches/pickup2/src/libraries/network/packet/Welcome.h
===================================================================
--- code/branches/pickup2/src/libraries/network/packet/Welcome.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/packet/Welcome.h	(revision 6412)
@@ -36,5 +36,5 @@
 
 /**
-	@author
+    @author
 */
 class _NetworkExport Welcome : public Packet
Index: code/branches/pickup2/src/libraries/network/synchronisable/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/CMakeLists.txt	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/synchronisable/CMakeLists.txt	(revision 6412)
@@ -2,5 +2,4 @@
   NetworkCallbackManager.cc
   Synchronisable.cc
-  SynchronisableSpecialisations.cc
   SynchronisableVariable.cc
 )
Index: code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallback.h
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallback.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallback.h	(revision 6412)
@@ -33,7 +33,10 @@
 #include "network/NetworkPrereqs.h"
 #include "NetworkCallbackManager.h"
+// #include "util/MultiType.h"
 
 namespace orxonox{
-  
+
+  struct EmptyType{};
+
   class _NetworkExport NetworkCallbackBase
   {
@@ -49,5 +52,5 @@
     public:
       NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {}
-	  virtual ~NetworkCallback() {}
+      virtual ~NetworkCallback() {}
       virtual void call()
         { (this->object_->*function_)(); }
@@ -58,4 +61,20 @@
   };
 
+  template <class T, class U>
+  class NetworkCallbackNotify: public NetworkCallbackBase
+  {
+    public:
+      NetworkCallbackNotify(T* object, void (T::*function) (const U&)) : object_(object), function_(function) {}
+      NetworkCallbackNotify() {}
+      virtual ~NetworkCallbackNotify() {}
+      virtual void call()
+        { (this->object_->*function_)( this->oldValue_ ); }
+      void setOldValue(const U& value){ this->oldValue_ = value; }
+    private:
+      T* object_;
+      U oldValue_;
+      void (T::*function_) (const U&);
+  };
+
 }
 
Index: code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallbackManager.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallbackManager.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallbackManager.cc	(revision 6412)
@@ -26,16 +26,16 @@
  *
  */
- 
+
 #include "NetworkCallbackManager.h"
 #include "NetworkCallback.h"
 
 namespace orxonox{
-  
+
   std::set<NetworkCallbackBase*> NetworkCallbackManager::callbackSet_;
   std::queue<NetworkCallbackBase*> NetworkCallbackManager::triggeredCallbacks_;
-  
+
   void NetworkCallbackManager::registerCallback(NetworkCallbackBase *cb)
-  { 
-    callbackSet_.insert(cb); 
+  {
+    callbackSet_.insert(cb);
   }
   void NetworkCallbackManager::deleteCallback(NetworkCallbackBase *cb)
@@ -48,5 +48,5 @@
     }
   }
-  
+
   void NetworkCallbackManager::triggerCallback(NetworkCallbackBase *cb)
   {
Index: code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallbackManager.h
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallbackManager.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/synchronisable/NetworkCallbackManager.h	(revision 6412)
@@ -37,5 +37,5 @@
 
 namespace orxonox{
-  
+
   class _NetworkExport NetworkCallbackManager{
     public:
@@ -48,5 +48,5 @@
       static std::queue<NetworkCallbackBase*> triggeredCallbacks_;
   };
-  
+
 
 }
Index: code/branches/pickup2/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/Serialise.h	(revision 6412)
+++ code/branches/pickup2/src/libraries/network/synchronisable/Serialise.h	(revision 6412)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Functions to serialise pointers to objects that inherit from Synchronisable
+*/
+
+#ifndef _NetworkSerialise_H__
+#define _NetworkSerialise_H__
+
+#include "util/Serialise.h"
+#include "util/TypeTraits.h"
+#include "core/CorePrereqs.h"
+
+namespace orxonox{
+    
+    // These functions implement loading / saving / etc. for pointer types
+    
+    /** @brief returns the size of the objectID needed to synchronise the pointer */
+    template <class T> inline uint32_t returnSize( T*& variable )
+    {
+      return sizeof(uint32_t);
+    }
+    
+    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
+    template <class T> inline void loadAndIncrease( T*& variable, uint8_t*& mem )
+    {
+        *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
+        mem += returnSize( variable );
+    }
+    
+    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
+    template <class T> inline void saveAndIncrease( T*& variable, uint8_t*& mem )
+    {
+        if ( variable )
+            *(uint32_t*)(mem) = static_cast<uint32_t>(variable->getObjectID());
+        else
+            *(uint32_t*)(mem) = OBJECTID_UNKNOWN;
+        mem += returnSize( variable );
+    }
+    
+    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
+    template <class T> inline  bool checkEquality( T*& variable, uint8_t* mem )
+    {
+        if ( variable )
+            return *(uint32_t*)(mem) == variable->getObjectID();
+        else
+            return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
+    }
+}
+
+
+#endif
Index: code/branches/pickup2/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/Synchronisable.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/synchronisable/Synchronisable.cc	(revision 6412)
@@ -62,5 +62,5 @@
     }
     classID_ = static_cast<uint32_t>(-1);
-    
+
     // set dataSize to 0
     this->dataSize_ = 0;
@@ -277,5 +277,5 @@
       //tempsize += (*i)->getSize( mode );
     }
-    
+
     tempsize += SynchronisableHeader::getSize();
     header.setObjectID( this->objectID_ );
@@ -284,5 +284,5 @@
     header.setDataAvailable( true );
     header.setDataSize( tempsize );
-    
+
 #ifndef NDEBUG
     uint32_t size;
@@ -390,4 +390,15 @@
   }
 
+  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+  {
+    SynchronisableVariableBase* sv;
+    if (bidirectional)
+      sv = new SynchronisableVariableBidirectional<std::string>(variable, mode, cb);
+    else
+      sv = new SynchronisableVariable<std::string>(variable, mode, cb);
+    syncList.push_back(sv);
+    stringList.push_back(sv);
+  }
+
 
 }
Index: code/branches/pickup2/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/Synchronisable.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/synchronisable/Synchronisable.h	(revision 6412)
@@ -66,6 +66,6 @@
 
   /**
-   * @brief: stores information about a Synchronisable 
-   * 
+   * @brief: stores information about a Synchronisable
+   *
    * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
    * in an emulated bitset.
@@ -132,5 +132,5 @@
     inline unsigned int getPriority() const { return this->objectFrequency_;}
     inline uint8_t getSyncMode() const { return this->objectMode_; }
-    
+
     void setSyncMode(uint8_t mode);
 
@@ -138,5 +138,5 @@
     Synchronisable(BaseObject* creator);
     template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
-    //template <class T> void unregisterVariable(T& var);
+
     void setPriority(unsigned int freq){ objectFrequency_ = freq; }
 
@@ -148,5 +148,5 @@
     bool isMyData(uint8_t* mem);
     bool doSync(int32_t id, uint8_t mode=0x0);
-    
+
     inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; }
     inline void setClassID(uint32_t id){ this->classID_ = id; }
@@ -167,54 +167,22 @@
   };
 
-  // ================= Specialisation declarations
-  
-//   template <> _NetworkExport void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-  
   template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
   {
     if (bidirectional)
     {
-      syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
+      syncList.push_back(new SynchronisableVariableBidirectional<T>(variable, mode, cb));
       this->dataSize_ += syncList.back()->getSize(state_);
     }
     else
     {
-      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
+      syncList.push_back(new SynchronisableVariable<T>(variable, mode, cb));
       if ( this->state_ == mode )
         this->dataSize_ += syncList.back()->getSize(state_);
     }
   }
-  
+
+  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
 
 
-//   template <class T> void Synchronisable::unregisterVariable(T& var){
-//     std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin();
-//     while(it!=syncList.end()){
-//       if( ((*it)->getReference()) == &var ){
-//         delete (*it);
-//         syncList.erase(it);
-//         return;
-//       }
-//       else
-//         it++;
-//     }
-//     bool unregistered_nonexistent_variable = false;
-//     assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
-//     // the variable has not been registered before
-//   }
-
-  
 }
 
Index: code/branches/pickup2/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc	(revision 6405)
+++ 	(revision )
@@ -1,111 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Dumeni Manatschal, (C) 2007
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
-
-#include <string>
-#include "util/Math.h"
-#include "Synchronisable.h"
-#include "SynchronisableVariable.h"
-
-// ================ template spezialisation
-  
-  
-namespace orxonox{
-  
-  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
-  {
-    SynchronisableVariableBase* sv;
-    if (bidirectional)
-      sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb);
-    else
-      sv = new SynchronisableVariable<const std::string>(variable, mode, cb);
-    syncList.push_back(sv);
-    stringList.push_back(sv);
-  }
-  
-  template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable(variable.r, mode, cb, bidirectional);
-    registerVariable(variable.g, mode, cb, bidirectional);
-    registerVariable(variable.b, mode, cb, bidirectional);
-    registerVariable(variable.a, mode, cb, bidirectional);
-  }
-  template <> void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    return Synchronisable::registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
-  }
-
-  template <> void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable(variable.x, mode, cb, bidirectional);
-    registerVariable(variable.y, mode, cb, bidirectional);
-  }
-  
-  template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable(variable.x, mode, cb, bidirectional);
-    registerVariable(variable.y, mode, cb, bidirectional);
-    registerVariable(variable.z, mode, cb, bidirectional);
-  }
-  template <> void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable( (const Vector3&)variable, mode, cb, bidirectional);
-  }
-
-  template <> void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable(variable.x, mode, cb, bidirectional);
-    registerVariable(variable.y, mode, cb, bidirectional);
-    registerVariable(variable.z, mode, cb, bidirectional);
-    registerVariable(variable.w, mode, cb, bidirectional);
-  }
-  template <> void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable( (const Vector4&)variable, mode, cb, bidirectional);
-  }
-  
-  template <> void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable(variable.getMemory(), mode, cb, bidirectional);
-  }
-  
-  template <> void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable(variable.x, mode, cb, bidirectional);
-    registerVariable(variable.y, mode, cb, bidirectional);
-    registerVariable(variable.z, mode, cb, bidirectional);
-    registerVariable(variable.w, mode, cb, bidirectional);
-  }
-  template <> void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable( (const Quaternion&)variable, mode, cb, bidirectional);
-  }
-
-  
-
-} //namespace
Index: code/branches/pickup2/src/libraries/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/branches/pickup2/src/libraries/network/synchronisable/SynchronisableVariable.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/network/synchronisable/SynchronisableVariable.h	(revision 6412)
@@ -35,5 +35,5 @@
 #include <cassert>
 #include <cstring>
-#include "util/Serialise.h"
+#include "Serialise.h"
 #include "util/TypeTraits.h"
 #include "core/GameMode.h"
@@ -41,5 +41,5 @@
 
 namespace orxonox{
-  
+
   namespace VariableDirection{
     enum Value{
@@ -54,5 +54,5 @@
     };
   }
-  
+
   class _NetworkExport SynchronisableVariableBase
   {
@@ -81,10 +81,9 @@
       virtual inline void* getReference(){ return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); }
     protected:
-      
-      T& variable_;
-      uint8_t mode_;
-      NetworkCallbackBase *callback_;
+      T&                       variable_;
+      uint8_t                  mode_;
+      NetworkCallbackBase      *callback_;
   };
-  
+
   template <class T>
   class SynchronisableVariableBidirectional: public SynchronisableVariable<T>
@@ -93,5 +92,5 @@
       SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
       virtual ~SynchronisableVariableBidirectional();
-      
+
       virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
       virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
@@ -113,8 +112,8 @@
     }
   }
-  
+
   template <class T> SynchronisableVariable<T>::~SynchronisableVariable()
   {
-    if (this->callback_ != 0)
+    if (this->callback_)
     {
       NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
@@ -141,14 +140,15 @@
       return;
   // check whether we need to consider a callback
-    if ( this->callback_ != 0 )
-    {
-      if( forceCallback || !checkEquality( this->variable_, mem ) )
-        callback = true;
+    if ( this->callback_ )
+    {
+      callback = forceCallback || !checkEquality( this->variable_, mem );
+    }
+  // now do a callback if neccessary
+    if ( callback )
+    {
+      NetworkCallbackManager::triggerCallback( this->callback_ );
     }
   // write the data
     loadAndIncrease( this->variable_, mem );
-  // now do a callback if neccessary
-    if ( callback )
-      NetworkCallbackManager::triggerCallback( this->callback_ );
   }
 
@@ -216,5 +216,5 @@
             mem += sizeof(varReference_);
             memcpy(static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->varBuffer_)), &this->variable_, sizeof(T));
-            if ( this->callback_ != 0 )
+            if ( this->callback_ )
               callback = true;
           }
@@ -235,14 +235,16 @@
           {
             // value changed so remark for callback
-            if ( this->callback_ != 0 )
+            if ( this->callback_ )
               callback = true;
           }
         }
       }
+  // now do a callback if neccessary
+      if ( callback )
+      {
+        NetworkCallbackManager::triggerCallback( this->callback_ );
+      }
   // now write the data
       loadAndIncrease(this->variable_, mem);
-  // now do a callback if neccessary
-      if ( callback )
-        NetworkCallbackManager::triggerCallback( this->callback_ );
     }
 
@@ -251,5 +253,5 @@
       return returnSize( this->variable_ ) + sizeof(varReference_);
     }
-  
+
 
 }
Index: code/branches/pickup2/src/libraries/tools/BillboardSet.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/BillboardSet.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/BillboardSet.cc	(revision 6412)
@@ -38,5 +38,4 @@
 #include "util/Convert.h"
 #include "util/Math.h"
-#include "util/StringUtils.h"
 #include "core/GameMode.h"
 
@@ -81,5 +80,5 @@
         catch (...)
         {
-            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
+            COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;
             this->billboardSet_ = 0;
         }
@@ -104,5 +103,5 @@
         catch (...)
         {
-            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
+            COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;
             this->billboardSet_ = 0;
         }
Index: code/branches/pickup2/src/libraries/tools/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/libraries/tools/CMakeLists.txt	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/CMakeLists.txt	(revision 6412)
@@ -23,4 +23,5 @@
   LINK_LIBRARIES
     core
+    network
   SOURCE_FILES ${TOOLS_SRC_FILES}
 )
Index: code/branches/pickup2/src/libraries/tools/Mesh.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/Mesh.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/Mesh.cc	(revision 6412)
@@ -36,5 +36,4 @@
 
 #include "util/Convert.h"
-#include "util/StringUtils.h"
 #include "core/GameMode.h"
 
@@ -84,5 +83,5 @@
             catch (...)
             {
-                COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
+                COUT(1) << "Error: Couln't load mesh \"" << meshsource << '"' << std::endl;
                 this->entity_ = 0;
             }
Index: code/branches/pickup2/src/libraries/tools/ParticleInterface.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/ParticleInterface.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/ParticleInterface.cc	(revision 6412)
@@ -64,4 +64,8 @@
         this->bAllowedByLOD_ = true;
         this->speedFactor_ = 1.0f;
+
+        this->setDetailLevel(static_cast<unsigned int>(detaillevel));
+
+        this->setConfigValues();
 
         if (GameMode::showsGraphics())
@@ -74,10 +78,8 @@
             catch (...)
             {
-                COUT(1) << "Error: Couln't load particle system \"" << templateName << "\"" << std::endl;
+                COUT(1) << "Error: Couln't load particle system \"" << templateName << '"' << std::endl;
                 this->particleSystem_ = 0;
             }
         }
-
-        this->setDetailLevel(static_cast<unsigned int>(detaillevel));
     }
 
Index: code/branches/pickup2/src/libraries/tools/ResourceCollection.h
===================================================================
--- code/branches/pickup2/src/libraries/tools/ResourceCollection.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/ResourceCollection.h	(revision 6412)
@@ -38,6 +38,4 @@
 namespace orxonox
 {
-    class ResourceLocation;
-
     class _ToolsExport ResourceCollection : public BaseObject
     {
Index: code/branches/pickup2/src/libraries/tools/ResourceLocation.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/ResourceLocation.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/ResourceLocation.cc	(revision 6412)
@@ -92,5 +92,5 @@
     {
         // Remove from Ogre paths
-        resourceGroup_.erase();
+        resourceGroup_.clear();
         try
         {
Index: code/branches/pickup2/src/libraries/tools/Shader.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/Shader.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/Shader.cc	(revision 6412)
@@ -57,6 +57,4 @@
         this->bLoadCompositor_ = GameMode::showsGraphics();
         this->bViewportInitialized_ = false;
-        this->compositor_ = "";
-        this->oldcompositor_ = "";
 
         if (this->bLoadCompositor_ && Ogre::Root::getSingletonPtr())
@@ -79,6 +77,5 @@
     Shader::~Shader()
     {
-
-        if (this->bLoadCompositor_ && this->compositorInstance_)
+        if (this->compositorInstance_ && this->bLoadCompositor_)
         {
             Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
@@ -112,10 +109,10 @@
             Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
             assert(viewport);
-            if (this->oldcompositor_ != "")
+            if (!this->oldcompositor_.empty())
             {
                 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->oldcompositor_);
                 this->compositorInstance_ = 0;
             }
-            if (this->compositor_ != "")
+            if (!this->compositor_.empty())
             {
                 this->compositorInstance_ = Ogre::CompositorManager::getSingleton().addCompositor(viewport, this->compositor_);
@@ -299,5 +296,5 @@
                         continue;
 
-                    if (pass_pointer->getFragmentProgramName() != "")
+                    if (!pass_pointer->getFragmentProgramName().empty())
                     {
                         Ogre::GpuProgramParameters* parameter_pointer = pass_pointer->getFragmentProgramParameters().get();
Index: code/branches/pickup2/src/libraries/tools/TextureGenerator.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/TextureGenerator.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/TextureGenerator.cc	(revision 6412)
@@ -72,5 +72,5 @@
         if (it == colourMap.end())
         {
-            std::string materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
+            const std::string& materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
             Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialName, "General"));
             material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
@@ -82,5 +82,5 @@
         else
         {
-            return (*it).second;
+            return it->second;
         }
     }
Index: code/branches/pickup2/src/libraries/tools/Timer.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/Timer.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/Timer.cc	(revision 6412)
@@ -112,5 +112,5 @@
         this->deleteExecutor();
     }
-    
+
     /**
         @brief Initializes the Timer
Index: code/branches/pickup2/src/libraries/tools/Timer.h
===================================================================
--- code/branches/pickup2/src/libraries/tools/Timer.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/Timer.h	(revision 6412)
@@ -140,5 +140,5 @@
         private:
             void init();
-        
+
             Executor* executor_;  //!< The executor of the function that should be called when the time expires
 
Index: code/branches/pickup2/src/libraries/tools/interfaces/TimeFactorListener.h
===================================================================
--- code/branches/pickup2/src/libraries/tools/interfaces/TimeFactorListener.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/interfaces/TimeFactorListener.h	(revision 6412)
@@ -37,14 +37,14 @@
     class _ToolsExport TimeFactorListener : virtual public OrxonoxClass
     {
-        friend class GSRoot;
-
         public:
             TimeFactorListener();
             virtual ~TimeFactorListener() {}
 
+            static void setTimeFactor( float factor );
+            static void setTimeFactorInternal( float factor );
+            static inline float getTimeFactor(){ return TimeFactorListener::timefactor_s; }
+
         protected:
             virtual void changedTimeFactor(float factor_new, float factor_old) {}
-            inline float getTimeFactor() const
-                { return TimeFactorListener::timefactor_s; }
 
         private:
Index: code/branches/pickup2/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
===================================================================
--- code/branches/pickup2/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	(revision 6412)
@@ -37,4 +37,6 @@
 
 #include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "network/NetworkFunction.h"
 
 namespace orxonox
@@ -43,4 +45,6 @@
     // TimeFactorListener
     //----------------------------
+    registerStaticNetworkFunction( &TimeFactorListener::setTimeFactorInternal );
+
     float TimeFactorListener::timefactor_s = 1.0f;
 
@@ -48,4 +52,19 @@
     {
         RegisterRootObject(TimeFactorListener);
+    }
+
+    /*static*/ void TimeFactorListener::setTimeFactor( float factor )
+    {
+        if ( !GameMode::isStandalone() )
+            callStaticNetworkFunction( &TimeFactorListener::setTimeFactorInternal, CLIENTID_UNKNOWN, factor );
+        TimeFactorListener::setTimeFactorInternal(factor);
+    }
+
+    /*static*/ void TimeFactorListener::setTimeFactorInternal( float factor )
+    {
+        float oldFactor = TimeFactorListener::timefactor_s;
+        TimeFactorListener::timefactor_s = factor;
+        for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)
+            it->changedTimeFactor(factor, oldFactor);
     }
 
Index: code/branches/pickup2/src/libraries/util/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/libraries/util/CMakeLists.txt	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/CMakeLists.txt	(revision 6412)
@@ -29,5 +29,4 @@
   CRC32.cc
   ExprParser.cc
-  OutputBuffer.cc
   OutputHandler.cc
   SignalHandler.cc
Index: code/branches/pickup2/src/libraries/util/Clipboard.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Clipboard.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Clipboard.cc	(revision 6412)
@@ -78,5 +78,5 @@
         {
             COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;
-            COUT(1) << "       \"" << text << "\"" << std::endl;
+            COUT(1) << "       \"" << text << '"' << std::endl;
         }
         return false;
@@ -94,5 +94,7 @@
             {
                 HANDLE hData = GetClipboardData(CF_TEXT);
-                std::string output = static_cast<char*>(GlobalLock(hData));
+                if (hData == NULL)
+                    return "";
+                std::string output(static_cast<char*>(GlobalLock(hData)));
                 GlobalUnlock(hData);
                 CloseClipboard();
@@ -117,5 +119,5 @@
 namespace orxonox
 {
-    static std::string clipboard = ""; //!< Keeps the text of our internal clipboard
+    static std::string clipboard; //!< Keeps the text of our internal clipboard
 
     /**
Index: code/branches/pickup2/src/libraries/util/Clock.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Clock.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Clock.cc	(revision 6412)
@@ -34,9 +34,7 @@
     Clock::Clock()
         : timer_(new Ogre::Timer())
-        , storedTime_(0)
         , tickTime_(0)
         , tickDt_(0)
         , tickDtFloat_(0.0f)
-        , lastTimersTime_(0)
     {
     }
@@ -46,28 +44,24 @@
         delete timer_;
     }
-    
+
+    /**
+    @remarks
+        Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned
+        long, which will eventually overflow. But if you use the subtraction of
+        the current time minus the last time the timer gave us and sum these up to
+        a 64 bit integer, we get the desired result.
+        Also mind that we don't have to store the last timer's time as unsigned long
+        as well because (unsigned long)tickTime_ will do exactly that.
+    */
     void Clock::capture()
     {
-        unsigned long timersTime = timer_->getMicroseconds();
-        tickTime_ = storedTime_ + timersTime;
-        tickDt_ = timersTime - lastTimersTime_;
+        tickDt_ = timer_->getMicroseconds() - (unsigned long)tickTime_;
+        tickTime_ += tickDt_;
         tickDtFloat_ = static_cast<float>(tickDt_) / 1000000.0f;
-
-        if (timersTime > 0xFFFFFFFF/4)
-        {
-            // Ogre timer will overflow at 2^32 microseconds if unsigned long is 32 bit
-            storedTime_ += timersTime;
-            lastTimersTime_ = 0;
-            timer_->reset();
-        }
-        else
-        {
-            lastTimersTime_ = timersTime;
-        }
     }
 
     unsigned long long Clock::getRealMicroseconds() const
     {
-        return this->timer_->getMicroseconds() + this->storedTime_;
+        return tickTime_ + (timer_->getMicroseconds() - (unsigned long)tickTime_);
     }
 }
Index: code/branches/pickup2/src/libraries/util/Clock.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Clock.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Clock.h	(revision 6412)
@@ -57,9 +57,7 @@
 
         Ogre::Timer*       timer_;
-        unsigned long long storedTime_;
         unsigned long long tickTime_;
         long               tickDt_;
         float              tickDtFloat_;
-        unsigned long      lastTimersTime_;
     };
 }
Index: code/branches/pickup2/src/libraries/util/Convert.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Convert.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Convert.h	(revision 6412)
@@ -43,5 +43,4 @@
 
 #include "Debug.h"
-#include "StringUtils.h"
 #include "TemplateUtils.h"
 
@@ -336,5 +335,5 @@
         FORCEINLINE static bool convert(std::string* output, const char input)
         {
-            *output = std::string(1, input);
+            *output = input;
             return true;
         }
@@ -345,5 +344,5 @@
         FORCEINLINE static bool convert(std::string* output, const unsigned char input)
         {
-            *output = std::string(1, input);
+            *output = input;
             return true;
         }
@@ -352,7 +351,7 @@
     struct ConverterExplicit<std::string, char>
     {
-        FORCEINLINE static bool convert(char* output, const std::string input)
-        {
-            if (input != "")
+        FORCEINLINE static bool convert(char* output, const std::string& input)
+        {
+            if (!input.empty())
                 *output = input[0];
             else
@@ -364,7 +363,7 @@
     struct ConverterExplicit<std::string, unsigned char>
     {
-        FORCEINLINE static bool convert(unsigned char* output, const std::string input)
-        {
-            if (input != "")
+        FORCEINLINE static bool convert(unsigned char* output, const std::string& input)
+        {
+            if (!input.empty())
                 *output = input[0];
             else
@@ -389,4 +388,8 @@
     };
 
+    // Declarations to avoid StringUtils.h include
+    _UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+    _UtilExport std::string getLowercase(const std::string& str);
+
     // std::string to bool
     template <>
@@ -395,14 +398,14 @@
         static bool convert(bool* output, const std::string& input)
         {
-            std::string stripped = getLowercase(removeTrailingWhitespaces(input));
+            const std::string& stripped = getLowercase(removeTrailingWhitespaces(input));
             if (stripped == "true" || stripped == "on" || stripped == "yes")
             {
-              *output = true;
-              return true;
+                *output = true;
+                return true;
             }
             else if (stripped == "false" || stripped == "off" || stripped == "no")
             {
-              *output = false;
-              return true;
+                *output = false;
+                return true;
             }
 
Index: code/branches/pickup2/src/libraries/util/Debug.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Debug.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Debug.h	(revision 6412)
@@ -21,13 +21,15 @@
  *
  *   Author:
- *      Benjamin Grauer
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
  *   Co-authors:
- *      Fabian 'x3n' Landau
+ *      ...
  *
  */
 
 /**
-    @file
-    @brief Handles different output-levels of errors, warnings, infos and debug information.
+@file
+@brief
+    Handles different output-levels of errors, warnings, infos and debug information.
 
     The COUT(level) macro acts like std::cout, but the output is only performed if the given
@@ -35,7 +37,7 @@
 
     There are two used values in this file:
-     - The hard debug level is used during compiletime. It describes the highest allowed output level.
+     - The hard debug level is used during compile time. It describes the highest allowed output level.
      - The soft debug level is used during runtime and is the maximum of the three configurable
-       output-levels for console, logfile and ingame shell.
+       output-levels for console, log file and in game shell.
 
     The separation between the three devices is done by the OutputHandler.
@@ -50,210 +52,63 @@
      6: Crazy debug information
 
-    @example
+@example
     COUT(0) << "Very important output" << std::endl;
     COUT(1) << "Error: Something went wrong!" << std::endl;
     COUT(2) << "Warning: There might be a problem." << std::endl;
-    COUT(3) << "Info: It's monday" << std::endl;
+    COUT(3) << "Info: It's Monday" << std::endl;
     COUT(4) << "Debug: x is 1.23456" << std::endl;
- */
+*/
 
-#ifndef _Debug_H__
-#define _Debug_H__
+#ifndef _Util_Debug_H__
+#define _Util_Debug_H__
 
 #include "UtilPrereqs.h"
-
 #include "OutputHandler.h"
 
 namespace orxonox
 {
-    /**
-        @brief Returns the soft debug level, stored in the only existing instance of the OutputHandler class, configured in the config-file.
-        @return The soft debug level
-    */
-    inline int getSoftDebugLevel()
+    // Just for convenience
+    using std::endl;
+
+    // Adjust this to discard certain output with level > hardDebugLevel at compile time already
+#ifdef ORXONOX_RELEASE
+    const int hardDebugLevel = OutputLevel::Verbose
+#elif defined(NDEBUG)
+    const int hardDebugLevel = OutputLevel::Verbose;
+#else
+    //! Maximum level for debug output that should be even processed at run time
+    const int hardDebugLevel = OutputLevel::Ultra;
+#endif
+
+    //! This function simply returns 0 and helps to suppress the "statement has no effect" compiler warning
+    inline int debugDummyFunction()
     {
-        return OutputHandler::getSoftDebugLevel();
+        return 0;
     }
-
-    using std::endl;
 }
 
-// DEFINE ERROR MODES
-#define ORX_NONE            0
-#define ORX_ERROR           1
-#define ORX_WARNING         2
-#define ORX_INFO            3
-#define ORX_DEBUG           4
-#define ORX_VERBOSE         5
-#define ORX_ULTRA           6
+/**
+@brief
+    Logs text output: use exactly like std::cout, but specify an output
+    level as argument.
+@details
+    (a > b ? 0 : c << "text") is equivalent to (a > b ? 0 : (c << "text"))
+    where (a > b ? 0 : ) stands for COUT(x). This should explain how
+    this macro magic can possibly even work ;)
+@example
+    COUT(3) << "Some info" << std::endl;
+@note
+    The ? : operator requires both possible results to have the type of
+    the first. This is achieved by the int conversion operator dummy
+    in the OutputHandler.
+*/
+#define COUT(level)                                                    \
+    /*if*/ (level > orxonox::hardDebugLevel) ?                         \
+        orxonox::debugDummyFunction()                                  \
+    /*else*/ :                                                         \
+        /*if*/ (level > orxonox::OutputHandler::getSoftDebugLevel()) ? \
+            orxonox::debugDummyFunction()                              \
+        /*else*/ :                                                     \
+            orxonox::OutputHandler::getOutStream(level)
 
-//definitions
-#define ORX_PRINT_DEBUG_OUTPUT 1
-#define ORX_HARD_DEBUG_LEVEL ORX_VERBOSE
-
-#define COUT_EXEC(x) orxonox::OutputHandler::getOutStream().setOutputLevel(x)
-
-////////////////////////////////////////////////////////
-///  COUT: just prints output as is with std::cout   ///
-////////////////////////////////////////////////////////
-#define COUTORX_NONE    COUT0
-#define COUTORX_ERROR   COUT1
-#define COUTORX_WARNING COUT2
-#define COUTORX_INFO    COUT3
-#define COUTORX_DEBUG   COUT4
-#define COUTORX_VERBOSE COUT5
-#define COUTORX_ULTRA   COUT6
-
-#ifndef COUT
- #if ORX_PRINT_DEBUG_OUTPUT
-  #define COUT(x) \
-   COUT ## x
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
-   #define COUT0 \
-   (orxonox::getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : COUT_EXEC(0)
-  #else
-   #define COUT0 \
-    false ? COUT_EXEC(0) : COUT_EXEC(0)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
-   #define COUT1 \
-    (orxonox::getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : COUT_EXEC(1)
-  #else
-   #define COUT1 \
-    false ? COUT_EXEC(1) : COUT_EXEC(1)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
-   #define COUT2 \
-    (orxonox::getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : COUT_EXEC(2)
-  #else
-   #define COUT2 \
-    false ? COUT_EXEC(2) : COUT_EXEC(2)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
-   #define COUT3 \
-    (orxonox::getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : COUT_EXEC(3)
-  #else
-   #define COUT3 \
-    false ? COUT_EXEC(3) : COUT_EXEC(3)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
-   #define COUT4 \
-    (orxonox::getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : COUT_EXEC(4)
-  #else
-   #define COUT4 \
-    false ? COUT_EXEC(4) : COUT_EXEC(4)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
-   #define COUT5 \
-    (orxonox::getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : COUT_EXEC(5)
-  #else
-   #define COUT5 \
-    false ? COUT_EXEC(5) : COUT_EXEC(5)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
-   #define COUT6 \
-    (orxonox::getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : COUT_EXEC(6)
-  #else
-   #define COUT6 \
-    false ? COUT_EXEC(6) : COUT_EXEC(6)
-  #endif
-
- #else /* if ORX_PRINT_DEBUG_OUTPUT */
-  #define COUT(x) \
-    false ? COUT_EXEC(6) : COUT_EXEC(6)
- #endif /* if ORX_PRINT_DEBUG_OUTPUT */
-
-#endif /* ifndef COUT */
-
-
-/////////////////////////////////////////////////////////////////////
-///  CCOUT: Prints output with std::cout and adds the classname   ///
-/////////////////////////////////////////////////////////////////////
-#define CCOUTORX_NONE    CCOUT0
-#define CCOUTORX_ERROR   CCOUT1
-#define CCOUTORX_WARNING CCOUT2
-#define CCOUTORX_INFO    CCOUT3
-#define CCOUTORX_DEBUG   CCOUT4
-#define CCOUTORX_VERBOSE CCOUT5
-#define CCOUTORX_ULTRA   CCOUT6
-
-#define CCOUT_EXEC(x) \
-  orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
-  << this->getIdentifier()->getName() << ": "
-
-#ifndef CCOUT
- #if ORX_PRINT_DEBUG_OUTPUT
-  #define CCOUT(x) \
-   CCOUT ## x
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
-   #define CCOUT0 \
-    (orxonox::getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : CCOUT_EXEC(0)
-  #else
-   #define CCOUT0 \
-    false ? COUT_EXEC(0) : CCOUT_EXEC(0)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
-   #define CCOUT1 \
-    (orxonox::getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : CCOUT_EXEC(1)
-  #else
-   #define CCOUT1 \
-    false ? COUT_EXEC(1) : CCOUT_EXEC(1)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
-   #define CCOUT2 \
-    (orxonox::getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : CCOUT_EXEC(2)
-  #else
-   #define CCOUT2 \
-    false ? COUT_EXEC(2) : CCOUT_EXEC(2)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
-   #define CCOUT3 \
-    (orxonox::getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : CCOUT_EXEC(3)
-  #else
-   #define CCOUT3 \
-    false ? COUT_EXEC(3) : CCOUT_EXEC(3)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
-   #define CCOUT4 \
-    (orxonox::getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : CCOUT_EXEC(4)
-  #else
-   #define CCOUT4 \
-    false ? COUT_EXEC(4) : CCOUT_EXEC(4)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
-   #define CCOUT5 \
-    (orxonox::getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : CCOUT_EXEC(5)
-  #else
-   #define CCOUT5 \
-    false ? COUT_EXEC(5) : CCOUT_EXEC(5)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
-   #define CCOUT6 \
-    (orxonox::getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : CCOUT_EXEC(6)
-  #else
-   #define CCOUT6 \
-    false ? COUT_EXEC(6) : CCOUT_EXEC(6)
-  #endif
-
- #else /* if ORX_PRINT_DEBUG_OUTPUT */
-  #define CCOUT(x) \
-   false ? CCOUT_EXEC(6) : CCOUT_EXEC(6)
- #endif /* if ORX_PRINT_DEBUG_OUTPUT */
-
-#endif /* ifndef CCOUT */
-
-#endif /* _Debug_H__ */
+#endif /* _Util_Debug_H__ */
Index: code/branches/pickup2/src/libraries/util/DisplayStringConversions.h
===================================================================
--- code/branches/pickup2/src/libraries/util/DisplayStringConversions.h	(revision 6412)
+++ code/branches/pickup2/src/libraries/util/DisplayStringConversions.h	(revision 6412)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ */
+
+/**
+@file
+@brief
+    std::sring to Ogre::UTFString conversion functions
+*/
+
+#ifndef _DisplayStringConversions_H__
+#define _DisplayStringConversions_H__
+
+#include "UtilPrereqs.h"
+#include <OgreOverlayElement.h>
+
+#if OGRE_UNICODE_SUPPORT
+    #include <OgreUTFString.h>
+
+    namespace orxonox
+    {
+        template <>
+        struct ConverterExplicit<std::string, Ogre::DisplayString>
+        {
+            //! Converts an std::string into an Ogre::UTFString
+            inline static bool convert(Ogre::DisplayString* output, const std::string& input)
+            {
+                Ogre::UTFString::code_point cp;
+                for (unsigned int i = 0; i < input.size(); ++i)
+                {
+                  cp = input[i];
+                  cp &= 0xFF;
+                  output->append(1, cp);
+                }
+                return true;
+            }
+        };
+    }
+#else
+    namespace orxonox
+    {
+        template <>
+        struct ConverterExplicit<std::string, Ogre::DisplayString>
+        {
+            //! Converts an std::string into an Ogre::String
+            inline static bool convert(Ogre::DisplayString* output, const std::string& input)
+            {
+                *output = input;
+                return true;
+            }
+        };
+    }
+#endif
+
+#endif /* _DisplayStringConversions_H__ */
Index: code/branches/pickup2/src/libraries/util/Exception.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Exception.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Exception.cc	(revision 6412)
@@ -49,6 +49,4 @@
         : description_(description)
         , lineNumber_(0)
-        , functionName_("")
-        , filename_("")
     { }
 
@@ -61,5 +59,5 @@
     const std::string& Exception::getFullDescription() const
     {
-        if (fullDescription_ == "")
+        if (fullDescription_.empty())
         {
             std::ostringstream fullDesc;
@@ -67,21 +65,21 @@
             fullDesc << this->getTypeName() << "Exception";
 
-            if (this->filename_ != "")
+            if (!this->filename_.empty())
             {
                 fullDesc << " in " << this->filename_;
                 if (this->lineNumber_)
-                    fullDesc << "(" << this->lineNumber_ << ")";
+                    fullDesc << '(' << this->lineNumber_ << ')';
             }
 
-            if (this->functionName_ != "")
-                fullDesc << " in function '" << this->functionName_ << "'";
+            if (!this->functionName_.empty())
+                fullDesc << " in function '" << this->functionName_ << '\'';
 
             fullDesc << ": ";
-            if (this->description_ != "")
+            if (!this->description_.empty())
                 fullDesc << this->description_;
             else
                 fullDesc << "No description available.";
 
-            this->fullDescription_ = std::string(fullDesc.str());
+            this->fullDescription_ = fullDesc.str();
         }
 
Index: code/branches/pickup2/src/libraries/util/Exception.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Exception.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Exception.h	(revision 6412)
@@ -131,4 +131,5 @@
     CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
     CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
+    CREATE_ORXONOX_EXCEPTION(InitialisationAborted);
     CREATE_ORXONOX_EXCEPTION(NotImplemented);
     CREATE_ORXONOX_EXCEPTION(GameState);
Index: code/branches/pickup2/src/libraries/util/ExprParser.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/ExprParser.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/ExprParser.cc	(revision 6412)
@@ -47,7 +47,18 @@
 namespace orxonox
 {
-    ExprParser::ExprParser(const std::string& str)
+    ExprParser::ExprParser()
     {
         this->failed_ = false;
+        this->variables_["pi"] = 3.1415926535897932;
+        this->variables_["e"] = 2.7182818284590452;
+    }
+
+    void ExprParser::setVariable(const std::string& varname, double value)
+    {
+        this->variables_[varname] = value;
+    }
+
+    void ExprParser::parse(const std::string& str)
+    {
         this->reading_stream = str.c_str();
         if (str.size() == 0 || *reading_stream == '\0')
@@ -343,10 +354,8 @@
             else
             {
-#define SWITCH word
-                CASE_1("pi")
-                    value = 3.1415926535897932;
-                CASE("e")
-                    value = 2.7182818284590452;
-                CASE_ELSE
+                std::map<std::string, double>::const_iterator it = this->variables_.find(word);
+                if (it != this->variables_.end())
+                    value = it->second;
+                else
                 {
                     this->failed_ = true;
@@ -358,5 +367,5 @@
         }
         else if (*reading_stream == 40)
-        {  // expresion in paranthesis
+        {  // expression in parenthesis
             ++reading_stream;
             value = parse_last_argument();
Index: code/branches/pickup2/src/libraries/util/ExprParser.h
===================================================================
--- code/branches/pickup2/src/libraries/util/ExprParser.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/ExprParser.h	(revision 6412)
@@ -36,4 +36,6 @@
 
 #include "UtilPrereqs.h"
+
+#include <map>
 #include <string>
 
@@ -71,8 +73,11 @@
 
 
-        ExprParser(const std::string& str);
+        ExprParser();
+        void parse(const std::string& str);
         const std::string& getRemains() { return  this->remains_; }
         double             getResult()  { return  this->result_; }
         bool               getSuccess() { return !this->failed_; }
+
+        void setVariable(const std::string& varname, double value);
 
     private:
@@ -97,5 +102,5 @@
         double result_;
         std::string remains_;
-
+        std::map<std::string, double> variables_;
     };
 
Index: code/branches/pickup2/src/libraries/util/Math.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Math.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Math.cc	(revision 6412)
@@ -43,4 +43,5 @@
 namespace orxonox
 {
+#if OGRE_VERSION < 0x010603
     /**
         @brief Function for writing a Radian to a stream.
@@ -51,4 +52,14 @@
         return out;
     }
+
+    /**
+        @brief Function for writing a Degree to a stream.
+    */
+    std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
+    {
+        out << degree.valueDegrees();
+        return out;
+    }
+#endif
 
     /**
@@ -61,13 +72,4 @@
         radian = temp;
         return in;
-    }
-
-    /**
-        @brief Function for writing a Degree to a stream.
-    */
-    std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
-    {
-        out << degree.valueDegrees();
-        return out;
     }
 
@@ -136,8 +138,8 @@
                 return orxonox::Vector2(0, 1);
         }
-        
+
         float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
         float sin_value = sqrt( 1 - cos_value*cos_value );
-        
+
         if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
             return orxonox::Vector2( sin_value, cos_value );
@@ -177,5 +179,5 @@
         }
         //float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
-        
+
         float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
         float sin_value = sqrt( 1 - cos_value*cos_value );
Index: code/branches/pickup2/src/libraries/util/Math.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Math.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Math.h	(revision 6412)
@@ -59,7 +59,9 @@
 namespace orxonox
 {
+#if OGRE_VERSION < 0x010603
     _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
+    _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
+#endif
     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
-    _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree);
 
@@ -163,5 +165,5 @@
     template <> inline bool                 zeroise<bool>()                 { return 0; }
     template <> inline void*                zeroise<void*>()                { return 0; }
-    template <> inline std::string          zeroise<std::string>()          { return ""; }
+    template <> inline std::string          zeroise<std::string>()          { return std::string(); }
     template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
     template <> inline orxonox::Degree      zeroise<orxonox::Degree>()      { return orxonox::Degree(0.0f); }
Index: code/branches/pickup2/src/libraries/util/MathConvert.h
===================================================================
--- code/branches/pickup2/src/libraries/util/MathConvert.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/MathConvert.h	(revision 6412)
@@ -53,5 +53,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.x << "," << input.y)
+            if (ostream << input.x << ',' << input.y)
             {
                 (*output) = ostream.str();
@@ -69,5 +69,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.x << "," << input.y << "," << input.z)
+            if (ostream << input.x << ',' << input.y << ',' << input.z)
             {
                 (*output) = ostream.str();
@@ -85,5 +85,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
+            if (ostream << input.x << ',' << input.y << ',' << input.z << ',' << input.w)
             {
                 (*output) = ostream.str();
@@ -101,5 +101,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
+            if (ostream << input.w << ',' << input.x << ',' << input.y << ',' << input.z)
             {
                 (*output) = ostream.str();
@@ -117,5 +117,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
+            if (ostream << input.r << ',' << input.g << ',' << input.b << ',' << input.a)
             {
                 (*output) = ostream.str();
Index: code/branches/pickup2/src/libraries/util/MultiType.h
===================================================================
--- code/branches/pickup2/src/libraries/util/MultiType.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/MultiType.h	(revision 6412)
@@ -232,5 +232,5 @@
 
             virtual void toString(std::ostream& outstream) const = 0;
-            
+
             virtual void importData( uint8_t*& mem )=0;
             virtual void exportData( uint8_t*& mem ) const=0;
@@ -339,5 +339,5 @@
             template <typename T> inline bool isType()                    const { return false; } // Only works for specialized values - see below
             std::string                       getTypename()               const;
-            
+
             /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
             inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
Index: code/branches/pickup2/src/libraries/util/MultiTypeValue.h
===================================================================
--- code/branches/pickup2/src/libraries/util/MultiTypeValue.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/MultiTypeValue.h	(revision 6412)
@@ -150,5 +150,5 @@
         /** @brief Puts the current value on the stream */
         inline void toString(std::ostream& outstream) const { outstream << this->value_; }
-        
+
         /** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */
         inline void importData( uint8_t*& mem )         { loadAndIncrease( /*(const T&)*/this->value_, mem ); }
@@ -160,5 +160,5 @@
         T value_; //!< The stored value
     };
-    
+
     // Import / Export specialisation
     // ColourValue
Index: code/branches/pickup2/src/libraries/util/OrxAssert.h
===================================================================
--- code/branches/pickup2/src/libraries/util/OrxAssert.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/OrxAssert.h	(revision 6412)
@@ -44,5 +44,5 @@
 #ifndef NDEBUG
 #define OrxAssert(Assertion, ErrorMessage) \
-    Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(1) << ErrorMessage << std::endl); \
+    Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream(1) << ErrorMessage << std::endl); \
     assert(Assertion)
 #else
Index: code/branches/pickup2/src/libraries/util/OutputBuffer.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputBuffer.cc	(revision 6405)
+++ 	(revision )
@@ -1,127 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Implementation of the OutputBuffer.
-*/
-
-#include "OutputBuffer.h"
-
-namespace orxonox
-{
-    /**
-        @brief Adds a new listener to the list.
-        @param listener The new listener
-    */
-    void OutputBuffer::registerListener(OutputBufferListener* listener)
-    {
-        this->listeners_.push_back(listener);
-    }
-
-    /**
-        @brief Removes a listener from the list.
-        @param listener The listener
-    */
-    void OutputBuffer::unregisterListener(OutputBufferListener* listener)
-    {
-        for (std::vector<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
-        {
-            if ((*it) == listener)
-                it = this->listeners_.erase(it);
-            else
-                ++it;
-        }
-    }
-
-    /**
-        @brief Puts a stream manipulator to the stream.
-        @param manipulator The manipulator
-    */
-    OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&))
-    {
-        this->stream_ << manipulator;
-        this->callListeners();
-        return *this;
-    }
-
-    /**
-        @brief Puts a stream manipulator to the stream.
-        @param manipulator The manipulator
-    */
-    OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&))
-    {
-        this->stream_ << manipulator;
-        this->callListeners();
-        return *this;
-    }
-
-    /**
-        @brief Puts a stream manipulator to the stream.
-        @param manipulator The manipulator
-    */
-    OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
-    {
-        this->stream_ << manipulator;
-        this->callListeners();
-        return *this;
-    }
-
-    /**
-        @brief Removes the first line from the stream and assigns it to a given string object.
-        @param output The string object to assign the first line
-        @return True if there was at least one line in the stream and this line was successfully assigned
-
-        It's important to know the returned line will be removed from the stream. If there are more than one
-        listener, they have to cooperate to avoid conflicts.
-    */
-    bool OutputBuffer::getLine(std::string* output)
-    {
-        std::getline(this->stream_, *output);
-
-        bool eof = this->stream_.eof();
-        bool fail = this->stream_.fail();
-
-        if (eof)
-            this->stream_.flush();
-
-        if (eof || fail)
-            this->stream_.clear();
-
-        return (!eof && !fail);
-    }
-
-    /**
-        @brief Calls the outputChanged() function of all registered listeners.
-    */
-    void OutputBuffer::callListeners()
-    {
-        for (std::vector<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-            (*it)->outputChanged();
-    }
-}
Index: code/branches/pickup2/src/libraries/util/OutputBuffer.h
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputBuffer.h	(revision 6405)
+++ 	(revision )
@@ -1,173 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Declaration of the OutputBuffer class.
-
-    The OutputBuffer acts almost like std::ostream. You can put text and other values to the
-    OutputBuffer by using the << operator. The OutputBuffer stores the text and calls registerd
-    listeners if new text gets assigned.
-    The listeners are then able to retrieve the text line by line.
-
-    It's important to know that getLine actually removes the line from the OutputBuffer, so it's
-    better to only have one "active" listener.
-*/
-
-#ifndef _OutputBuffer_H__
-#define _OutputBuffer_H__
-
-#include "UtilPrereqs.h"
-
-#include <vector>
-#include <sstream>
-
-namespace orxonox
-{
-    /**
-        @brief A pure virtual baseclass for classes that want to register as listener to an OutputBuffer.
-
-        This class is pure virtual, so an inheriting class has to implement the function on it's own.
-        The function get's called, if an instance of the inheriting class registers as a listener at
-        an OutputBuffer and this buffer changes.
-    */
-    class OutputBufferListener
-    {
-        friend class OutputBuffer;
-
-        public:
-            virtual ~OutputBufferListener() {}
-
-        private:
-            virtual void outputChanged() = 0;
-    };
-
-    /**
-        @brief The OutputBuffer acts almost like std::ostream and stores the assigned text.
-
-        If text gets assigned by using the << operator or another function, the OutputBuffer
-        calls it's listeners, allowing them to retrieve the text line by line.
-
-        It's important to know that getLine actually removes the line from the OutputBuffer, so it's
-        better to only have one "active" listener.
-    */
-    class _UtilExport OutputBuffer
-    {
-        public:
-            OutputBuffer() {}
-            ~OutputBuffer() {}
-
-            /**
-                @brief Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners.
-                @param object The object/value to assign
-            */
-            template <class T>
-            inline OutputBuffer& operator<<(T object)
-            {
-                this->stream_ << object;
-                this->callListeners();
-                return *this;
-            }
-
-            /**
-                @brief Reads the stored text of the other OutputBuffer and calls the listeners.
-                @param object The other OutputBuffer
-            */
-            template <const OutputBuffer&>
-            inline OutputBuffer& operator<<(const OutputBuffer& object)
-            {
-                this->stream_ << object.stream_.rdbuf();
-                this->callListeners();
-                return *this;
-            }
-
-            OutputBuffer& operator<<(std::ostream& (*manipulator)(std::ostream&));
-            OutputBuffer& operator<<(std::ios& (*manipulator)(std::ios&));
-            OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
-
-            /**
-                @brief Does the same like operator<<: Assigns the object to the stream and calls the listeners.
-                @param object The object/value
-            */
-            template <class T>
-            inline void add(T object)
-            {
-                this->stream_ << object;
-                this->callListeners();
-            }
-
-            /**
-                @brief Assigns an object/value and adds std::endl.
-                @param object The object/value
-            */
-            template <class T>
-            inline void addLine(T object)
-            {
-                this->stream_ << object << std::endl;
-                this->callListeners();
-            }
-
-            /**
-                @brief Puts std::endl to the stream and calls the listeners.
-            */
-            inline void newline()
-            {
-                this->stream_ << std::endl;
-                this->callListeners();
-            }
-
-            /**
-                @brief Flushes the stored text (~empties the OutputBuffer).
-            */
-            inline void flush()
-            {
-                this->stream_.flush();
-            }
-
-            bool getLine(std::string* output);
-
-            void registerListener(OutputBufferListener* listener);
-            void unregisterListener(OutputBufferListener* listener);
-
-            /**
-                @brief Returns the internal stringstream object.
-            */
-            inline std::stringstream& getStream()
-            {
-                return this->stream_;
-            }
-
-        private:
-            void callListeners();
-
-            std::stringstream stream_;                     //!< The stringstream that stores the assigned text
-            std::vector<OutputBufferListener*> listeners_; //!< A list of all listeners
-    };
-}
-
-#endif /* _OutputBuffer_H__ */
Index: code/branches/pickup2/src/libraries/util/OutputHandler.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputHandler.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/OutputHandler.cc	(revision 6412)
@@ -23,66 +23,214 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
 
 /**
-    @file
-    @brief Implementation of the OutputHandler class.
+@file
+@brief
+    Definition of classes related to output (logging).
 */
 
 #include "OutputHandler.h"
 
+#include <algorithm>
 #include <ctime>
 #include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+#include "Debug.h"
 
 namespace orxonox
 {
+    //! How the log file shall be named on the filesystem
+    const std::string logFileBaseName_g = "orxonox.log";
+
+    /////////////////////////
+    ///// LogFileWriter /////
+    /////////////////////////
     /**
-        @brief Constructor: Opens the logfile and writes the first line.
-        @param logfilename The name of the logfile
+    @brief
+        Writes the output to the log file.
+    @note
+        As long as the correct log path is not yet known (for pre main code), the
+        LogFileWriter will write to a temporary file in /temp (Unix) or %TEMP% (Windows).
+        As soon as you set the correct path setLogPath the content of the temporary file
+        is read and put into the new file as well.
     */
+    class LogFileWriter : public OutputListener
+    {
+    public:
+        /**
+        @brief
+            Gets temporary log path and starts the log file
+        @param outputHandler
+            This is only required to avoid another call to getInstance (this c'tor was
+            called from getInstance!)
+        */
+        LogFileWriter()
+            : OutputListener(OutputHandler::logFileOutputListenerName_s)
+        {
+            // Get path for a temporary file
+#ifdef ORXONOX_PLATFORM_WINDOWS
+            char* pTempDir = getenv("TEMP");
+            this->logFilename_ = std::string(pTempDir) + '/' + logFileBaseName_g;
+#else
+            this->logFilename_ = std::string("/tmp/") + logFileBaseName_g;
+#endif
+
+            // Get current time
+            time_t rawtime;
+            struct tm* timeinfo;
+            time(&rawtime);
+            timeinfo = localtime(&rawtime);
+
+            this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
+            this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl;
+            this->logFile_.flush();
+
+            this->outputStream_ = &this->logFile_;
+        }
+
+        //! Closes the log file
+        ~LogFileWriter()
+        {
+            this->logFile_ << "Closed log" << std::endl;
+            this->logFile_.close();
+        }
+
+        //! Changes the log path
+        void setLogPath(const std::string& path)
+        {
+            this->logFile_.close();
+            // Read old file into a buffer
+            std::ifstream old(this->logFilename_.c_str());
+            this->logFilename_ = path + logFileBaseName_g;
+            // Open the new file and feed it the content of the old one
+            this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
+            this->logFile_ << old.rdbuf();
+            this->logFile_.flush();
+            old.close();
+        }
+
+    private:
+        std::ofstream logFile_;     //! File handle for the log file
+        std::string   logFilename_; //! Filename of the log file
+    };
+
+
+    /////////////////////////
+    ///// ConsoleWriter /////
+    /////////////////////////
+    /**
+    @brief
+        Writes the output to std::cout.
+    @note
+        This listener will usually be disable once an actual shell with console is instantiated.
+    */
+    class ConsoleWriter : public OutputListener
+    {
+    public:
+        //! Only assigns the output stream with std::cout
+        ConsoleWriter()
+            : OutputListener("consoleLog")
+        {
+            this->outputStream_ = &std::cout;
+        }
+    };
+
+
+    ///////////////////////////
+    ///// MemoryLogWriter /////
+    ///////////////////////////
+    /**
+    @brief
+        OutputListener that writes all the output piece by piece to an array
+        associated with the corresponding output level.
+    @note
+        Only output below or equal to the current soft debug level is written
+        to minimise huge arrays for the normal run.
+    */
+    class MemoryLogWriter : public OutputListener
+    {
+    public:
+        friend class OutputHandler;
+
+        /**
+        @brief
+            Sets the right soft debug level and registers itself
+        @param outputHandler
+            This is only required to avoid another call to getInstance (this c'tor was
+            called from getInstance!)
+        */
+        MemoryLogWriter()
+            : OutputListener("memoryLog")
+        {
+            this->outputStream_ = &this->buffer_;
+        }
+
+        //! Pushed the just written output to the internal array
+        void outputChanged(int level)
+        {
+            if (!this->buffer_.str().empty())
+            {
+                // Read ostringstream and store it
+                this->output_.push_back(std::make_pair(level, this->buffer_.str()));
+                // Clear content and flags
+                this->buffer_.str(std::string());
+            }
+            this->buffer_.clear();
+        }
+
+    private:
+        std::ostringstream                        buffer_; //! Stream object used to process the output
+        std::vector<std::pair<int, std::string> > output_; //! Vector containing ALL output
+    };
+
+
+    /////////////////////////
+    ///// OutputHandler /////
+    /////////////////////////
+    const std::string OutputHandler::logFileOutputListenerName_s = "logFile";
+          int         OutputHandler::softDebugLevel_s = hardDebugLevel;
+
+    //! Creates the LogFileWriter and the MemoryLogWriter
     OutputHandler::OutputHandler()
-    {
-#ifdef ORXONOX_PLATFORM_WINDOWS
-        char* pTempDir = getenv("TEMP");
-        this->logfilename_ = std::string(pTempDir) + "/orxonox.log";
+        : outputLevel_(OutputLevel::Verbose)
+    {
+#ifdef ORXONOX_RELEASE
+        const OutputLevel::Value defaultLevelConsole = OutputLevel::Error;
+        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Info;
 #else
-        this->logfilename_ = "/tmp/orxonox.log";
+        const OutputLevel::Value defaultLevelConsole = OutputLevel::Info;
+        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Debug;
 #endif
-#ifdef NDEBUG
-        this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 2;
-        this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 1;
-#else
-        this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 3;
-        this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 2;
-#endif
-
-        this->outputBuffer_ = &this->fallbackBuffer_;
-        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
-
-        time_t rawtime;
-        struct tm* timeinfo;
-        time(&rawtime);
-        timeinfo = localtime(&rawtime);
-
-        this->logfile_ << "Started log on " << asctime(timeinfo) << std::endl;
-        this->logfile_.flush();
-    }
-
-    /**
-        @brief Destructor: Writes the last line to the logfile and closes it.
-    */
+
+        this->logFile_ = new LogFileWriter();
+        // Use default level until we get the configValue from the Core
+        this->logFile_->softDebugLevel_ = defaultLevelLogFile;
+        this->registerOutputListener(this->logFile_);
+
+        this->consoleWriter_ = new ConsoleWriter();
+        this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
+        this->registerOutputListener(this->consoleWriter_);
+
+        this->output_ = new MemoryLogWriter();
+        // We capture as much input as the listener with the highest level
+        this->output_->softDebugLevel_ = getSoftDebugLevel();
+        this->registerOutputListener(this->output_);
+    }
+
+    //! Destroys the LogFileWriter and the MemoryLogWriter
     OutputHandler::~OutputHandler()
     {
-        this->logfile_ << "Closed log" << std::endl;
-        this->logfile_.close();
-    }
-
-    /**
-        @brief Returns a reference to the only existing instance of the OutputHandler class.
-        @return The instance
-    */
-    OutputHandler& OutputHandler::getOutStream()
+        delete this->logFile_;
+        delete this->consoleWriter_;
+        delete this->output_;
+    }
+
+    OutputHandler& OutputHandler::getInstance()
     {
         static OutputHandler orxout;
@@ -90,142 +238,71 @@
     }
 
-    /**
-        @brief Sets the soft debug level for a given output device.
-        @param device The output device
-        @param level The debug level
-    */
-    void OutputHandler::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
-    {
-        OutputHandler::getOutStream().softDebugLevel_[static_cast<unsigned int>(device)] = level;
-    }
-
-    /**
-        @brief Returns the soft debug level for a given output device.
-        @param device The output device
-        @return The debug level
-    */
-    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
-    {
-        return OutputHandler::getOutStream().softDebugLevel_[static_cast<unsigned int>(device)];
-    }
-
-    /**
-        @brief Sets the OutputBuffer, representing the third output stream.
-        @param buffer The OutputBuffer
-    */
-    void OutputHandler::setOutputBuffer(OutputBuffer* buffer)
-    {
-        if (buffer == NULL)
-            this->outputBuffer_ = &this->fallbackBuffer_;
-        else
-        {
-            buffer->getStream() >> this->outputBuffer_->getStream().rdbuf();
-            this->outputBuffer_ = buffer;
-        }
-    }
-
-    /**
-        @brief Sets the path where to create orxonox.log
-        @param Path string with trailing slash
-    */
+    void OutputHandler::registerOutputListener(OutputListener* listener)
+    {
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->name_ == listener->name_)
+            {
+                COUT(2) << "OutputHandler, Warning: Trying to register two listeners with the same name!" << std::endl;
+                return;
+            }
+        }
+        this->listeners_.push_back(listener);
+        // Update global soft debug level
+        this->setSoftDebugLevel(listener->getOutputListenerName(), listener->getSoftDebugLevel());
+    }
+
+    void OutputHandler::unregisterOutputListener(OutputListener* listener)
+    {
+        this->listeners_.remove(listener);
+    }
+
     void OutputHandler::setLogPath(const std::string& path)
     {
-        OutputHandler::getOutStream().logfile_.close();
-        // store old content
-        std::ifstream old;
-        old.open(OutputHandler::getOutStream().logfilename_.c_str());
-        OutputHandler::getOutStream().logfilename_ = path + "orxonox.log";
-        OutputHandler::getOutStream().logfile_.open(OutputHandler::getOutStream().logfilename_.c_str(), std::fstream::out);
-        OutputHandler::getOutStream().logfile_ << old.rdbuf();
-        old.close();
-        OutputHandler::getOutStream().logfile_.flush();
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console and the logfile.
-        @param sb The streambuffer that should be shown in the console
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::streambuf* sb)
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            std::cout << sb;
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            this->logfile_ << sb;
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << sb;
-
-        return *this;
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
-        @param manipulator A function, manipulating the outstream.
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::ostream& (*manipulator)(std::ostream&))
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            manipulator(std::cout);
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            manipulator(this->logfile_);
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << manipulator;
-
-        return *this;
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
-        @param manipulator A function, manipulating the outstream.
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::ios& (*manipulator)(std::ios&))
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            manipulator(std::cout);
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            manipulator(this->logfile_);
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << manipulator;
-
-        return *this;
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
-        @param manipulator A function, manipulating the outstream.
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            manipulator(std::cout);
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            manipulator(this->logfile_);
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << manipulator;
-
-        return *this;
+        this->logFile_->setLogPath(path);
+    }
+
+    void OutputHandler::disableCout()
+    {
+        this->unregisterOutputListener(this->consoleWriter_);
+    }
+
+    void OutputHandler::enableCout()
+    {
+        this->registerOutputListener(this->consoleWriter_);
+    }
+
+    OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorBegin() const
+    {
+        return this->output_->output_.begin();
+    }
+
+    OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorEnd() const
+    {
+        return this->output_->output_.end();
+    }
+
+    int OutputHandler::getSoftDebugLevel(const std::string& name) const
+    {
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->name_ == name)
+                return (*it)->softDebugLevel_;
+        }
+        return -1;
+    }
+
+    void OutputHandler::setSoftDebugLevel(const std::string& name, int level)
+    {
+        int globalSoftDebugLevel = -1;
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->name_ == name)
+                (*it)->softDebugLevel_ = level;
+            if ((*it)->softDebugLevel_ > globalSoftDebugLevel)
+                globalSoftDebugLevel = (*it)->softDebugLevel_;
+        }
+        // Update global soft debug level
+        OutputHandler::softDebugLevel_s = globalSoftDebugLevel;
     }
 }
Index: code/branches/pickup2/src/libraries/util/OutputHandler.h
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputHandler.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/OutputHandler.h	(revision 6412)
@@ -23,14 +23,12 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
 
 /**
-    @file
-    @brief Definition of the OutputHandler class.
-
-    The OutputHandler acts like std::cout, but output isn't only shown in the console,
-    but also written to the logfile and the ingame shell.
+@file
+@brief
+    Declaration of classes related to output (logging).
 */
 
@@ -40,166 +38,244 @@
 #include "UtilPrereqs.h"
 
-#include <iostream>
-#include <fstream>
+#include <list>
+#include <ostream>
 #include <string>
-
-#include "OutputBuffer.h"
+#include <vector>
+#include <utility>
 
 namespace orxonox
 {
-    //! The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell.
+    /**
+    @brief
+        Denotes different levels of text output (log output)
+
+        0, None   : Very important output
+        1, Error  : Errors
+        2, Warning: Warnings
+        3, Info   : Information
+        4, Debug  : Debug information
+        5, Verbose: More debug information
+        6, Ultra  : Crazy debug information
+    */
+    namespace OutputLevel
+    {
+        enum Value
+        {
+            None    = 0,
+            Error   = 1,
+            Warning = 2,
+            Info    = 3,
+            Debug   = 4,
+            Verbose = 5,
+            Ultra   = 6,
+        };
+    }
+
+    // Forward declarations for classes in the source file
+    class LogFileWriter;
+    class ConsoleWriter;
+    class MemoryLogWriter;
+
+    /**
+    @brief
+        The OutputHandler acts like std::cout, but output isn't only shown in the console.
+
+        You can register your own listener for output by inheriting from OutputListner.
+        And if you need the output previously processed, iterate over it with
+        OutputHandler::getOutputVector[Begin/End].
+        The way to output text is to first set the desired output level with
+        OutputHandler::getOutStream(level) and then use the "<<" operator like with std::cout.
+    */
     class _UtilExport OutputHandler
     {
         public:
-            enum OutputDevice
-            {
-                LD_All = 0,
-                LD_Console = 1,
-                LD_Logfile = 2,
-                LD_Shell = 3
-            };
-
-            static OutputHandler& getOutStream();
-
-            /** @brief Puts some text on the outstream. @param text The text */
+            //! Returns a reference to the only existing instance of the OutputHandler class.
+            static OutputHandler& getInstance();
+
+            //! Sets the output level and returns a stream to be used with "<<"
+            static inline OutputHandler& getOutStream(int level)
+                { return OutputHandler::getInstance().setOutputLevel(level); }
+
+            typedef std::vector<std::pair<int, std::string> >::const_iterator OutputVectorIterator;
+            //! Returns an iterator to the beginning of the all-output vector
+            OutputVectorIterator getOutputVectorBegin() const;
+            //! Returns an iterator to the end of the all-output vector
+            OutputVectorIterator getOutputVectorEnd() const;
+
+            //! Writes to all output devices
             static inline const std::string& log(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(0); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts an error on the outstream. @param text The text */
+                { OutputHandler::getOutStream(0).output(text) << std::endl; return text; }
+
+            //! Writes an error message to the output
             static inline const std::string& error(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(1); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts a warning on the outstream. @param text The text */
+                { OutputHandler::getOutStream(1).output(text) << std::endl; return text; }
+
+            //! Writes a warning message to the output
             static inline const std::string& warning(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(2); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts an info on the outstream. @param text The text */
+                { OutputHandler::getOutStream(2).output(text) << std::endl; return text; }
+
+            //! Writes an informational message to the output
             static inline const std::string& info(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(3); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts some debug output on the outstream. @param text The text */
+                { OutputHandler::getOutStream(3).output(text) << std::endl; return text; }
+
+            //! Writes a debug message to the output
             static inline const std::string& debug(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(4); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Returns a reference to the logfile. @return The logfile */
-            inline std::ofstream& getLogfile()
-                { return this->logfile_; }
-
-            /** @brief Returns a pointer to the OutputBuffer. @return The OutputBuffer */
-            inline OutputBuffer* getOutputBuffer()
-                { return this->outputBuffer_; }
-
-            /** @brief Sets the level of the incoming output. @param level The level of the incoming output @return The OutputHandler itself */
+                { OutputHandler::getOutStream(4).output(text) << std::endl; return text; }
+
+            //! Registers an object that receives output via a provided std::ostream
+            void registerOutputListener(OutputListener* listener);
+            //! Unregisters an object that receives output via a provided std::ostream
+            void unregisterOutputListener(OutputListener* listener);
+
+            //! Set the log path once the program has been properly initialised
+            void setLogPath(const std::string& path);
+            //! Disables the std::cout stream for output
+            void disableCout();
+            //! Enables the std::cout stream for output (startup behaviour)
+            void enableCout();
+
+            //! Sets the level of the incoming output and returns the OutputHandler
             inline OutputHandler& setOutputLevel(int level)
                 { this->outputLevel_ = level; return *this; }
 
-            /** @brief Returns the level of the incoming output. @return The level */
+            //! Returns the level of the incoming output
             inline int getOutputLevel() const
                 { return this->outputLevel_; }
 
-            static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
-            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
-
-            static void setLogPath(const std::string& path);
-
-            void setOutputBuffer(OutputBuffer* buffer);
-
+            //! Returns the maximum debug level over all registered listeners (devices)
+            static int getSoftDebugLevel() { return softDebugLevel_s; }
+            //! Returns the soft debug level for a device by its name   @return The level or -1 if the listener was not found
+            int  getSoftDebugLevel(const std::string& name) const;
+            //! Sets the soft debug level for a listener by its name   @remarks Only works for registered listeners!
+            void setSoftDebugLevel(const std::string& name, int level);
+
+            /**
+            @brief
+                General template that copes with all output.
+                Required because operator << might be ambiguous.
+                @a output will be streamed into every listener with an appropriate debug level
+            @return
+                Returns a reference to the OutputHandler so you can use it again directly
+            */
             template <class T>
             OutputHandler& output(const T& output);
 
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned char val)      { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(short val)              { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned short val)     { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(int val)                { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned int val)       { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(long val)               { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned long val)      { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(long long val)          { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned long long val) { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(float val)              { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(double val)             { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(long double val)        { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(const void* val)        { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(bool val)               { return this->output(val); }
 
-            OutputHandler& operator<<(std::streambuf* sb);
-
-            OutputHandler& operator<<(std::ostream& (*manipulator)(std::ostream&));
-            OutputHandler& operator<<(std::ios& (*manipulator)(std::ios&));
-            OutputHandler& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
+            //! Overloaded << operator, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::streambuf* sb)     { return this->output(sb); }
+
+            //! Overloaded << operator, redirect the output of classes with self defined 'operator <<' to the listeners
+            template <class T>
+            inline OutputHandler& operator<<(const T& val)           { return this->output(val); }
+
+            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::ostream&  (*manip)(std::ostream&))  { return this->output(manip); }
+            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::ios&      (*manip)(std::ios&))      { return this->output(manip); }
+            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::ios_base& (*manip)(std::ios_base&)) { return this->output(manip); }
+
+            //! Dummy operator required by Debug.h for the ternary operator
+            inline operator int() const { return 0; }
+
+            //! Name of the OutputListener that writes to the log file
+            static const std::string logFileOutputListenerName_s;
 
         private:
-            explicit OutputHandler();
-            OutputHandler(const OutputHandler& oh);
-            virtual ~OutputHandler();
-
-            std::ofstream logfile_;              //!< The logfile where the output is logged
-            std::string logfilename_;            //!< The name of the logfile
-            OutputBuffer fallbackBuffer_;        //!< The OutputBuffer that gets used if there is no other OutputBuffer
-            OutputBuffer* outputBuffer_;         //!< The OutputBuffer to put output in (usually used by the Shell)
-            int outputLevel_;                    //!< The level of the incoming output
-            int softDebugLevel_[4];              //!< The soft debug level for each OutputDevice - the configurable maximal output level
+            OutputHandler();
+            ~OutputHandler();
+            OutputHandler(const OutputHandler& rhs); //! Unused and undefined
+
+            std::list<OutputListener*> listeners_;        //!< Array with all registered output listeners
+            int                        outputLevel_;      //!< The level of the incoming output
+            LogFileWriter*             logFile_;          //!< Listener that writes to the log file
+            ConsoleWriter*             consoleWriter_;    //!< Listener for std::cout (just program beginning)
+            MemoryLogWriter*           output_;           //!< Listener that Stores ALL output below the current soft debug level
+            static int                 softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
     };
 
     /**
-        @brief Redirects the output to the console and the logfile.
-        @param output The value that should be shown in the console
-        @return A reference to the OutputHandler itself
+    @brief
+        Interface for listening to output.
+    @remarks
+        Remember to register the listener (not done automatically!)
     */
+    class OutputListener
+    {
+        friend class OutputHandler;
+
+    public:
+        OutputListener(const std::string& name)
+            : outputStream_(NULL)
+            , name_(name)
+            , softDebugLevel_(OutputLevel::Info)
+        {}
+        virtual ~OutputListener() {}
+
+        //! Gets called whenever output is put into the stream
+        virtual void outputChanged(int level) {}
+        //! Returns the name of this output listener
+        const std::string& getOutputListenerName() const { return this->name_; }
+        //! Returns the soft debug level of the listener
+        int getSoftDebugLevel() const { return this->softDebugLevel_; }
+        //! Sets the soft debug level of the listener
+        void setSoftDebugLevel(int level)
+        {
+            this->softDebugLevel_ = level;
+            OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);
+        }
+
+    protected:
+        std::ostream*     outputStream_;   //!< Pointer to the associated output stream, can be NULL
+
+    private:
+        const std::string name_;           //!< Name of the listener, constant and unique!
+        int               softDebugLevel_; //!< Current soft debug level that defines what kind of output is written to the stream
+    };
+
     template<class T>
-    OutputHandler& OutputHandler::output(const T& output)
-    {
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            std::cout << output;
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+    inline OutputHandler& OutputHandler::output(const T& output)
+    {
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
         {
-            this->logfile_ << output;
-            this->logfile_.flush();
+            if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
+            {
+                std::ostream& stream = *((*it)->outputStream_);
+                stream << output;
+                stream.flush();
+                (*it)->outputChanged(this->outputLevel_);
+            }
         }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << output;
 
         return *this;
     }
-
-    /**
-        @brief Overloading of the non-member << operator to redirect the output of classes with self defined '<< to std::ostream' operators to the console and the logfile.
-        @param out The OutputHandler itself
-        @param output The class that should be shown in the console
-        @return The OutputHandler itself
-    */
-    template<class T>
-    OutputHandler& operator<<(OutputHandler& out, const T& output)
-    {
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= out.getOutputLevel())
-            std::cout << output;
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= out.getOutputLevel())
-        {
-            out.getLogfile() << output;
-            out.getLogfile().flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= out.getOutputLevel())
-            (*out.getOutputBuffer()) << output;
-
-        return out;
-    }
 }
 
Index: code/branches/pickup2/src/libraries/util/Serialise.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Serialise.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Serialise.h	(revision 6412)
@@ -37,17 +37,16 @@
 #include <cstring>
 #include "util/Math.h"
+#include "util/mbool.h"
 
 namespace orxonox{
-    
-// general template declaration
-    
+
     /** @brief returns the size of the variable in a datastream */
-    template <class T> inline uint32_t returnSize( const T& );
+    template <class T> inline uint32_t returnSize( const T& variable );
     /** @brief loads the value of a variable out of the bytestream and increases the mem pointer */
-    template <class T> inline void loadAndIncrease( const T&, uint8_t*& );
+    template <class T> inline void loadAndIncrease( const T& variable, uint8_t*& mem );
     /** @brief saves the value of a variable into the bytestream and increases the mem pointer */
-    template <class T> inline void saveAndIncrease( const T&, uint8_t*& );
+    template <class T> inline void saveAndIncrease( const T& variable, uint8_t*& mem );
     /** @brief checks whether the variable of type T is the same as in the bytestream */
-    template <class T> inline  bool checkEquality( const T&, uint8_t* );
+    template <class T> inline bool checkEquality( const T& variable, uint8_t* mem );
 
 // =================== Template specialisation stuff =============
@@ -203,5 +202,5 @@
         return sizeof(uint32_t);
     }
-    
+
     template <> inline void loadAndIncrease( const unsigned int& variable, uint8_t*& mem )
     {
@@ -376,5 +375,5 @@
         double temp;
         memcpy(&temp, mem, sizeof(uint64_t));
-        *(long double*)( &variable ) = static_cast<const long double>(temp);
+        *(long double*)( &variable ) = static_cast<long double>(temp);
         mem += returnSize( variable );
     }
@@ -471,6 +470,167 @@
         return variable==Degree(*r);
     }
-    
-    
+
+    // =========== Vector2
+
+    template <> inline uint32_t returnSize( const Vector2& variable )
+    {
+        return returnSize( variable.x )+returnSize( variable.y );
+    }
+
+    template <> inline void saveAndIncrease( const Vector2& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Vector2& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+    }
+
+    template <> inline bool checkEquality( const Vector2& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.x, mem) && checkEquality(variable.y, mem+returnSize(variable.x));
+    }
+
+    // =========== Vector3
+
+    template <> inline uint32_t returnSize( const Vector3& variable )
+    {
+        return returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+    }
+
+    template <> inline void saveAndIncrease( const Vector3& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+        saveAndIncrease( variable.z, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Vector3& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+        loadAndIncrease( variable.z, mem );
+    }
+
+    template <> inline bool checkEquality( const Vector3& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.x, mem) && checkEquality(variable.y, mem+returnSize(variable.x)) &&
+            checkEquality(variable.z, mem+returnSize(variable.x)+returnSize(variable.y));
+    }
+
+    // =========== Vector4
+
+    template <> inline uint32_t returnSize( const Vector4& variable )
+    {
+        return returnSize( variable.w )+returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+    }
+
+    template <> inline void saveAndIncrease( const Vector4& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.w, mem );
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+        saveAndIncrease( variable.z, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Vector4& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.w, mem );
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+        loadAndIncrease( variable.z, mem );
+    }
+
+    template <> inline bool checkEquality( const Vector4& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.w, mem) && checkEquality(variable.x, mem+returnSize(variable.w)) &&
+            checkEquality(variable.y, mem+returnSize(variable.w)+returnSize(variable.x)) &&
+            checkEquality(variable.z, mem+returnSize(variable.w)+returnSize(variable.x)+returnSize(variable.y));
+    }
+
+    // =========== Quaternion
+
+    template <> inline uint32_t returnSize( const Quaternion& variable )
+    {
+        return returnSize( variable.w )+returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+    }
+
+    template <> inline void saveAndIncrease( const Quaternion& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.w, mem );
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+        saveAndIncrease( variable.z, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Quaternion& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.w, mem );
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+        loadAndIncrease( variable.z, mem );
+    }
+
+    template <> inline bool checkEquality( const Quaternion& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.w, mem) && checkEquality(variable.x, mem+returnSize(variable.w)) &&
+            checkEquality(variable.y, mem+returnSize(variable.w)+returnSize(variable.x)) &&
+            checkEquality(variable.z, mem+returnSize(variable.w)+returnSize(variable.x)+returnSize(variable.y));
+    }
+
+    // =========== ColourValue
+
+    template <> inline uint32_t returnSize( const ColourValue& variable )
+    {
+        return returnSize( variable.r )+returnSize( variable.g )+returnSize( variable.b )+returnSize( variable.a );
+    }
+
+    template <> inline void saveAndIncrease( const ColourValue& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.r, mem );
+        saveAndIncrease( variable.g, mem );
+        saveAndIncrease( variable.b, mem );
+        saveAndIncrease( variable.a, mem );
+    }
+
+    template <> inline void loadAndIncrease( const ColourValue& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.r, mem );
+        loadAndIncrease( variable.g, mem );
+        loadAndIncrease( variable.b, mem );
+        loadAndIncrease( variable.a, mem );
+    }
+
+    template <> inline bool checkEquality( const ColourValue& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.r, mem) && checkEquality(variable.g, mem+returnSize(variable.r)) &&
+            checkEquality(variable.b, mem+returnSize(variable.r)+returnSize(variable.g)) &&
+            checkEquality(variable.a, mem+returnSize(variable.r)+returnSize(variable.g)+returnSize(variable.b));
+    }
+
+    // =========== mbool
+
+    template <> inline uint32_t returnSize( const mbool& variable )
+    {
+        return returnSize( (unsigned char&)((mbool&)variable).getMemory() );
+    }
+
+    template <> inline void saveAndIncrease( const mbool& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
+    }
+
+    template <> inline void loadAndIncrease( const mbool& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
+    }
+
+    template <> inline bool checkEquality( const mbool& variable, uint8_t* mem )
+    {
+        return checkEquality( (unsigned char&)((mbool&)variable).getMemory(), mem );
+    }
 }
 
Index: code/branches/pickup2/src/libraries/util/Singleton.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Singleton.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/Singleton.h	(revision 6412)
@@ -56,7 +56,11 @@
 
         //! Update method called by ClassSingletonManager (if used)
-        void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); }
+        void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
         //! Empty update method for the static polymorphism
-        void update(const Clock& time) { }
+        void preUpdate(const Clock& time) { }
+        //! Update method called by ClassSingletonManager (if used)
+        void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
+        //! Empty update method for the static polymorphism
+        void postUpdate(const Clock& time) { }
 
     protected:
Index: code/branches/pickup2/src/libraries/util/StringUtils.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/StringUtils.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/StringUtils.cc	(revision 6412)
@@ -40,5 +40,5 @@
 namespace orxonox
 {
-    std::string BLANKSTRING("");
+    std::string BLANKSTRING;
 
     std::string getUniqueNumberString()
@@ -54,10 +54,10 @@
     {
         size_t pos;
-        while ((pos = (*str).find(" ")) < (*str).length())
-            (*str).erase(pos, 1);
-        while ((pos = (*str).find("\t")) < (*str).length())
-            (*str).erase(pos, 1);
-        while ((pos = (*str).find("\n")) < (*str).length())
-            (*str).erase(pos, 1);
+        while ((pos = str->find(' ')) < str->length())
+            str->erase(pos, 1);
+        while ((pos = str->find('\t')) < str->length())
+            str->erase(pos, 1);
+        while ((pos = str->find('\n')) < str->length())
+            str->erase(pos, 1);
     }
 
@@ -69,5 +69,5 @@
     std::string getStripped(const std::string& str)
     {
-        std::string output = std::string(str);
+        std::string output(str);
         strip(&output);
         return output;
@@ -98,5 +98,5 @@
         size_t quote = start - 1;
 
-        while ((quote = str.find('\"', quote + 1)) != std::string::npos)
+        while ((quote = str.find('"', quote + 1)) != std::string::npos)
         {
             size_t backslash = quote;
@@ -231,5 +231,5 @@
     {
         // Strip the line, whitespaces are disturbing
-        std::string teststring = getStripped(str);
+        const std::string& teststring = getStripped(str);
 
         // There are four possible comment-symbols:
@@ -259,6 +259,5 @@
     bool isEmpty(const std::string& str)
     {
-        std::string temp = getStripped(str);
-        return ((temp == "") || (temp.size() == 0));
+        return getStripped(str).empty();
     }
 
@@ -303,5 +302,5 @@
         for (size_t pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); }
         for (size_t pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); }
-        for (size_t pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
+        for (size_t pos = 0; (pos = output.find('"' , pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
         for (size_t pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); }
 
@@ -319,5 +318,5 @@
             return str;
 
-        std::string output = "";
+        std::string output;
         for (size_t pos = 0; pos < str.size() - 1; )
         {
@@ -363,5 +362,5 @@
     std::string getLowercase(const std::string& str)
     {
-        std::string output = std::string(str);
+        std::string output(str);
         lowercase(&output);
         return output;
@@ -387,5 +386,5 @@
     std::string getUppercase(const std::string& str)
     {
-        std::string output = std::string(str);
+        std::string output(str);
         uppercase(&output);
         return output;
Index: code/branches/pickup2/src/libraries/util/SubString.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/SubString.cc	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/SubString.cc	(revision 6412)
@@ -270,8 +270,5 @@
         }
         else
-        {
-            static std::string empty;
-            return empty;
-        }
+            return "";
     }
 
@@ -557,5 +554,5 @@
     void SubString::debug() const
     {
-        printf("Substring-information::count=%d ::", this->strings.size());
+        printf("Substring-information::count=%zd ::", this->strings.size());
         for (unsigned int i = 0; i < this->strings.size(); i++)
             printf("s%d='%s'::", i, this->strings[i].c_str());
Index: code/branches/pickup2/src/libraries/util/UTFStringConversions.h
===================================================================
--- code/branches/pickup2/src/libraries/util/UTFStringConversions.h	(revision 6405)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *      Reto Grieder
- *   Co-authors:
- *      ...
- */
-
-/**
-@file
-@brief
-    std::sring to Ogre::UTFString conversion functions
-*/
-
-#ifndef _UTFStringConversions_H__
-#define _UTFStringConversions_H__
-
-#include "UtilPrereqs.h"
-#include <OgreUTFString.h>
-
-namespace orxonox
-{
-    template <>
-    struct ConverterExplicit<std::string, Ogre::UTFString>
-    {
-        //! Converts an std::string into an Ogre::UTFString
-        inline static bool convert(Ogre::UTFString* output, const std::string& input)
-        {
-            Ogre::UTFString::code_point cp;
-            for (unsigned int i = 0; i < input.size(); ++i)
-            {
-              cp = input[i];
-              cp &= 0xFF;
-              output->append(1, cp);
-            }
-            return true;
-        }
-    };
-}
-
-#endif /* _UTFStringConversions_H__ */
Index: code/branches/pickup2/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/branches/pickup2/src/libraries/util/UtilPrereqs.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/UtilPrereqs.h	(revision 6412)
@@ -87,7 +87,6 @@
     class IntVector3;
     class MultiType;
-    class OutputBuffer;
-    class OutputBufferListener;
     class OutputHandler;
+    class OutputListener;
     template <ScopeID::Value>
     class Scope;
@@ -132,3 +131,10 @@
 }
 
+// Just so you don't have to include StringUtils.h everywhere just for this
+namespace orxonox
+{
+    extern _UtilExport std::string BLANKSTRING;
+}
+
+
 #endif /* _UtilPrereqs_H__ */
Index: code/branches/pickup2/src/libraries/util/mbool.h
===================================================================
--- code/branches/pickup2/src/libraries/util/mbool.h	(revision 6405)
+++ code/branches/pickup2/src/libraries/util/mbool.h	(revision 6412)
@@ -67,5 +67,5 @@
             inline bool operator!() const
                 { return (!this->value_.bool_); }
-            
+
             inline unsigned char& getMemory(){ return value_.memory_; }
 
