Index: code/trunk/src/libraries/core/ArgumentCompleter.h
===================================================================
--- code/trunk/src/libraries/core/ArgumentCompleter.h	(revision 7278)
+++ 	(revision )
@@ -1,79 +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:
- *      ...
- *
- */
-
-#ifndef _ArgumentCompleter_H__
-#define _ArgumentCompleter_H__
-
-#include "CorePrereqs.h"
-#include "ArgumentCompletionListElement.h"
-
-namespace orxonox
-{
-    class _CoreExport ArgumentCompleter
-    {
-        public:
-            ArgumentCompleter(ArgumentCompletionList (*function) (void)) : paramCount_(0), function_0_(function) {}
-            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1)) : paramCount_(1), function_1_(function) {}
-            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2)) : paramCount_(2), function_2_(function) {}
-            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3)) : paramCount_(3), function_3_(function) {}
-            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4)) : paramCount_(4), function_4_(function) {}
-            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)) : paramCount_(5), function_5_(function) {}
-
-            ArgumentCompletionList operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "")
-            {
-                switch (this->paramCount_)
-                {
-                    case 0:
-                        return (*this->function_0_)();
-                    case 1:
-                        return (*this->function_1_)(param1);
-                    case 2:
-                        return (*this->function_2_)(param1, param2);
-                    case 3:
-                        return (*this->function_3_)(param1, param2, param3);
-                    case 4:
-                        return (*this->function_4_)(param1, param2, param3, param4);
-                    case 5:
-                        return (*this->function_5_)(param1, param2, param3, param4, param5);
-                    default:
-                        return ArgumentCompletionList();
-                }
-            }
-
-        private:
-            unsigned char paramCount_;
-            ArgumentCompletionList (*function_0_) (void);
-            ArgumentCompletionList (*function_1_) (const std::string& param1);
-            ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2);
-            ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3);
-            ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4);
-            ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5);
-    };
-}
-
-#endif /* _ArgumentCompleter_H__ */
Index: code/trunk/src/libraries/core/ArgumentCompletionFunctions.cc
===================================================================
--- code/trunk/src/libraries/core/ArgumentCompletionFunctions.cc	(revision 7278)
+++ 	(revision )
@@ -1,154 +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:
- *      ...
- *
- */
-
-#include "ArgumentCompletionFunctions.h"
-
-#include <map>
-#include <boost/version.hpp>
-#include <boost/filesystem.hpp>
-
-#include "util/Convert.h"
-#include "util/StringUtils.h"
-#include "Identifier.h"
-#include "ConfigFileManager.h"
-#include "ConfigValueContainer.h"
-#include "TclThreadManager.h"
-
-// Boost 1.36 has some issues with deprecated functions that have been omitted
-#if (BOOST_VERSION == 103600)
-#  define BOOST_LEAF_FUNCTION filename
-#else
-#  define BOOST_LEAF_FUNCTION leaf
-#endif
-
-namespace orxonox
-{
-    namespace autocompletion
-    {
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(fallback)()
-        {
-            return ArgumentCompletionList();
-        }
-
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment)
-        {
-            ArgumentCompletionList dirlist;
-            ArgumentCompletionList filelist;
-
-            try
-            {
-                boost::filesystem::path input(fragment);
-                boost::filesystem::path startdirectory(input.branch_path());
-
-                if (!boost::filesystem::exists(startdirectory))
-                {
-                    startdirectory = ".";
-                }
-#ifdef ORXONOX_PLATFORM_WINDOWS
-                else
-                {
-                    const std::string& dir = startdirectory.string();
-                    if (dir.size() > 0 && dir[dir.size() - 1] == ':')
-                        startdirectory = dir + '/';
-                }
-#endif
-
-                boost::filesystem::directory_iterator file(startdirectory);
-                boost::filesystem::directory_iterator end;
-
-                while (file != end)
-                {
-                    if (boost::filesystem::is_directory(*file))
-                        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()));
-                    ++file;
-                }
-            }
-            catch (...) {}
-
-            filelist.insert(filelist.begin(), dirlist.begin(), dirlist.end());
-            return filelist;
-        }
-
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingssections)()
-        {
-            ArgumentCompletionList sectionList;
-
-            const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames();
-            for (std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
-                sectionList.push_back(ArgumentCompletionListElement(*it, getLowercase(*it)));
-
-            return sectionList;
-        }
-
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsentries)(const std::string& fragment, const std::string& section)
-        {
-            ArgumentCompletionList entryList;
-            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
-            const std::string& sectionLC = getLowercase(section);
-
-            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
-            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
-                entryList.push_back(ArgumentCompletionListElement(it->second.second->getName(), it->second.first));
-
-            return entryList;
-        }
-
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section)
-        {
-            ArgumentCompletionList oldValue;
-            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
-            const std::string& sectionLC = getLowercase(section);
-            const std::string& entryLC = getLowercase(entry);
-
-            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
-            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
-            {
-                if (it->second.first == entryLC)
-                {
-                    const std::string& valuestring = it->second.second->toString();
-                    oldValue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
-                }
-            }
-
-            return oldValue;
-        }
-
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(tclthreads)()
-        {
-            std::list<unsigned int> threadnumbers = TclThreadManager::getInstance().getThreadList();
-            ArgumentCompletionList threads;
-
-            for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
-                threads.push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));
-
-            return threads;
-        }
-    }
-}
Index: code/trunk/src/libraries/core/ArgumentCompletionFunctions.h
===================================================================
--- code/trunk/src/libraries/core/ArgumentCompletionFunctions.h	(revision 7278)
+++ 	(revision )
@@ -1,63 +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:
- *      ...
- *
- */
-
-#ifndef _ArgumentCompletionFunctions_H__
-#define _ArgumentCompletionFunctions_H__
-
-#include "CorePrereqs.h"
-#include "ArgumentCompleter.h"
-
-
-#define ARGUMENT_COMPLETION_FUNCTION_DECLARATION(functionname) \
-    _CoreExport ArgumentCompleter* functionname(); \
-    _CoreExport ArgumentCompletionList acf_##functionname
-
-#define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(functionname) \
-    ArgumentCompleter* functionname() \
-    { \
-        static ArgumentCompleter completer = ArgumentCompleter(&acf_##functionname); \
-        return &completer; \
-    } \
-    \
-    ArgumentCompletionList acf_##functionname
-
-
-namespace orxonox
-{
-    namespace autocompletion
-    {
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingssections)();
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsentries)(const std::string& fragment, const std::string& section);
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section);
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(tclthreads)();
-    }
-}
-
-#endif /* _ArgumentCompletionFunctions_H__ */
Index: code/trunk/src/libraries/core/ArgumentCompletionListElement.h
===================================================================
--- code/trunk/src/libraries/core/ArgumentCompletionListElement.h	(revision 7278)
+++ 	(revision )
@@ -1,73 +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:
- *      ...
- *
- */
-
-#ifndef _ArgumentCompletionListElement_H__
-#define _ArgumentCompletionListElement_H__
-
-#include "CorePrereqs.h"
-
-#include <list>
-#include <string>
-
-namespace orxonox
-{
-    const int ACL_MODE_NORMAL    = 1;
-    const int ACL_MODE_LOWERCASE = 2;
-    const int ACL_MODE_DISPLAY   = 4;
-
-    typedef std::list<ArgumentCompletionListElement> ArgumentCompletionList;
-
-    class _CoreExport ArgumentCompletionListElement
-    {
-        public:
-            ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normalCase_(normalcase) {}
-            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE), normalCase_(normalcase), lowerCase_(lowercase) {}
-            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE | ACL_MODE_DISPLAY), normalCase_(normalcase), lowerCase_(lowercase), display_(display) {}
-
-            const std::string& getString() const
-                { return this->normalCase_; }
-            const std::string& getComparable() const
-                { if (this->mode_ & ACL_MODE_LOWERCASE) { return this->lowerCase_; } else { return this->normalCase_; } }
-            const std::string& getDisplay() const
-                { if (this->mode_ & ACL_MODE_DISPLAY) { return this->display_; } else { return this->normalCase_; } }
-
-            bool lowercaseComparison() const
-                { return (this->mode_ & ACL_MODE_LOWERCASE); }
-
-            bool operator<(const ArgumentCompletionListElement& other) const
-                { return (this->getComparable() < other.getComparable()); }
-
-        private:
-            unsigned char mode_;
-            std::string normalCase_;
-            std::string lowerCase_;
-            std::string display_;
-    };
-}
-
-#endif /* _ArgumentCompletionListElement_H__ */
Index: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc	(revision 7278)
+++ code/trunk/src/libraries/core/BaseObject.cc	(revision 7284)
@@ -39,5 +39,4 @@
 #include "Event.h"
 #include "EventIncludes.h"
-#include "Functor.h"
 #include "Iterator.h"
 #include "Template.h"
@@ -45,4 +44,5 @@
 #include "XMLNameListener.h"
 #include "XMLPort.h"
+#include "command/Functor.h"
 
 namespace orxonox
@@ -477,6 +477,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 + ')');
+                    const ExecutorMemberPtr<BaseObject>& setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')');
+                    const ExecutorMemberPtr<BaseObject>& getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')');
                     setfunctor->setDefaultValue(1, statename);
                     getfunctor->setDefaultValue(1, statename);
Index: code/trunk/src/libraries/core/BaseObject.h
===================================================================
--- code/trunk/src/libraries/core/BaseObject.h	(revision 7278)
+++ code/trunk/src/libraries/core/BaseObject.h	(revision 7284)
@@ -196,5 +196,5 @@
             mbool                   bVisible_;                 //!< True = the object is visible
             std::string             mainStateName_;
-            Functor*                mainStateFunctor_;
+            FunctorPtr              mainStateFunctor_;
             std::set<std::string>   networkTemplateNames_;
 
Index: code/trunk/src/libraries/core/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/CMakeLists.txt	(revision 7278)
+++ code/trunk/src/libraries/core/CMakeLists.txt	(revision 7284)
@@ -19,4 +19,5 @@
 
 SET_SOURCE_FILES(CORE_SRC_FILES
+  CommandLineParser.cc
   ConfigValueContainer.cc
   Core.cc
@@ -29,5 +30,4 @@
   GraphicsManager.cc
   GUIManager.cc
-  IOConsole.cc
   Language.cc
   LuaState.cc
@@ -35,14 +35,5 @@
   OrxonoxClass.cc
   Resource.cc
-  ScopedSingletonManager.cc
   WindowEventListener.cc
-
-  # command
-  CommandEvaluation.cc
-  CommandExecutor.cc
-  CommandLineParser.cc
-  ConsoleCommand.cc
-  ConsoleCommandCompilation.cc
-  Executor.cc
 
   # hierarchy
@@ -60,11 +51,6 @@
   XMLNameListener.cc
 
-  # shell
-  IRC.cc
-  Shell.cc
-  TclBind.cc
-
 COMPILATION_BEGIN FilesystemCompilation.cc
-  ArgumentCompletionFunctions.cc
+  command/ArgumentCompletionFunctions.cc
   ConfigFileManager.cc
   MemoryArchive.cc
@@ -75,9 +61,10 @@
   ThreadPool.cc
 COMPILATION_BEGIN ThreadCompilation.cc
-  TclThreadManager.cc
+  command/TclThreadManager.cc
   Thread.cc
 COMPILATION_END
 )
 
+ADD_SUBDIRECTORY(command)
 ADD_SUBDIRECTORY(input)
 
@@ -85,5 +72,5 @@
   FIND_HEADER_FILES
   TOLUA_FILES
-    CommandExecutor.h
+    command/CommandExecutor.h
     ConfigFileManager.h
     Game.h
Index: code/trunk/src/libraries/core/CommandEvaluation.cc
===================================================================
--- code/trunk/src/libraries/core/CommandEvaluation.cc	(revision 7278)
+++ 	(revision )
@@ -1,313 +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:
- *      ...
- *
- */
-
-#include "CommandEvaluation.h"
-
-#include "util/Debug.h"
-#include "util/StringUtils.h"
-#include "ConsoleCommand.h"
-#include "Identifier.h"
-
-namespace orxonox
-{
-    CommandEvaluation::CommandEvaluation()
-    {
-        this->initialize("");
-        this->state_ = CommandState::Uninitialized;
-    }
-
-    void CommandEvaluation::initialize(const std::string& command)
-    {
-        this->bNewCommand_ = true;
-        this->bCommandChanged_ = false;
-        this->originalCommand_ = command;
-        this->command_ = command;
-        this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
-
-        this->additionalParameter_.clear();
-
-        this->bEvaluatedParams_ = false;
-
-        this->listOfPossibleIdentifiers_.clear();
-        this->listOfPossibleFunctions_.clear();
-        this->listOfPossibleArguments_.clear();
-
-        this->functionclass_ = 0;
-        this->function_ = 0;
-        this->possibleArgument_.clear();
-        this->argument_.clear();
-
-        this->errorMessage_.clear();
-        this->state_ = CommandState::Empty;
-    }
-
-    bool CommandEvaluation::isValid() const
-    {
-        return (this->function_);
-    }
-
-    bool CommandEvaluation::execute() const
-    {
-        if (!this->isValid())
-            return false;
-
-        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;
-            (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
-            return true;
-        }
-
-        if (!this->bCommandChanged_ || nocaseCmp(removeTrailingWhitespaces(this->command_), removeTrailingWhitespaces(this->originalCommand_)) == 0)
-        {
-            COUT(4) << "CE_execute: " << this->command_ << "\n";
-
-            unsigned int startindex = this->getStartindex();
-            if (this->commandTokens_.size() > startindex)
-                return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));
-            else
-                return this->function_->parse(removeSlashes(this->additionalParameter_));
-        }
-
-        return false;
-    }
-
-    const std::string& CommandEvaluation::complete()
-    {
-        if (!this->bNewCommand_)
-        {
-            switch (this->state_)
-            {
-                case CommandState::Uninitialized:
-                    break;
-                case CommandState::Empty:
-                    break;
-                case CommandState::ShortcutOrIdentifier:
-                    if (this->function_)
-                    {
-                        if (this->function_->getParamCount() == 0)
-                            return (this->command_ = this->function_->getName());
-                        else
-                            return (this->command_ = this->function_->getName() + ' ');
-                    }
-                    else if (this->functionclass_)
-                        return (this->command_ = this->functionclass_->getName() + ' ');
-                    break;
-                case CommandState::Function:
-                    if (this->function_)
-                    {
-                        if (this->function_->getParamCount() == 0)
-                            return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName());
-                        else
-                            return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName() + ' ');
-                    }
-                    break;
-                case CommandState::ParamPreparation:
-                case CommandState::Params:
-                {
-                    if (this->argument_.empty() && this->possibleArgument_.empty())
-                        break;
-
-                    unsigned int maxIndex = this->commandTokens_.size();
-                    if (this->command_[this->command_.size() - 1] != ' ')
-                        maxIndex -= 1;
-                    std::string whitespace;
-
-                    if (!this->possibleArgument_.empty())
-                    {
-                        this->argument_ = this->possibleArgument_;
-                        if (this->function_->getParamCount() > (maxIndex + 1 - this->getStartindex()))
-                            whitespace = " ";
-                    }
-
-                    return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + ' ' + this->argument_ + whitespace);
-                    break;
-                }
-                case CommandState::Finished:
-                    break;
-                case CommandState::Error:
-                    break;
-            }
-        }
-        this->bNewCommand_ = false;
-        return this->command_;
-    }
-
-    std::string CommandEvaluation::hint() const
-    {
-        switch (this->state_)
-        {
-            case CommandState::Uninitialized:
-                break;
-            case CommandState::Empty:
-            case CommandState::ShortcutOrIdentifier:
-                if (this->listOfPossibleFunctions_.size() == 0)
-                    return CommandEvaluation::dump(this->listOfPossibleIdentifiers_);
-                else if (this->listOfPossibleIdentifiers_.size() == 0)
-                    return CommandEvaluation::dump(this->listOfPossibleFunctions_);
-                else
-                    return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
-                break;
-            case CommandState::Function:
-                return CommandEvaluation::dump(this->listOfPossibleFunctions_);
-                break;
-            case CommandState::ParamPreparation:
-            case CommandState::Params:
-                if (this->listOfPossibleArguments_.size() > 0)
-                    return CommandEvaluation::dump(this->listOfPossibleArguments_);
-                else
-                    return CommandEvaluation::dump(this->function_);
-            case CommandState::Finished:
-                if (this->function_)
-                    return CommandEvaluation::dump(this->function_);
-                break;
-            case CommandState::Error:
-                return this->errorMessage_;
-                break;
-        }
-
-        return "";
-    }
-
-    void CommandEvaluation::evaluateParams()
-    {
-        this->bEvaluatedParams_ = false;
-
-        for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++)
-            this->param_[i] = MT_Type::Null;
-
-        if (!this->isValid())
-            return;
-
-        unsigned int startindex = this->getStartindex();
-
-        if (this->commandTokens_.size() <= startindex)
-        {
-            if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " "))
-                this->bEvaluatedParams_ = true;
-        }
-        else if (this->commandTokens_.size() > startindex)
-        {
-            if (this->function_->evaluate(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))
-                this->bEvaluatedParams_ = true;
-        }
-    }
-
-    void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType param)
-    {
-        if (index < MAX_FUNCTOR_ARGUMENTS)
-            this->param_[index] = param;
-    }
-
-    MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const
-    {
-        if (index < MAX_FUNCTOR_ARGUMENTS)
-            return this->param_[index];
-
-        return MT_Type::Null;
-    }
-
-    bool CommandEvaluation::hasReturnvalue() const
-    {
-        if (this->function_)
-            return this->function_->hasReturnvalue();
-
-        return MT_Type::Null;
-    }
-
-    MultiType CommandEvaluation::getReturnvalue() const
-    {
-        if (this->function_)
-            return this->function_->getReturnvalue();
-
-        return MultiType();
-    }
-
-
-    unsigned int CommandEvaluation::getStartindex() const
-    {
-        if (this->functionclass_ && this->function_)
-            return 2;
-        else if (this->function_)
-            return 1;
-        else
-            return 0;
-    }
-
-    std::string CommandEvaluation::dump(const std::list<std::pair<const std::string*, const std::string*> >& list)
-    {
-        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);
-        }
-        return output;
-    }
-
-    std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
-    {
-        std::string output;
-        for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
-        {
-            if (it != list.begin())
-                output += ' ';
-
-            output += it->getDisplay();
-        }
-        return output;
-    }
-
-    std::string CommandEvaluation::dump(const ConsoleCommand* command)
-    {
-        std::string output = command->getName();
-        if (command->getParamCount() > 0)
-            output += ": ";
-
-        for (unsigned int i = 0; i < command->getParamCount(); i++)
-        {
-            if (i != 0)
-                output += ' ';
-
-            if (command->defaultValueSet(i))
-                output += '[';
-            else
-                output += '{';
-
-            output += command->getTypenameParam(i);
-
-            if (command->defaultValueSet(i))
-                output += '=' + command->getDefaultValue(i).getString() + ']';
-            else
-                output += '}';
-        }
-        return output;
-    }
-}
Index: code/trunk/src/libraries/core/CommandEvaluation.h
===================================================================
--- code/trunk/src/libraries/core/CommandEvaluation.h	(revision 7278)
+++ 	(revision )
@@ -1,124 +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:
- *      ...
- *
- */
-
-#ifndef _CommandEvaluation_H__
-#define _CommandEvaluation_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-#include <list>
-
-#include "ArgumentCompletionListElement.h"
-#include "util/SubString.h"
-#include "util/MultiType.h"
-
-namespace orxonox
-{
-    namespace CommandState
-    {
-        enum Value
-        {
-            Uninitialized,
-            Empty,
-            ShortcutOrIdentifier,
-            Function,
-            ParamPreparation,
-            Params,
-            Finished,
-            Error
-        };
-    }
-
-    class _CoreExport CommandEvaluation
-    {
-        friend class CommandExecutor;
-
-        public:
-            CommandEvaluation();
-
-            void initialize(const std::string& command);
-
-            bool execute() const;
-            const std::string& complete();
-            std::string hint() const;
-            void evaluateParams();
-
-            bool isValid() const;
-
-            inline ConsoleCommand* getConsoleCommand() const
-                { return this->function_; }
-            inline const std::string& getOriginalCommand() const
-                { return this->originalCommand_; }
-            inline const std::string& getCommand() const
-                { return this->command_; }
-
-            inline void setAdditionalParameter(const std::string& param)
-                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
-            inline std::string getAdditionalParameter() const
-                { return (!this->additionalParameter_.empty()) ? (' ' + this->additionalParameter_) : ""; }
-
-            void setEvaluatedParameter(unsigned int index, MultiType param);
-            MultiType getEvaluatedParameter(unsigned int index) const;
-
-            bool hasReturnvalue() const;
-            MultiType getReturnvalue() const;
-
-        private:
-            unsigned int getStartindex() const;
-            static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
-            static std::string dump(const ArgumentCompletionList& list);
-            static std::string dump(const ConsoleCommand* command);
-
-
-            bool bNewCommand_;
-            bool bCommandChanged_;
-
-            std::string originalCommand_;
-            std::string command_;
-            SubString commandTokens_;
-            std::string additionalParameter_;
-
-            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
-            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
-            ArgumentCompletionList listOfPossibleArguments_;
-
-            Identifier* functionclass_;
-            ConsoleCommand* function_;
-            std::string possibleArgument_;
-            std::string argument_;
-
-            std::string errorMessage_;
-            CommandState::Value state_;
-
-            bool bEvaluatedParams_;
-            MultiType param_[5];
-    };
-}
-
-#endif /* _CommandEvaluation_H__ */
Index: code/trunk/src/libraries/core/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/CommandExecutor.cc	(revision 7278)
+++ 	(revision )
@@ -1,677 +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:
- *      ...
- *
- */
-
-#include "CommandExecutor.h"
-
-#include "util/Debug.h"
-#include "util/StringUtils.h"
-#include "ConsoleCommand.h"
-#include "Identifier.h"
-#include "Language.h"
-#include "TclBind.h"
-
-namespace orxonox
-{
-    CommandExecutor& CommandExecutor::getInstance()
-    {
-        static CommandExecutor instance;
-        return instance;
-    }
-
-    CommandEvaluation& CommandExecutor::getEvaluation()
-    {
-        return CommandExecutor::getInstance().evaluation_;
-    }
-
-    const CommandEvaluation& CommandExecutor::getLastEvaluation()
-    {
-        return CommandExecutor::getInstance().evaluation_;
-    }
-
-    ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command, bool bDeleteAtExit)
-    {
-        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(command->getName());
-        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
-        {
-            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << '.' << std::endl;
-        }
-
-        // Make sure we can also delete the external ConsoleCommands that don't belong to an Identifier
-        if (command && bDeleteAtExit)
-        {
-            CommandExecutor::getInstance().consoleCommandExternals_.insert(command);
-        }
-
-        CommandExecutor::getInstance().consoleCommandShortcuts_[command->getName()] = command;
-        CommandExecutor::getInstance().consoleCommandShortcuts_LC_[getLowercase(command->getName())] = command;
-        return (*command);
-    }
-
-    /**
-        @brief Returns the executor of a console command shortcut with given name.
-        @brief name The name of the requested console command shortcut
-        @return The executor of the requested console command shortcut
-    */
-    ConsoleCommand* CommandExecutor::getConsoleCommandShortcut(const std::string& name)
-    {
-        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);
-        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
-            return it->second;
-        else
-            return 0;
-    }
-
-    /**
-        @brief Returns the executor of a console command shortcut with given name in lowercase.
-        @brief name The name of the requested console command shortcut in lowercase
-        @return The executor of the requested console command shortcut
-    */
-    ConsoleCommand* CommandExecutor::getLowercaseConsoleCommandShortcut(const std::string& name)
-    {
-        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);
-        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end())
-            return it->second;
-        else
-            return 0;
-    }
-
-    bool CommandExecutor::execute(const std::string& command, bool useTcl)
-    {
-        if (useTcl)
-            return TclBind::eval(command);
-
-        CommandExecutor::parseIfNeeded(command);
-        return CommandExecutor::getEvaluation().execute();
-    }
-
-    MultiType CommandExecutor::getReturnValue()
-    {
-        return CommandExecutor::getEvaluation().getReturnvalue();
-    }
-
-    std::string CommandExecutor::getReturnValueString()
-    {
-        return CommandExecutor::getEvaluation().getReturnvalue().getString();
-    }
-
-    std::string CommandExecutor::complete(const std::string& command)
-    {
-        CommandExecutor::parseIfNeeded(command);
-        return CommandExecutor::getEvaluation().complete();
-    }
-
-    std::string CommandExecutor::hint(const std::string& command)
-    {
-        CommandExecutor::parseIfNeeded(command);
-        return CommandExecutor::getEvaluation().hint();
-    }
-
-    CommandEvaluation CommandExecutor::evaluate(const std::string& command)
-    {
-        CommandExecutor::parse(command);
-        CommandExecutor::getEvaluation().evaluateParams();
-        return CommandExecutor::getEvaluation();
-    }
-
-    void CommandExecutor::parseIfNeeded(const std::string& command)
-    {
-        if (CommandExecutor::getEvaluation().state_ == CommandState::Uninitialized)
-        {
-            CommandExecutor::parse(command);
-        }
-        else if (CommandExecutor::getEvaluation().originalCommand_ != command)
-        {
-            if (CommandExecutor::getEvaluation().command_ == command)
-            {
-                CommandExecutor::parse(command);
-                CommandExecutor::getEvaluation().bNewCommand_ = false;
-            }
-            else
-            {
-                CommandExecutor::parse(command);
-            }
-        }
-    }
-
-    void CommandExecutor::parse(const std::string& command, bool bInitialize)
-    {
-        if (bInitialize)
-            CommandExecutor::getEvaluation().initialize(command);
-
-        CommandExecutor::getEvaluation().commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
-        CommandExecutor::getEvaluation().command_ = command;
-
-        switch (CommandExecutor::getEvaluation().state_)
-        {
-            case CommandState::Uninitialized:
-            {
-                // Impossible
-                break;
-            }
-            case CommandState::Empty:
-            {
-                if (CommandExecutor::argumentsGiven() == 0)
-                {
-                    CommandExecutor::createListOfPossibleFunctions("");
-                    CommandExecutor::createListOfPossibleIdentifiers("");
-                    break;
-                }
-                else
-                {
-                    CommandExecutor::getEvaluation().state_ = CommandState::ShortcutOrIdentifier;
-                    // Move on to next case
-                }
-            }
-            case CommandState::ShortcutOrIdentifier:
-            {
-                if (CommandExecutor::argumentsGiven() > 1)
-                {
-                    // There's a finished first argument - check if it's a shortcut or a classname
-                    CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
-                    CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
-
-                    if (CommandExecutor::getEvaluation().function_)
-                    {
-                        // It's a shortcut
-                        CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                        CommandExecutor::getEvaluation().functionclass_ = 0;
-                        // Move on to next case
-                    }
-                    else if (CommandExecutor::getEvaluation().functionclass_)
-                    {
-                        // It's a functionname
-                        CommandExecutor::getEvaluation().state_ = CommandState::Function;
-                        CommandExecutor::getEvaluation().function_ = 0;
-                        // Move on to next case
-                    }
-                    else
-                    {
-                        // The first argument is bad
-                        CommandExecutor::getEvaluation().state_ = CommandState::Error;
-                        AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + ' ' + GetLocalisation("commandexecutorunknownfirstargument") + '.';
-                        return;
-                    }
-                }
-                else
-                {
-                    // There's no finished first argument - search possible shortcuts or classnames
-                    CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0));
-                    CommandExecutor::createListOfPossibleIdentifiers(CommandExecutor::getArgument(0));
-
-                    unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
-                    unsigned int num_identifiers = CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.size();
-
-                    if (num_functions == 1 && num_identifiers == 0)
-                    {
-                        // It's a shortcut
-                        const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname);
-                        if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0)))
-                        {
-                            // Unfinished shortcut
-                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        }
-                        CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                        CommandExecutor::getEvaluation().functionclass_ = 0;
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
-                        if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
-                        {
-                            CommandExecutor::getEvaluation().command_ += ' ';
-                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        }
-                        // Move on to next case
-                    }
-                    else if (num_identifiers == 1 && num_functions == 0)
-                    {
-                        // It's a classname
-                        const std::string& classname = *CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()->first;
-                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname);
-                        if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0)))
-                        {
-                            // Unfinished classname
-                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        }
-                        CommandExecutor::getEvaluation().state_ = CommandState::Function;
-                        CommandExecutor::getEvaluation().function_ = 0;
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ';
-                        // Move on to next case
-                    }
-                    else if (num_identifiers == 0 && num_functions == 0)
-                    {
-                        // No possibilities
-                        CommandExecutor::getEvaluation().state_ = CommandState::Error;
-                        AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + ' ' + CommandExecutor::getArgument(0) + '.';
-                        return;
-                    }
-                    else
-                    {
-                        // There are several possiblilities
-                        std::list<std::pair<const std::string*, const std::string*> > temp;
-                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.end());
-                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.end());
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getCommonBegin(temp);
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
-                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
-                        CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        return;
-                    }
-                }
-            }
-            case CommandState::Function:
-            {
-                if (CommandExecutor::getEvaluation().functionclass_)
-                {
-                    // There is a classname - search for the commandname
-                    if (CommandExecutor::argumentsGiven() > 2)
-                    {
-                        // There is a finished second argument - check if it's a commandname
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
-
-                        if (CommandExecutor::getEvaluation().function_)
-                        {
-                            // It's a function
-                            CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                            // Move on to next case
-                        }
-                        else
-                        {
-                            // The second argument is bad
-                            CommandExecutor::getEvaluation().state_ = CommandState::Error;
-                            AddLanguageEntry("commandexecutorunknownsecondargument", "is not a function of");
-                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknownsecondargument") + " " + CommandExecutor::getEvaluation().functionclass_->getName() + ".";
-                            return;
-                        }
-                    }
-                    else
-                    {
-                        // There is no finished second argument - search for possibilities
-                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
-                        unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
-
-                        if (num_functions == 1)
-                        {
-                            // It's a function
-                            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)))
-                            {
-                                // Unfinished function
-                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                            }
-                            CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getEvaluation().function_->getName();
-                            if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
-                            {
-                                CommandExecutor::getEvaluation().command_ += ' ';
-                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                            }
-                            // Move on to next case
-                        }
-                        else if (num_functions == 0)
-                        {
-                            // No possibilities
-                            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) + '.';
-                            return;
-                        }
-                        else
-                        {
-                            // There are several possibilities
-                            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;
-                            return;
-                        }
-                    }
-                }
-                else
-                {
-                    // There is no classname - move on to CommandState::ParamPreparation
-                }
-            }
-            case CommandState::ParamPreparation:
-            {
-                if (CommandExecutor::getEvaluation().function_->getParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))
-                {
-                    CommandExecutor::getEvaluation().state_ = CommandState::Finished;
-                    return;
-                }
-                else
-                {
-                    unsigned int argumentNumber = CommandExecutor::argumentsGiven() - 2;
-                    if (CommandExecutor::getEvaluation().functionclass_)
-                        argumentNumber -= 1;
-
-                    CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
-                    CommandExecutor::getEvaluation().state_ = CommandState::Params;
-
-                    if (CommandExecutor::getEvaluation().bCommandChanged_)
-                    {
-                        // Don't do more than one change
-                        return;
-                    }
-                }
-            }
-            case CommandState::Params:
-            {
-                if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 1)
-                {
-                    // There is exactly one possible argument
-                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
-                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
-                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                    return;
-                }
-                else if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 0)
-                {
-                    // The user tries something new - we let him do
-                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getLastArgument();
-                    return;
-                }
-                else
-                {
-                    // There are several possibilities
-                    unsigned int argumentNumber = CommandExecutor::argumentsGiven();
-                    if (argumentNumber > 0)
-                        --argumentNumber;
-                    if (CommandExecutor::getEvaluation().functionclass_ && argumentNumber > 0)
-                        --argumentNumber;
-
-                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleArguments_);
-                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
-                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                    return;
-                }
-            }
-            case CommandState::Finished:
-            {
-                // Nothing more to do
-                break;
-            }
-            case CommandState::Error:
-            {
-                // Bad, very bad
-                break;
-            }
-        }
-    }
-
-    unsigned int CommandExecutor::argumentsFinished()
-    {
-        unsigned int argumentsGiven = CommandExecutor::argumentsGiven();
-        if (argumentsGiven > 0)
-            return argumentsGiven - 1;
-        else
-            return 0;
-    }
-
-    unsigned int CommandExecutor::argumentsGiven()
-    {
-        if (CommandExecutor::getEvaluation().command_.size() > 0 && CommandExecutor::getEvaluation().command_[CommandExecutor::getEvaluation().command_.size() - 1] == ' ')
-            return CommandExecutor::getEvaluation().commandTokens_.size() + 1;
-        else
-            return CommandExecutor::getEvaluation().commandTokens_.size();
-    }
-
-    bool CommandExecutor::enoughArgumentsGiven(ConsoleCommand* command)
-    {
-        if (CommandExecutor::getEvaluation().functionclass_)
-            return (CommandExecutor::argumentsGiven() > (2 + command->getParamCount()));
-        else
-            return (CommandExecutor::argumentsGiven() > (1 + command->getParamCount()));
-    }
-
-    const std::string& CommandExecutor::getArgument(unsigned int index)
-    {
-        if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
-            return CommandExecutor::getEvaluation().commandTokens_[index];
-        else
-            return BLANKSTRING;
-    }
-
-    const std::string& CommandExecutor::getLastArgument()
-    {
-        return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1);
-    }
-
-    void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment)
-    {
-        CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
-        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.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
-    }
-
-    void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier)
-    {
-        CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear();
-        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.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.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
-        }
-    }
-
-    void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param)
-    {
-        CommandExecutor::createArgumentCompletionList(command, param);
-
-        CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
-        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.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
-            }
-            else
-            {
-                if (it->getComparable().find(fragment) == 0 || fragment.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
-            }
-        }
-    }
-
-    Identifier* CommandExecutor::getPossibleIdentifier(const std::string& 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;
-
-        return 0;
-    }
-
-    ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
-    {
-        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;
-        }
-        else
-        {
-            std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
-            if (it != identifier->getLowercaseConsoleCommandMapEnd())
-                return it->second;
-        }
-        return 0;
-    }
-
-    const std::string& CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
-    {
-        CommandExecutor::createArgumentCompletionList(command, param);
-
-        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();
-            }
-            else
-            {
-                if (it->getComparable() == name)
-                    return it->getString();
-            }
-        }
-
-        return BLANKSTRING;
-    }
-
-    void CommandExecutor::createArgumentCompletionList(ConsoleCommand* command, unsigned int param)
-    {
-        std::string params[5];
-
-        unsigned int index = 0;
-        unsigned int lowestIndex = 1 + (CommandExecutor::getEvaluation().functionclass_ != 0);
-
-        for (unsigned int i = CommandExecutor::argumentsGiven() - 1; i >= lowestIndex; --i)
-        {
-            params[index] = CommandExecutor::getArgument(i);
-            ++index;
-            if (index >= 5)
-                break;
-        }
-
-        command->createArgumentCompletionList(param, params[0], params[1], params[2], params[3], params[4]);
-    }
-
-    std::string CommandExecutor::getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list)
-    {
-        if (list.size() == 0)
-        {
-            return "";
-        }
-        else if (list.size() == 1)
-        {
-            return ((*list.begin()->first) + ' ');
-        }
-        else
-        {
-            std::string output;
-            for (unsigned int i = 0; true; i++)
-            {
-                char temp = 0;
-                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 == list.begin())
-                        {
-                            temp = (*it->first)[i];
-                        }
-                        else
-                        {
-                            if (temp != (*it->first)[i])
-                                return output;
-                        }
-                    }
-                    else
-                    {
-                        return output;
-                    }
-                }
-                output += temp;
-            }
-            return output;
-        }
-    }
-
-    std::string CommandExecutor::getCommonBegin(const ArgumentCompletionList& list)
-    {
-        if (list.size() == 0)
-        {
-            return "";
-        }
-        else if (list.size() == 1)
-        {
-            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)
-                {
-                    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 (tempComparable != argumentComparable[i])
-                                return output;
-                            else if (temp != argument[i])
-                                temp = tempComparable;
-                        }
-                    }
-                    else
-                    {
-                        return output;
-                    }
-                }
-                output += temp;
-            }
-            return output;
-        }
-    }
-
-    void CommandExecutor::destroyExternalCommands()
-    {
-        for (std::set<ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandExternals_.begin();
-            it != CommandExecutor::getInstance().consoleCommandExternals_.end(); ++it)
-            delete *it;
-    }
-}
Index: code/trunk/src/libraries/core/CommandExecutor.h
===================================================================
--- code/trunk/src/libraries/core/CommandExecutor.h	(revision 7278)
+++ 	(revision )
@@ -1,114 +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:
- *      ...
- *
- */
-
-#ifndef _CommandExecutor_H__
-#define _CommandExecutor_H__
-
-#include "CorePrereqs.h"
-
-#include <map>
-#include <set>
-#include <string>
-
-#include "util/MultiType.h"
-#include "CommandEvaluation.h"
-
-// tolua_begin
-namespace orxonox
-{
-    class _CoreExport CommandExecutor
-    {
-// tolua_end
-        public:
-            static bool execute(const std::string& command, bool useTcl = true); // tolua_export
-            static MultiType getReturnValue();
-            static std::string getReturnValueString(); // tolua_export
-
-            static std::string complete(const std::string& command);
-            static std::string hint(const std::string& command);
-
-            static CommandEvaluation evaluate(const std::string& command);
-            static const CommandEvaluation& getLastEvaluation();
-
-            static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command, bool bDeleteAtExit = false);
-            static ConsoleCommand* getConsoleCommandShortcut(const std::string& name);
-            static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name);
-
-            /** @brief Returns the map that stores all console commands. @return The const_iterator */
-            static inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; }
-            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
-            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); }
-            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
-            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); }
-
-            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
-            static inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; }
-            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
-            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); }
-            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
-            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }
-
-            static void destroyExternalCommands();
-
-        private:
-            CommandExecutor() {}
-            CommandExecutor(const CommandExecutor& other);
-            ~CommandExecutor() {}
-
-            static CommandExecutor& getInstance();
-            static CommandEvaluation& getEvaluation();
-
-            static void parseIfNeeded(const std::string& command);
-            static void parse(const std::string& command, bool bInitialize = true);
-
-            static unsigned int argumentsFinished();
-            static unsigned int argumentsGiven();
-            static bool enoughArgumentsGiven(ConsoleCommand* command);
-            static const std::string& getArgument(unsigned int index);
-            static const std::string& getLastArgument();
-
-            static void createListOfPossibleIdentifiers(const std::string& fragment);
-            static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
-            static void createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param);
-
-            static Identifier* getPossibleIdentifier(const std::string& name);
-            static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
-            static const std::string& getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
-
-            static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param);
-            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
-            static std::string getCommonBegin(const ArgumentCompletionList& list);
-
-            CommandEvaluation evaluation_;
-            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_;
-            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_;
-            std::set<ConsoleCommand*>              consoleCommandExternals_;
-    }; // tolua_export
-} // tolua_export
-
-#endif /* _CommandExecutor_H__ */
Index: code/trunk/src/libraries/core/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.cc	(revision 7278)
+++ code/trunk/src/libraries/core/CommandLineParser.cc	(revision 7284)
@@ -335,5 +335,5 @@
     {
         std::vector<std::string> args;
-        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '(', ')', false);
+        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
         for (unsigned i = 0; i < tokens.size(); ++i)
             args.push_back(tokens[i]);
@@ -363,5 +363,5 @@
                 //if (!(line[0] == '#' || line[0] == '%'))
                 //{
-                SubString tokens(line, " ", " ", false, '\\', true, '"', true, '(', ')', false, '#');
+                SubString tokens(line, " ", " ", false, '\\', true, '"', true, '\0', '\0', false, '#');
                 for (unsigned i = 0; i < tokens.size(); ++i)
                     if (tokens[i][0] != '#')
Index: code/trunk/src/libraries/core/CommandLineParser.h
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.h	(revision 7278)
+++ code/trunk/src/libraries/core/CommandLineParser.h	(revision 7284)
@@ -64,5 +64,5 @@
         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.
+        So "--startVector {2, 4, 5}" is perfectly legal.
 
         Retrieving an argument is possible with the getCommandLineArgument function of the
Index: code/trunk/src/libraries/core/ConfigFileManager.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigFileManager.cc	(revision 7278)
+++ code/trunk/src/libraries/core/ConfigFileManager.cc	(revision 7284)
@@ -34,7 +34,7 @@
 #include "util/Math.h"
 #include "util/StringUtils.h"
-#include "ConsoleCommand.h"
 #include "ConfigValueContainer.h"
 #include "PathConfig.h"
+#include "command/ConsoleCommand.h"
 
 namespace orxonox
@@ -277,11 +277,14 @@
                             if (commentposition == std::string::npos)
                             {
-                                value = removeTrailingWhitespaces(line.substr(pos1 + 1));
+                                value = line.substr(pos1 + 1);
                             }
                             else
                             {
-                                value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));
+                                value = line.substr(pos1 + 1, commentposition - pos1 - 1);
                                 comment = removeTrailingWhitespaces(line.substr(commentposition));
                             }
+
+                            value = removeTrailingWhitespaces(value);
+                            value = removeSlashes(value);
 
                             if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1)
@@ -425,4 +428,16 @@
     ////////////////////////
 
+    static const std::string __CC_load_name = "reloadSettings";
+    static const std::string __CC_setFilename_name = "setSettingsFile";
+    static const std::string __CC_config_name = "config";
+    static const std::string __CC_tconfig_name = "tconfig";
+    static const std::string __CC_getConfig_name = "getConfig";
+
+    SetConsoleCommand(__CC_load_name,            &ConfigFile::load);
+    SetConsoleCommand(__CC_setFilename_name,     &SettingsConfigFile::setFilename);
+    SetConsoleCommand(__CC_config_name,          &SettingsConfigFile::config).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
+    SetConsoleCommand(__CC_tconfig_name,         &SettingsConfigFile::tconfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
+    SetConsoleCommand(__CC_getConfig_name,       &SettingsConfigFile::getConfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries());
+
     SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0;
 
@@ -430,18 +445,18 @@
         : ConfigFile(filename)
     {
-        ConsoleCommand* command = createConsoleCommand(createFunctor(&ConfigFile::load, this), "reloadSettings");
-        CommandExecutor::addConsoleCommandShortcut(command);
-        command = createConsoleCommand(createFunctor(&SettingsConfigFile::setFilename, this), "setSettingsFile");
-        CommandExecutor::addConsoleCommandShortcut(command);
-        command = createConsoleCommand(createFunctor(&SettingsConfigFile::config, this), "config");
-        CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
-        command = createConsoleCommand(createFunctor(&SettingsConfigFile::tconfig, this), "tconfig");
-        CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
-        command = createConsoleCommand(createFunctor(&SettingsConfigFile::getConfig, this), "getConfig");
-        CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries());
+        ModifyConsoleCommand(__CC_load_name).setObject(this);
+        ModifyConsoleCommand(__CC_setFilename_name).setObject(this);
+        ModifyConsoleCommand(__CC_config_name).setObject(this);
+        ModifyConsoleCommand(__CC_tconfig_name).setObject(this);
+        ModifyConsoleCommand(__CC_getConfig_name).setObject(this);
     }
 
     SettingsConfigFile::~SettingsConfigFile()
     {
+        ModifyConsoleCommand(__CC_load_name).setObject(0);
+        ModifyConsoleCommand(__CC_setFilename_name).setObject(0);
+        ModifyConsoleCommand(__CC_config_name).setObject(0);
+        ModifyConsoleCommand(__CC_tconfig_name).setObject(0);
+        ModifyConsoleCommand(__CC_getConfig_name).setObject(0);
     }
 
@@ -543,12 +558,14 @@
     }
 
-    bool SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value)
-    {
-        return this->configImpl(section, entry, value, &ConfigValueContainer::set);
-    }
-
-    bool SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value)
-    {
-        return this->configImpl(section, entry, value, &ConfigValueContainer::tset);
+    void SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value)
+    {
+        if (!this->configImpl(section, entry, value, &ConfigValueContainer::set))
+            COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl;
+    }
+
+    void SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value)
+    {
+        if (!this->configImpl(section, entry, value, &ConfigValueContainer::tset))
+            COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl;
     }
 
Index: code/trunk/src/libraries/core/ConfigFileManager.h
===================================================================
--- code/trunk/src/libraries/core/ConfigFileManager.h	(revision 7278)
+++ code/trunk/src/libraries/core/ConfigFileManager.h	(revision 7284)
@@ -331,6 +331,6 @@
             void clean(bool bCleanComments = false); // tolua_export
 
-            bool config(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
-            bool tconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
+            void config(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
+            void tconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
             std::string getConfig(const std::string& section, const std::string& entry); // tolua_export
 
Index: code/trunk/src/libraries/core/ConfigValueContainer.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigValueContainer.cc	(revision 7278)
+++ code/trunk/src/libraries/core/ConfigValueContainer.cc	(revision 7284)
@@ -302,5 +302,5 @@
     bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input)
     {
-        SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '(', ')', false, '\0');
+        SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '\0', '\0', false, '\0');
         int index = -1;
         bool success = false;
Index: code/trunk/src/libraries/core/ConsoleCommand.cc
===================================================================
--- code/trunk/src/libraries/core/ConsoleCommand.cc	(revision 7278)
+++ 	(revision )
@@ -1,72 +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:
- *      ...
- *
- */
-
-#include "ConsoleCommand.h"
-
-namespace orxonox
-{
-    ConsoleCommand::ConsoleCommand(Functor* functor, const std::string& name) : Executor(functor, name)
-    {
-        this->accessLevel_ = AccessLevel::None;
-        this->argumentCompleter_[0] = 0;
-        this->argumentCompleter_[1] = 0;
-        this->argumentCompleter_[2] = 0;
-        this->argumentCompleter_[3] = 0;
-        this->argumentCompleter_[4] = 0;
-
-        this->keybindMode_ = KeybindMode::OnPress;
-        this->inputConfiguredParam_ = -1;
-    }
-
-    ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer)
-    {
-        if (param < 5)
-            this->argumentCompleter_[param] = completer;
-        else
-        {
-            COUT(2) << "Warning: Couldn't add autocompletion-function for param " << param << ": index out of bound." << std::endl;
-        }
-        return (*this);
-    }
-
-    ArgumentCompleter* ConsoleCommand::getArgumentCompleter(unsigned int param) const
-    {
-        if (param < 5)
-            return this->argumentCompleter_[param];
-        else
-            return 0;
-    }
-
-    void ConsoleCommand::createArgumentCompletionList(unsigned int param, const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)
-    {
-        if (param < 5 && this->argumentCompleter_[param])
-            this->argumentList_ = (*this->argumentCompleter_[param])(param1, param2, param3, param4, param5);
-        else
-            this->argumentList_.clear();
-    }
-}
Index: code/trunk/src/libraries/core/ConsoleCommand.h
===================================================================
--- code/trunk/src/libraries/core/ConsoleCommand.h	(revision 7278)
+++ 	(revision )
@@ -1,157 +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:
- *      ...
- *
- */
-
-#ifndef _ConsoleCommand_H__
-#define _ConsoleCommand_H__
-
-#include "CorePrereqs.h"
-
-#include <boost/preprocessor/cat.hpp>
-
-#include "ArgumentCompletionFunctions.h"
-#include "CommandExecutor.h"
-#include "Executor.h"
-#include "Identifier.h"
-
-
-#define SetConsoleCommand(classname, function, bCreateShortcut) \
-    SetConsoleCommandGeneric(classname, function, #function, bCreateShortcut)
-#define SetConsoleCommandAlias(classname, function, name, bCreateShortcut) \
-    SetConsoleCommandGeneric(classname, function, name, bCreateShortcut)
-
-#define SetConsoleCommandGeneric(classname, function, name, bCreateShortcut) \
-    orxonox::ConsoleCommand& BOOST_PP_CAT(classname##function##consolecommand__, __LINE__) = orxonox::ClassIdentifier<classname>::getIdentifier(#classname)->addConsoleCommand(orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name), bCreateShortcut)
-
-
-#define SetConsoleCommandShortcut(classname, function) \
-    SetConsoleCommandShortcutAliasGeneric(classname, function, #function)
-#define SetConsoleCommandShortcutAlias(classname, function, name) \
-    SetConsoleCommandShortcutAliasGeneric(classname, function, name)
-#define SetConsoleCommandShortcutAliasGeneric(classname, function, name) \
-    SetConsoleCommandShortcutGeneric(BOOST_PP_CAT(function##consolecommand__, __LINE__), orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name))
-
-#define SetConsoleCommandShortcutExtern(function) \
-    SetConsoleCommandShortcutExternAliasGeneric(function, #function)
-#define SetConsoleCommandShortcutExternAlias(function, name) \
-    SetConsoleCommandShortcutExternAliasGeneric(function, name)
-#define SetConsoleCommandShortcutExternAliasGeneric(function, name) \
-    SetConsoleCommandShortcutGeneric(BOOST_PP_CAT(function##consolecommand__, __LINE__), orxonox::createConsoleCommand(orxonox::createFunctor(&function), name))
-
-#define SetConsoleCommandShortcutGeneric(fakevariable, command) \
-    orxonox::ConsoleCommand& fakevariable = orxonox::CommandExecutor::addConsoleCommandShortcut(command, true)
-
-
-namespace orxonox
-{
-    namespace AccessLevel
-    {
-        enum Value
-        {
-            None,
-            User,
-            Admin,
-            Offline,
-            Debug,
-            Disabled
-        };
-    }
-
-    class _CoreExport ConsoleCommand : public Executor
-    {
-        public:
-            ConsoleCommand(Functor* functor, const std::string& name = "");
-
-            inline ConsoleCommand& description(const std::string& description)
-                { this->Executor::setDescription(description); return (*this); }
-            inline ConsoleCommand& descriptionParam(int param, const std::string& description)
-                { this->Executor::setDescriptionParam(param, description); return (*this); }
-            inline ConsoleCommand& descriptionReturnvalue(const std::string& description)
-                { this->Executor::setDescriptionReturnvalue(description); return (*this); }
-            inline ConsoleCommand& defaultValues(const MultiType& param1)
-                { this->Executor::setDefaultValues(param1); return (*this); }
-            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2)
-                { this->Executor::setDefaultValues(param1, param2); return (*this); }
-            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
-                { this->Executor::setDefaultValues(param1, param2, param3); return (*this); }
-            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
-                { this->Executor::setDefaultValues(param1, param2, param3, param4); return (*this); }
-            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
-                { this->Executor::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
-            inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param)
-                { this->Executor::setDefaultValue(index, param); return (*this); }
-
-            inline ConsoleCommand& accessLevel(AccessLevel::Value level)
-                { this->accessLevel_ = level; return (*this); }
-            inline AccessLevel::Value getAccessLevel() const
-                { return this->accessLevel_; }
-
-            ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
-            ArgumentCompleter* getArgumentCompleter(unsigned int param) const;
-
-            void createArgumentCompletionList(unsigned int param, const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "");
-            const ArgumentCompletionList& getArgumentCompletionList() const
-                { return this->argumentList_; }
-            ArgumentCompletionList::const_iterator getArgumentCompletionListBegin() const
-                { return this->argumentList_.begin(); }
-            ArgumentCompletionList::const_iterator getArgumentCompletionListEnd() const
-                { return this->argumentList_.end(); }
-
-            inline ConsoleCommand& setAsInputCommand()
-            {
-                this->keybindMode(KeybindMode::OnHold);
-                this->defaultValue(0, Vector2(0.0f, 0.0f));
-                this->inputConfiguredParam(0);
-                return *this;
-            }
-
-            inline ConsoleCommand& keybindMode(KeybindMode::Value mode)
-                { this->keybindMode_ = mode; return *this; }
-            inline KeybindMode::Value getKeybindMode() const
-                { return this->keybindMode_; }
-
-            inline ConsoleCommand& inputConfiguredParam(int index)
-                { this->inputConfiguredParam_ = index; return *this; }
-            inline int getInputConfiguredParam_() const
-                { return this->inputConfiguredParam_; }
-
-        private:
-            AccessLevel::Value accessLevel_;
-            ArgumentCompleter* argumentCompleter_[5];
-            ArgumentCompletionList argumentList_;
-
-            KeybindMode::Value keybindMode_;
-            int inputConfiguredParam_;
-    };
-
-    inline ConsoleCommand* createConsoleCommand(Functor* functor, const std::string& name = "")
-    {
-        return new ConsoleCommand(functor, name);
-    }
-}
-
-#endif /* _ConsoleCommand_H__ */
Index: code/trunk/src/libraries/core/ConsoleCommandCompilation.cc
===================================================================
--- code/trunk/src/libraries/core/ConsoleCommandCompilation.cc	(revision 7278)
+++ 	(revision )
@@ -1,181 +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:
- *      ...
- *
- */
-
-#include "ConsoleCommandCompilation.h"
-
-#include <fstream>
-#include <set>
-#include <string>
-
-#include "util/Debug.h"
-#include "util/ExprParser.h"
-#include "util/StringUtils.h"
-#include "ConsoleCommand.h"
-
-namespace orxonox
-{
-    SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files());
-    SetConsoleCommandShortcutExtern(echo);
-    SetConsoleCommandShortcutExtern(puts);
-
-    SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files());
-    SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files());
-    SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files());
-
-    SetConsoleCommandShortcutExtern(calculate);
-
-    void source(const std::string& filename)
-    {
-        static std::set<std::string> executingFiles;
-
-        std::set<std::string>::const_iterator it = executingFiles.find(filename);
-        if (it != executingFiles.end())
-        {
-            COUT(1) << "Error: Recurring source command in \"" << filename << "\". Stopped execution." << std::endl;
-            return;
-        }
-
-        // Open the file
-        std::ifstream file;
-        file.open(filename.c_str(), std::fstream::in);
-
-        if (!file.is_open())
-        {
-            COUT(1) << "Error: Couldn't open file \"" << filename << "\"." << std::endl;
-            return;
-        }
-
-        executingFiles.insert(filename);
-
-        // Iterate through the file and put the lines into the CommandExecutor
-        while (file.good() && !file.eof())
-        {
-            std::string line;
-            std::getline(file, line);
-            CommandExecutor::execute(line);
-        }
-
-        executingFiles.erase(filename);
-        file.close();
-    }
-
-    std::string echo(const std::string& text)
-    {
-        return text;
-    }
-
-    void puts(bool newline, const std::string& text)
-    {
-        if (newline)
-        {
-            COUT(0) << stripEnclosingBraces(text) << std::endl;
-        }
-        else
-        {
-            COUT(0) << stripEnclosingBraces(text);
-        }
-    }
-
-    void write(const std::string& filename, const std::string& text)
-    {
-        std::ofstream file;
-        file.open(filename.c_str(), std::fstream::out);
-
-        if (!file.is_open())
-        {
-            COUT(1) << "Error: Couldn't write to file \"" << filename << "\"." << std::endl;
-            return;
-        }
-
-        file << text << std::endl;
-        file.close();
-    }
-
-    void append(const std::string& filename, const std::string& text)
-    {
-        std::ofstream file;
-        file.open(filename.c_str(), std::fstream::app);
-
-        if (!file.is_open())
-        {
-            COUT(1) << "Error: Couldn't append to file \"" << filename << "\"." << std::endl;
-            return;
-        }
-
-        file << text << std::endl;
-        file.close();
-    }
-
-    std::string read(const std::string& filename)
-    {
-        std::ifstream file;
-        file.open(filename.c_str(), std::fstream::in);
-
-        if (!file.is_open())
-        {
-            COUT(1) << "Error: Couldn't read from file \"" << filename << "\"." << std::endl;
-            return "";
-        }
-
-        std::string output;
-        while (file.good() && !file.eof())
-        {
-            std::string line;
-            std::getline(file, line);
-            output += line;
-            output += "\n";
-        }
-
-        file.close();
-
-        return output;
-    }
-
-    float calculate(const std::string& calculation)
-    {
-        ExprParser expr;
-        expr.parse(calculation);
-        if (expr.getSuccess())
-        {
-            if (expr.getResult() == 42.0)
-            {
-                COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;
-            }
-            if (!expr.getRemains().empty())
-            {
-                COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;
-            }
-            return static_cast<float>(expr.getResult());
-        }
-        else
-        {
-            COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;
-            return 0;
-        }
-    }
-}
Index: code/trunk/src/libraries/core/ConsoleCommandCompilation.h
===================================================================
--- code/trunk/src/libraries/core/ConsoleCommandCompilation.h	(revision 7278)
+++ 	(revision )
@@ -1,47 +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:
- *      ...
- *
- */
-
-#ifndef _ConsoleCommandCompilation_H__
-#define _ConsoleCommandCompilation_H__
-
-#include "CorePrereqs.h"
-
-namespace orxonox
-{
-    _CoreExport void source(const std::string& filename);
-    _CoreExport std::string echo(const std::string& text);
-    _CoreExport void puts(bool newline, const std::string& test);
-
-    _CoreExport void write(const std::string& filename, const std::string& text);
-    _CoreExport void append(const std::string& filename, const std::string& text);
-    _CoreExport std::string read(const std::string& filename);
-
-    _CoreExport float calculate(const std::string& calculation);
-}
-
-#endif /* _ConsoleCommandCompilation_H__ */
Index: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc	(revision 7278)
+++ code/trunk/src/libraries/core/Core.cc	(revision 7284)
@@ -52,7 +52,7 @@
 #include "util/Exception.h"
 #include "util/Scope.h"
+#include "util/ScopedSingletonManager.h"
 #include "util/SignalHandler.h"
 #include "PathConfig.h"
-#include "CommandExecutor.h"
 #include "CommandLineParser.h"
 #include "ConfigFileManager.h"
@@ -65,9 +65,9 @@
 #include "Identifier.h"
 #include "Language.h"
-#include "IOConsole.h"
 #include "LuaState.h"
-#include "ScopedSingletonManager.h"
-#include "TclBind.h"
-#include "TclThreadManager.h"
+#include "command/ConsoleCommand.h"
+#include "command/IOConsole.h"
+#include "command/TclBind.h"
+#include "command/TclThreadManager.h"
 #include "input/InputManager.h"
 
@@ -88,5 +88,5 @@
         : identifierDestroyer_(Identifier::destroyAllIdentifiers)
         // Cleanup guard for external console commands that don't belong to an Identifier
-        , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)
+        , consoleCommandDestroyer_(ConsoleCommand::destroyAll)
         , bGraphicsLoaded_(false)
         , bStartIOConsole_(true)
Index: code/trunk/src/libraries/core/CorePrereqs.h
===================================================================
--- code/trunk/src/libraries/core/CorePrereqs.h	(revision 7278)
+++ code/trunk/src/libraries/core/CorePrereqs.h	(revision 7284)
@@ -119,6 +119,4 @@
     T orxonox_cast(U*);
 
-    class ArgumentCompleter;
-    class ArgumentCompletionListElement;
     class BaseObject;
     template <class T>
@@ -130,5 +128,4 @@
     class ClassTreeMaskNode;
     class ClassTreeMaskObjectIterator;
-    class CommandEvaluation;
     class CommandLineParser;
     class CommandLineArgument;
@@ -140,5 +137,4 @@
     class ConfigFileSection;
     class ConfigValueContainer;
-    class ConsoleCommand;
     class Core;
     class DynLib;
@@ -146,13 +142,5 @@
     struct Event;
     class EventState;
-    class Executor;
-    template <class T>
-    class ExecutorMember;
-    class ExecutorStatic;
     class Factory;
-    class Functor;
-    template <class T>
-    class FunctorMember;
-    class FunctorStatic;
     class Game;
     class GameState;
@@ -162,9 +150,8 @@
     class GUIManager;
     class Identifier;
-    class IOConsole;
-    class IRC;
     template <class T>
     class Iterator;
     class Language;
+    class LuaFunctor;
     class LuaState;
     class MemoryArchive;
@@ -187,15 +174,8 @@
     struct ResourceInfo;
     class SettingsConfigFile;
-    class Shell;
-    class ShellListener;
     template <class T>
     class SmartPtr;
     template <class T>
     class SubclassIdentifier;
-    class TclBind;
-    struct TclInterpreterBundle;
-    template <class T>
-    class TclThreadList;
-    class TclThreadManager;
     class Template;
     class Thread;
@@ -212,4 +192,29 @@
     class XMLPortObjectContainer;
     class XMLPortParamContainer;
+
+    // Command
+    class ArgumentCompleter;
+    class ArgumentCompletionListElement;
+    class CommandEvaluation;
+    class ConsoleCommand;
+    class Executor;
+    template <class T>
+    class ExecutorMember;
+    class ExecutorStatic;
+    class Functor;
+    template <class O>
+    class FunctorMember;
+    typedef FunctorMember<void> FunctorStatic;
+    template <class F, class O>
+    class FunctorPointer;
+    class IOConsole;
+    class IRC;
+    class Shell;
+    class ShellListener;
+    class TclBind;
+    struct TclInterpreterBundle;
+    template <class T>
+    class TclThreadList;
+    class TclThreadManager;
 
     // Input
@@ -238,4 +243,7 @@
 }
 
+#include "command/FunctorPtr.h"
+#include "command/ExecutorPtr.h"
+
 // CppTcl
 namespace Tcl
Index: code/trunk/src/libraries/core/Event.cc
===================================================================
--- code/trunk/src/libraries/core/Event.cc	(revision 7278)
+++ code/trunk/src/libraries/core/Event.cc	(revision 7284)
@@ -34,13 +34,4 @@
 namespace orxonox
 {
-    /**
-        @brief Destructor: Deletes the functor of the event state.
-    */
-    EventState::~EventState()
-    {
-        if (this->statefunction_)
-            delete this->statefunction_;
-    }
-
     /**
         @brief Processes an event (calls the set-function if the necessary conditions are met).
Index: code/trunk/src/libraries/core/Event.h
===================================================================
--- code/trunk/src/libraries/core/Event.h	(revision 7278)
+++ code/trunk/src/libraries/core/Event.h	(revision 7284)
@@ -67,10 +67,9 @@
     {
         public:
-            EventState(Functor* statefunction, Identifier* subclass, bool bSink = false) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass), bSink_(bSink) {}
-            virtual ~EventState();
+            EventState(const FunctorPtr& statefunction, Identifier* subclass, bool bSink = false) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass), bSink_(bSink) {}
 
             void process(const Event& event, BaseObject* object);
 
-            Functor* getFunctor() const
+            const FunctorPtr& getFunctor() const
                 { return this->statefunction_; }
 
@@ -78,5 +77,5 @@
             bool        bProcessingEvent_;  //!< This becomes true while the container processes an event (used to prevent loops)
             int         activeEvents_;      //!< The number of events which affect this state and are currently active
-            Functor*    statefunction_;     //!< A functor to set the state
+            FunctorPtr  statefunction_;     //!< A functor to set the state
             Identifier* subclass_;          //!< Originators must be an instance of this class (usually BaseObject, but some statefunctions allow a second argument with an originator of a specific class)
             bool        bSink_;             //!< Determines whether the EventState acts as an EventSink forwarding any Event (even if the state didn't change) or in the normal manner, only processing Events that change the state.
Index: code/trunk/src/libraries/core/EventIncludes.h
===================================================================
--- code/trunk/src/libraries/core/EventIncludes.h	(revision 7278)
+++ code/trunk/src/libraries/core/EventIncludes.h	(revision 7284)
@@ -31,6 +31,6 @@
 
 #include "CorePrereqs.h"
-#include "Executor.h"
 #include "XMLPort.h"
+#include "command/Executor.h"
 
 /**
@@ -76,6 +76,8 @@
 
 #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::ExecutorMemberPtr<classname> xmlsetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \
+    static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \
+    xmlsetfunctor##name->setDefaultValue(1, statename); \
+    xmlgetfunctor##name->setDefaultValue(1, statename); \
     XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
 
Index: code/trunk/src/libraries/core/Executor.cc
===================================================================
--- code/trunk/src/libraries/core/Executor.cc	(revision 7278)
+++ 	(revision )
@@ -1,338 +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:
- *      ...
- *
- *   Inspiration: Executor by Benjamin Grauer
- */
-
-#include "Executor.h"
-
-#include <algorithm>
-
-#include "util/Convert.h"
-#include "util/Debug.h"
-#include "util/StringUtils.h"
-#include "util/SubString.h"
-#include "Language.h"
-
-namespace orxonox
-{
-    Executor::Executor(Functor* functor, const std::string& name)
-    {
-        this->functor_ = functor;
-        this->name_ = name;
-
-        this->bAddedDescription_ = false;
-        this->bAddedDescriptionReturnvalue_ = false;
-
-        this->bAddedDescriptionParam_[0] = false;
-        this->bAddedDescriptionParam_[1] = false;
-        this->bAddedDescriptionParam_[2] = false;
-        this->bAddedDescriptionParam_[3] = false;
-        this->bAddedDescriptionParam_[4] = false;
-
-        this->bAddedDefaultValue_[0] = false;
-        this->bAddedDefaultValue_[1] = false;
-        this->bAddedDefaultValue_[2] = false;
-        this->bAddedDefaultValue_[3] = false;
-        this->bAddedDefaultValue_[4] = false;
-    }
-
-    Executor::~Executor()
-    {
-        delete this->functor_;
-    }
-
-    bool Executor::parse(const std::string& params, const std::string& delimiter) const
-    {
-        unsigned int paramCount = this->functor_->getParamCount();
-       
-        if (paramCount == 0)
-        {
-            COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl;
-            (*this->functor_)();
-        }
-        else if (paramCount == 1)
-        {
-            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;
-                (*this->functor_)(MultiType(params));
-            }
-            else if (this->bAddedDefaultValue_[0])
-            {
-                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
-                (*this->functor_)(this->defaultValue_[0]);
-            }
-            else
-            {
-                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl;
-                return false;
-            }
-        }
-        else
-        {
-            SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
-           
-            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
-            {
-                if (!this->bAddedDefaultValue_[i])
-                {
-                    COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl;
-                    return false;
-                }
-            }
-           
-            MultiType param[MAX_FUNCTOR_ARGUMENTS];
-            COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens (";
-            for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++)
-            {
-                param[i] = tokens[i];
-                if (i != 0)
-                {
-                    COUT(5) << ", ";
-                }
-                COUT(5) << tokens[i];
-            }
-            COUT(5) << ") and " << std::max((int)paramCount - (int)tokens.size(), 0) << " default values (";
-            for (unsigned int i = tokens.size(); i < paramCount; i++)
-            {
-                param[i] = this->defaultValue_[i];
-                if (i != 0)
-                {
-                    COUT(5) << ", ";
-                }
-                COUT(5) << this->defaultValue_[i];
-            }
-            COUT(5) << ")." << std::endl;
-           
-            if ((tokens.size() > paramCount) && (this->functor_->getTypenameParam(paramCount - 1) == "string"))
-                param[paramCount - 1] = tokens.subSet(paramCount - 1).join();
-           
-            switch(paramCount)
-            {
-                case 2:
-                    (*this->functor_)(param[0], param[1]);
-                    break;
-                case 3:
-                    (*this->functor_)(param[0], param[1], param[2]);
-                    break;
-                case 4:
-                    (*this->functor_)(param[0], param[1], param[2], param[3]);
-                    break;
-                case 5:
-                    (*this->functor_)(param[0], param[1], param[2], param[3], param[4]);
-                    break;
-            }
-        }
-
-        return true;
-    }
-
-    bool Executor::evaluate(const std::string& params, MultiType param[5], const std::string& delimiter) const
-    {
-        unsigned int paramCount = this->functor_->getParamCount();
-
-        if (paramCount == 1)
-        {
-            // only one param: check if there are params given, otherwise try to use default values
-            if (!getStripped(params).empty())
-            {
-                param[0] = params;
-                this->functor_->evaluateParam(0, param[0]);
-                return true;
-            }
-            else if (this->bAddedDefaultValue_[0])
-            {
-                param[0] = this->defaultValue_[0];
-                this->functor_->evaluateParam(0, param[0]);
-                return true;
-            }
-            return false;
-        }
-        else
-        {
-            // more than one param
-            SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
-
-            // if there are not enough params given, check if there are default values
-            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
-                if (!this->bAddedDefaultValue_[i])
-                    return false;
-
-            // assign all given arguments to the multitypes
-            for (unsigned int i = 0; i < std::min(tokens.size(), MAX_FUNCTOR_ARGUMENTS); i++)
-                param[i] = tokens[i];
-
-            // fill the remaining multitypes with default values
-            for (unsigned int i = tokens.size(); i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++)
-                param[i] = this->defaultValue_[i];
-
-            // evaluate the param types through the functor
-            for (unsigned int i = 0; i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++)
-                this->functor_->evaluateParam(i, param[i]);
-
-            return true;
-        }
-    }
-
-    Executor& Executor::setDescription(const std::string& description)
-    {
-        if (!this->bAddedDescription_)
-        {
-            this->description_ = std::string("ExecutorDescription::" + this->name_ + "::function");
-            AddLanguageEntry(this->description_, description);
-            this->bAddedDescription_ = true;
-        }
-        return (*this);
-    }
-
-    const std::string& Executor::getDescription() const
-    {
-        return GetLocalisation(this->description_);
-    }
-
-    Executor& Executor::setDescriptionParam(unsigned int param, const std::string& description)
-    {
-        if (param < MAX_FUNCTOR_ARGUMENTS)
-        {
-            if (!this->bAddedDescriptionParam_[param])
-            {
-                std::string paramnumber;
-                if (!convertValue(&paramnumber, param))
-                    return (*this);
-
-                this->descriptionParam_[param] = std::string("ExecutorDescription::" + this->name_ + "::param" + paramnumber);
-                AddLanguageEntry(this->descriptionParam_[param], description);
-                this->bAddedDescriptionParam_[param] = true;
-            }
-        }
-        return (*this);
-    }
-
-    const std::string& Executor::getDescriptionParam(unsigned int param) const
-    {
-        if (param < MAX_FUNCTOR_ARGUMENTS)
-            return GetLocalisation(this->descriptionParam_[param]);
-
-        return this->descriptionParam_[0];
-    }
-
-    Executor& Executor::setDescriptionReturnvalue(const std::string& description)
-    {
-        if (!this->bAddedDescriptionReturnvalue_)
-        {
-            this->descriptionReturnvalue_ = std::string("ExecutorDescription::" + this->name_ + "::returnvalue");
-            AddLanguageEntry(this->descriptionReturnvalue_, description);
-            this->bAddedDescriptionReturnvalue_ = true;
-        }
-        return (*this);
-    }
-
-    const std::string& Executor::getDescriptionReturnvalue(int param) const
-    {
-        return GetLocalisation(this->descriptionReturnvalue_);
-    }
-
-    Executor& Executor::setDefaultValues(const MultiType& param1)
-    {
-        this->defaultValue_[0] = param1;
-        this->bAddedDefaultValue_[0] = true;
-
-        return (*this);
-    }
-
-    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
-    {
-        this->defaultValue_[0] = param1;
-        this->bAddedDefaultValue_[0] = true;
-        this->defaultValue_[1] = param2;
-        this->bAddedDefaultValue_[1] = true;
-
-        return (*this);
-    }
-
-    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
-    {
-        this->defaultValue_[0] = param1;
-        this->bAddedDefaultValue_[0] = true;
-        this->defaultValue_[1] = param2;
-        this->bAddedDefaultValue_[1] = true;
-        this->defaultValue_[2] = param3;
-        this->bAddedDefaultValue_[2] = true;
-
-        return (*this);
-    }
-
-    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
-    {
-        this->defaultValue_[0] = param1;
-        this->bAddedDefaultValue_[0] = true;
-        this->defaultValue_[1] = param2;
-        this->bAddedDefaultValue_[1] = true;
-        this->defaultValue_[2] = param3;
-        this->bAddedDefaultValue_[2] = true;
-        this->defaultValue_[3] = param4;
-        this->bAddedDefaultValue_[3] = true;
-
-        return (*this);
-    }
-
-    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
-    {
-        this->defaultValue_[0] = param1;
-        this->bAddedDefaultValue_[0] = true;
-        this->defaultValue_[1] = param2;
-        this->bAddedDefaultValue_[1] = true;
-        this->defaultValue_[2] = param3;
-        this->bAddedDefaultValue_[2] = true;
-        this->defaultValue_[3] = param4;
-        this->bAddedDefaultValue_[3] = true;
-        this->defaultValue_[4] = param5;
-        this->bAddedDefaultValue_[4] = true;
-
-        return (*this);
-    }
-
-    Executor& Executor::setDefaultValue(unsigned int index, const MultiType& param)
-    {
-        if (index < MAX_FUNCTOR_ARGUMENTS)
-        {
-            this->defaultValue_[index] = param;
-            this->bAddedDefaultValue_[index] = true;
-        }
-        return (*this);
-    }
-
-    bool Executor::allDefaultValuesSet() const
-    {
-        for (unsigned int i = 0; i < this->functor_->getParamCount(); i++)
-            if (!this->bAddedDefaultValue_[i])
-                return false;
-
-        return true;
-    }
-}
Index: code/trunk/src/libraries/core/Executor.h
===================================================================
--- code/trunk/src/libraries/core/Executor.h	(revision 7278)
+++ 	(revision )
@@ -1,227 +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:
- *      ...
- *
- *   Inspiration: Executor by Benjamin Grauer
- */
-
-#ifndef _Executor_H__
-#define _Executor_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-#include "util/MultiType.h"
-#include "Functor.h"
-
-namespace orxonox
-{
-    class _CoreExport Executor
-    {
-        public:
-            Executor(Functor* functor, const std::string& name = "");
-            virtual ~Executor();
-
-            inline void operator()() const
-                { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const MultiType& param1) const
-                { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const MultiType& param1, const MultiType& param2) const
-                { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
-                { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
-                { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
-            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
-                { (*this->functor_)(param1, param2, param3, param4, param5); }
-
-            bool parse(const std::string& params, const std::string& delimiter = " ") const;
-
-            bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
-
-            Executor& setDescription(const std::string& description);
-            const std::string& getDescription() const;
-
-            Executor& setDescriptionParam(unsigned int param, const std::string& description);
-            const std::string& getDescriptionParam(unsigned int param) const;
-
-            Executor& setDescriptionReturnvalue(const std::string& description);
-            const std::string& getDescriptionReturnvalue(int param) const;
-
-            inline Functor* getFunctor() const
-                { return this->functor_; }
-            inline unsigned int getParamCount() const
-                { return this->functor_->getParamCount(); }
-            inline bool hasReturnvalue() const
-                { return this->functor_->hasReturnvalue(); }
-            inline FunctionType::Value getType() const
-                { return this->functor_->getType(); }
-            inline const MultiType& getReturnvalue() const
-                { return this->functor_->getReturnvalue(); }
-            inline const std::string& getTypenameParam(unsigned int param) const
-                { return this->functor_->getTypenameParam(param); }
-            inline const std::string& getTypenameReturnvalue() const
-                { return this->functor_->getTypenameReturnvalue(); }
-
-            inline void setName(const std::string& name)
-                { this->name_ = name; }
-            inline const std::string& getName() const
-                { return this->name_; }
-
-            Executor& setDefaultValues(const MultiType& param1);
-            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2);
-            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
-            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
-            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
-            Executor& setDefaultValue(unsigned int index, const MultiType& param);
-
-            inline MultiType getDefaultValue(unsigned int index) const
-            {
-                if (index < MAX_FUNCTOR_ARGUMENTS)
-                    return this->defaultValue_[index];
-
-                return MT_Type::Null;
-            }
-
-            bool allDefaultValuesSet() const;
-            inline bool defaultValueSet(unsigned int index) const
-            {
-                if (index < MAX_FUNCTOR_ARGUMENTS)
-                    return this->bAddedDefaultValue_[index];
-
-                return false;
-            }
-
-        protected:
-            Functor* functor_;
-            std::string name_;
-            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
-            bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
-
-        private:
-            LanguageEntryLabel description_;
-            LanguageEntryLabel descriptionReturnvalue_;
-            LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS];
-
-            bool bAddedDescription_;
-            bool bAddedDescriptionReturnvalue_;
-            bool bAddedDescriptionParam_[MAX_FUNCTOR_ARGUMENTS];
-    };
-
-    class _CoreExport ExecutorStatic : public Executor
-    {
-        public:
-            ExecutorStatic(FunctorStatic* functor, const std::string& name = "") : Executor(functor, name) {}
-            virtual ~ExecutorStatic() {}
-    };
-
-    template <class T>
-    class ExecutorMember : public Executor
-    {
-        public:
-            ExecutorMember(FunctorMember<T>* functor, const std::string& name = "") : Executor(functor, name) {}
-            virtual ~ExecutorMember() {}
-
-            using Executor::operator();
-
-            inline void operator()(T* object) const
-                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(T* object, const MultiType& param1) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(T* object, const MultiType& param1, const MultiType& param2) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
-            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
-
-
-            inline void operator()(const T* object) const
-                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const T* object, const MultiType& param1) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
-            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
-            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
-                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
-
-            inline void setObject(T* object) const
-                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
-            inline void setObject(const T* object) const
-                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
-
-            using Executor::parse;
-
-            bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const
-            {
-                FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_);
-
-                const typename FunctorMember<T>::Objects& objects = functorMember->getObjects();
-
-                functorMember->setObject(object);
-                bool result = Executor::parse(params, delimiter);
-                functorMember->setObjects(objects);
-
-                return result;
-            }
-
-            bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const
-            {
-                FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_);
-
-                const typename FunctorMember<T>::Objects& objects = functorMember->getObjects();
-
-                functorMember->setObject(object);
-                bool result = Executor::parse(params, delimiter);
-                functorMember->setObjects(objects);
-
-                return result;
-            }
-    };
-
-    inline Executor* createExecutor(Functor* functor, const std::string& name = "")
-    {
-        return new Executor(functor, name);
-    }
-
-    template <class T>
-    inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "")
-    {
-        return new ExecutorMember<T>(functor, name);
-    }
-
-    inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "")
-    {
-        return new ExecutorStatic(functor, name);
-    }
-}
-
-#endif /* _Executor_H__ */
Index: code/trunk/src/libraries/core/Functor.h
===================================================================
--- code/trunk/src/libraries/core/Functor.h	(revision 7278)
+++ 	(revision )
@@ -1,505 +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:
- *      ...
- *
- *   Inspiration: Functor by Benjamin Grauer
- */
-
-#ifndef _Functor_H__
-#define _Functor_H__
-
-#include "CorePrereqs.h"
-
-#include "util/Debug.h"
-#include "util/MultiType.h"
-
-namespace orxonox
-{
-    const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
-
-    namespace FunctionType
-    {
-        enum Value
-        {
-            Member,
-            ConstMember,
-            Static
-        };
-    }
-
-
-    template <class T>
-    inline std::string typeToString() { return "unknown"; }
-
-#define CreateTypeToStringTemplate(type) \
-    template <> \
-    inline std::string typeToString<type>() { return #type; } \
-    template <> \
-    inline std::string typeToString<type&>() { return #type; } \
-    template <> \
-    inline std::string typeToString<const type>() { return #type; } \
-    template <> \
-    inline std::string typeToString<const type&>() { return #type; }
-
-    CreateTypeToStringTemplate(int);
-    CreateTypeToStringTemplate(unsigned int);
-    CreateTypeToStringTemplate(char);
-    CreateTypeToStringTemplate(unsigned char);
-    CreateTypeToStringTemplate(short);
-    CreateTypeToStringTemplate(unsigned short);
-    CreateTypeToStringTemplate(long);
-    CreateTypeToStringTemplate(unsigned long);
-    CreateTypeToStringTemplate(long long);
-    CreateTypeToStringTemplate(unsigned long long);
-    CreateTypeToStringTemplate(float);
-    CreateTypeToStringTemplate(double);
-    CreateTypeToStringTemplate(long double);
-    CreateTypeToStringTemplate(bool);
-    CreateTypeToStringTemplate(Vector2);
-    CreateTypeToStringTemplate(Vector3);
-    CreateTypeToStringTemplate(Quaternion);
-    CreateTypeToStringTemplate(ColourValue);
-    CreateTypeToStringTemplate(Radian);
-    CreateTypeToStringTemplate(Degree);
-
-    template <>
-    inline std::string typeToString<std::string>() { return "string"; }
-    template <>
-    inline std::string typeToString<std::string&>() { return "string"; }
-    template <>
-    inline std::string typeToString<const std::string>() { return "string"; }
-    template <>
-    inline std::string typeToString<const std::string&>() { return "string"; }
-
-    class _CoreExport Functor
-    {
-        public:
-            Functor() {}
-            virtual ~Functor() {}
-
-            virtual 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) = 0;
-
-            inline unsigned int getParamCount() const { return this->numParams_; }
-            inline bool hasReturnvalue() const { return this->hasReturnValue_; }
-            inline FunctionType::Value getType() const { return this->type_; }
-            inline const MultiType& getReturnvalue() const { return this->returnedValue_; }
-
-            const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : BLANKSTRING; }
-            const std::string& getTypenameReturnvalue() const { return this->typeReturnvalue_; }
-
-            virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
-
-        protected:
-            unsigned int numParams_;
-            bool hasReturnValue_;
-            FunctionType::Value type_;
-            MultiType returnedValue_;
-
-            std::string typeReturnvalue_;
-            std::string typeParam_[MAX_FUNCTOR_ARGUMENTS];
-    };
-
-    class _CoreExport FunctorStatic : public Functor
-    {
-        public:
-            virtual ~FunctorStatic() {}
-            virtual 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) = 0;
-    };
-
-    template <class T>
-    class FunctorMember : public Functor
-    {
-        public:
-            FunctorMember()
-            {
-                this->object_ = 0;
-                this->constObject_ = 0;
-            }
-            virtual ~FunctorMember() {}
-
-            virtual void operator()(T* object, 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) = 0;
-            virtual void operator()(const T* object, 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) = 0;
-
-            virtual 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)
-            {
-                if (this->object_)
-                    (*this)(this->object_, param1, param2, param3, param4, param5);
-                else if (this->constObject_)
-                    (*this)(this->constObject_, param1, param2, param3, param4, param5);
-                else
-                {
-                    COUT(1) << "An error occurred in Functor.h:" << std::endl;
-                    COUT(1) << "Error: No object set." << std::endl;
-                }
-            }
-
-            inline FunctorMember<T>* setObject(T* object)
-            {
-                this->object_ = object;
-                this->constObject_ = 0;
-                return this;
-            }
-
-            inline FunctorMember<T>* setObject(const T* object)
-            {
-                this->object_ = 0;
-                this->constObject_ = object;
-                return this;
-            }
-
-            typedef std::pair<T*, const T*> Objects;
-
-            inline Objects getObjects() const
-            {
-                return Objects(this->object_, this->constObject_);
-            }
-
-            inline void setObjects(const Objects& objects)
-            {
-                this->object_ = objects.first;
-                this->constObject_ = objects.second;
-            }
-
-        private:
-            T* object_;
-            const T* constObject_;
-    };
-
-
-
-#define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams, additionalobject) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams(additionalobject)
-#define FUNCTOR_TEMPLATE000(additionalobject)
-#define FUNCTOR_TEMPLATE001(additionalobject) template <class P1>
-#define FUNCTOR_TEMPLATE002(additionalobject) template <class P1, class P2>
-#define FUNCTOR_TEMPLATE003(additionalobject) template <class P1, class P2, class P3>
-#define FUNCTOR_TEMPLATE004(additionalobject) template <class P1, class P2, class P3, class P4>
-#define FUNCTOR_TEMPLATE005(additionalobject) template <class P1, class P2, class P3, class P4, class P5>
-#define FUNCTOR_TEMPLATE010(additionalobject) template <class R>
-#define FUNCTOR_TEMPLATE011(additionalobject) template <class R, class P1>
-#define FUNCTOR_TEMPLATE012(additionalobject) template <class R, class P1, class P2>
-#define FUNCTOR_TEMPLATE013(additionalobject) template <class R, class P1, class P2, class P3>
-#define FUNCTOR_TEMPLATE014(additionalobject) template <class R, class P1, class P2, class P3, class P4>
-#define FUNCTOR_TEMPLATE015(additionalobject) template <class R, class P1, class P2, class P3, class P4, class P5>
-#define FUNCTOR_TEMPLATE100(additionalobject) template <class T FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE101(additionalobject) template <class T, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE102(additionalobject) template <class T, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE103(additionalobject) template <class T, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE104(additionalobject) template <class T, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE105(additionalobject) template <class T, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE110(additionalobject) template <class T, class R FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE111(additionalobject) template <class T, class R, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE112(additionalobject) template <class T, class R, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE113(additionalobject) template <class T, class R, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE114(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE115(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-
-
-
-#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT##additionalobject
-#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT0
-#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT1 , class O
-
-
-
-#define FUNCTOR_TEMPLATE_CLASSES(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE_CLASSES##ismember##returnvalue##numparams
-#define FUNCTOR_TEMPLATE_CLASSES000
-#define FUNCTOR_TEMPLATE_CLASSES001 <P1>
-#define FUNCTOR_TEMPLATE_CLASSES002 <P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES003 <P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES004 <P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES005 <P1, P2, P3, P4, P5>
-#define FUNCTOR_TEMPLATE_CLASSES010 <R>
-#define FUNCTOR_TEMPLATE_CLASSES011 <R, P1>
-#define FUNCTOR_TEMPLATE_CLASSES012 <R, P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES013 <R, P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES014 <R, P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES015 <R, P1, P2, P3, P4, P5>
-#define FUNCTOR_TEMPLATE_CLASSES100 <T>
-#define FUNCTOR_TEMPLATE_CLASSES101 <T, P1>
-#define FUNCTOR_TEMPLATE_CLASSES102 <T, P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES103 <T, P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES104 <T, P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES105 <T, P1, P2, P3, P4, P5>
-#define FUNCTOR_TEMPLATE_CLASSES110 <T, R>
-#define FUNCTOR_TEMPLATE_CLASSES111 <T, R, P1>
-#define FUNCTOR_TEMPLATE_CLASSES112 <T, R, P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES113 <T, R, P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES114 <T, R, P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES115 <T, R, P1, P2, P3, P4, P5>
-
-
-
-#define FUNCTOR_TYPENAME_PARAMS(numparams) FUNCTOR_TYPENAME_PARAMS##numparams
-#define FUNCTOR_TYPENAME_PARAMS0
-#define FUNCTOR_TYPENAME_PARAMS1 this->typeParam_[0] = typeToString<P1>();
-#define FUNCTOR_TYPENAME_PARAMS2 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>();
-#define FUNCTOR_TYPENAME_PARAMS3 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>();
-#define FUNCTOR_TYPENAME_PARAMS4 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>();
-#define FUNCTOR_TYPENAME_PARAMS5 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>(); this->typeParam_[4] = typeToString<P5>();
-
-#define FUNCTOR_TYPENAME_RETURN(returnvalue) FUNCTOR_TYPENAME_RETURN##returnvalue
-#define FUNCTOR_TYPENAME_RETURN0
-#define FUNCTOR_TYPENAME_RETURN1 this->typeReturnvalue_ = typeToString<R>();
-
-
-
-#define FUNCTOR_FUNCTION_PARAMS(numparams) FUNCTOR_FUNCTION_PARAMS##numparams
-#define FUNCTOR_FUNCTION_PARAMS0
-#define FUNCTOR_FUNCTION_PARAMS1 P1 param1
-#define FUNCTOR_FUNCTION_PARAMS2 P1 param1, P2 param2
-#define FUNCTOR_FUNCTION_PARAMS3 P1 param1, P2 param2, P3 param3
-#define FUNCTOR_FUNCTION_PARAMS4 P1 param1, P2 param2, P3 param3, P4 param4
-#define FUNCTOR_FUNCTION_PARAMS5 P1 param1, P2 param2, P3 param3, P4 param4, P5 param5
-
-#define FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) FUNCTOR_FUNCTION_RETURNVALUE##returnvalue
-#define FUNCTOR_FUNCTION_RETURNVALUE0 void
-#define FUNCTOR_FUNCTION_RETURNVALUE1 R
-
-
-
-#define FUNCTOR_FUNCTION_CALL(numparams) FUNCTOR_FUNCTION_CALL##numparams
-#define FUNCTOR_FUNCTION_CALL0
-#define FUNCTOR_FUNCTION_CALL1 param1
-#define FUNCTOR_FUNCTION_CALL2 param1, param2
-#define FUNCTOR_FUNCTION_CALL3 param1, param2, param3
-#define FUNCTOR_FUNCTION_CALL4 param1, param2, param3, param4
-#define FUNCTOR_FUNCTION_CALL5 param1, param2, param3, param4, param5
-
-#define FUNCTOR_STORE_RETURNVALUE(returnvalue, functioncall) FUNCTOR_STORE_RETURNVALUE##returnvalue(functioncall)
-#define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall
-#define FUNCTOR_STORE_RETURNVALUE1(functioncall) this->returnedValue_ = functioncall
-
-
-
-#define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams
-#define FUNCTOR_EVALUATE_PARAM0
-#define FUNCTOR_EVALUATE_PARAM1 \
-    if (index == 0) { param.convert<P1>(); }
-#define FUNCTOR_EVALUATE_PARAM2 \
-    if (index == 0) { param.convert<P1>(); } \
-    else if (index == 1) { param.convert<P2>(); }
-#define FUNCTOR_EVALUATE_PARAM3 \
-    if (index == 0) { param.convert<P1>(); } \
-    else if (index == 1) { param.convert<P2>(); } \
-    else if (index == 2) { param.convert<P3>(); }
-#define FUNCTOR_EVALUATE_PARAM4 \
-    if (index == 0) { param.convert<P1>(); } \
-    else if (index == 1) { param.convert<P2>(); } \
-    else if (index == 2) { param.convert<P3>(); } \
-    else if (index == 3) { param.convert<P4>(); }
-#define FUNCTOR_EVALUATE_PARAM5 \
-    if (index == 0) { param.convert<P1>(); } \
-    else if (index == 1) { param.convert<P2>(); } \
-    else if (index == 2) { param.convert<P3>(); } \
-    else if (index == 3) { param.convert<P4>(); } \
-    else if (index == 4) { param.convert<P5>(); }
-
-
-
-
-
-#define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \
-    FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
-    class FunctorStatic##returnvalue##numparams : public FunctorStatic \
-    { \
-        public: \
-            FunctorStatic##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
-            { \
-                this->numParams_ = numparams; \
-                this->hasReturnValue_ = returnvalue; \
-                this->type_ = FunctionType::Static; \
-                this->functionPointer_ = functionPointer; \
-                \
-                FUNCTOR_TYPENAME_PARAMS(numparams); \
-                FUNCTOR_TYPENAME_RETURN(returnvalue); \
-            } \
-    \
-            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) \
-            { \
-                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
-            } \
-    \
-            virtual void evaluateParam(unsigned int index, MultiType& param) const \
-            { \
-                FUNCTOR_EVALUATE_PARAM(numparams); \
-            } \
-    \
-        private: \
-            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
-    }; \
-    \
-    \
-    FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
-    inline FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
-    { \
-        return new FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams) (functionPointer); \
-    }
-
-
-
-
-
-#define CREATE_MEMBER_FUNCTOR(returnvalue, numparams) \
-    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
-    class FunctorMember##returnvalue##numparams : public FunctorMember<T> \
-    { \
-        public: \
-            FunctorMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
-            { \
-                this->numParams_ = numparams; \
-                this->hasReturnValue_ = returnvalue; \
-                this->type_ = FunctionType::Member; \
-                this->functionPointer_ = functionPointer; \
-            } \
-    \
-            void operator()(T* object, 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) \
-            { \
-                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
-            } \
-    \
-            void operator()(const T* object, 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) \
-            { \
-                COUT(1) << "An error occurred in Functor.h:" << std::endl; \
-                COUT(1) << "Error: Function is not const." << std::endl; \
-            } \
-    \
-            virtual void evaluateParam(unsigned int index, MultiType& param) const \
-            { \
-                FUNCTOR_EVALUATE_PARAM(numparams); \
-            } \
-    \
-        private: \
-            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
-    }; \
-    \
-    \
-    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
-    class FunctorConstMember##returnvalue##numparams : public FunctorMember<T> \
-    { \
-        public: \
-            FunctorConstMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
-            { \
-                this->numParams_ = numparams; \
-                this->hasReturnValue_ = returnvalue; \
-                this->type_ = FunctionType::ConstMember; \
-                this->functionPointer_ = functionPointer; \
-            } \
-    \
-            void operator()(T* object, 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) \
-            { \
-                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
-            } \
-    \
-            void operator()(const T* object, 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) \
-            { \
-                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
-            } \
-    \
-            virtual void evaluateParam(unsigned int index, MultiType& param) const \
-            { \
-                FUNCTOR_EVALUATE_PARAM(numparams); \
-            } \
-    \
-        private: \
-            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)) const; \
-    }; \
-    \
-    \
-    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
-    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
-    { \
-        return new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
-    } \
-    \
-    \
-    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
-    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
-    { \
-        return new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
-    } \
-    \
-    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
-    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)), O* object) \
-    { \
-        FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
-        functor->setObject(object); \
-        return functor; \
-    } \
-    \
-    \
-    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
-    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const, O* object) \
-    { \
-        FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
-        functor->setObject(object); \
-        return functor; \
-    }
-
-
-// disable annoying warning about forcing value to boolean
-#ifdef ORXONOX_COMPILER_MSVC
-#pragma warning(push)
-#pragma warning(disable:4100 4800)
-#endif
-
-#define CREATE_ALL_STATIC_FUNCTORS() \
-    CREATE_STATIC_FUNCTOR(0, 0); \
-    CREATE_STATIC_FUNCTOR(0, 1); \
-    CREATE_STATIC_FUNCTOR(0, 2); \
-    CREATE_STATIC_FUNCTOR(0, 3); \
-    CREATE_STATIC_FUNCTOR(0, 4); \
-    CREATE_STATIC_FUNCTOR(0, 5); \
-    CREATE_STATIC_FUNCTOR(1, 0); \
-    CREATE_STATIC_FUNCTOR(1, 1); \
-    CREATE_STATIC_FUNCTOR(1, 2); \
-    CREATE_STATIC_FUNCTOR(1, 3); \
-    CREATE_STATIC_FUNCTOR(1, 4); \
-    CREATE_STATIC_FUNCTOR(1, 5)
-
-
-#define CREATE_ALL_MEMBER_FUNCTORS() \
-    CREATE_MEMBER_FUNCTOR(0, 0); \
-    CREATE_MEMBER_FUNCTOR(0, 1); \
-    CREATE_MEMBER_FUNCTOR(0, 2); \
-    CREATE_MEMBER_FUNCTOR(0, 3); \
-    CREATE_MEMBER_FUNCTOR(0, 4); \
-    CREATE_MEMBER_FUNCTOR(0, 5); \
-    CREATE_MEMBER_FUNCTOR(1, 0); \
-    CREATE_MEMBER_FUNCTOR(1, 1); \
-    CREATE_MEMBER_FUNCTOR(1, 2); \
-    CREATE_MEMBER_FUNCTOR(1, 3); \
-    CREATE_MEMBER_FUNCTOR(1, 4); \
-    CREATE_MEMBER_FUNCTOR(1, 5)
-
-
-    CREATE_ALL_STATIC_FUNCTORS();
-    CREATE_ALL_MEMBER_FUNCTORS();
-}
-
-#ifdef ORXONOX_COMPILER_MSVC
-#pragma warning(pop)
-#endif
-
-#endif /* _Functor_H__ */
Index: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc	(revision 7278)
+++ code/trunk/src/libraries/core/GUIManager.cc	(revision 7284)
@@ -57,5 +57,4 @@
 #include "util/Exception.h"
 #include "util/OrxAssert.h"
-#include "ConsoleCommand.h"
 #include "Core.h"
 #include "GraphicsManager.h"
@@ -63,4 +62,5 @@
 #include "PathConfig.h"
 #include "Resource.h"
+#include "command/ConsoleCommand.h"
 #include "input/InputManager.h"
 #include "input/InputState.h"
@@ -71,5 +71,5 @@
     static void key_esc()
         { GUIManager::getInstance().keyESC(); }
-    SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
+    SetConsoleCommand("keyESC", &key_esc);
 
     class CEGUILogger : public CEGUI::DefaultLogger
@@ -99,6 +99,6 @@
     GUIManager* GUIManager::singletonPtr_s = 0;
 
-    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
-    SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
+    SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, true);
+    SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
 
     /**
Index: code/trunk/src/libraries/core/Game.cc
===================================================================
--- code/trunk/src/libraries/core/Game.cc	(revision 7278)
+++ code/trunk/src/libraries/core/Game.cc	(revision 7284)
@@ -45,5 +45,4 @@
 #include "util/SubString.h"
 #include "CommandLineParser.h"
-#include "ConsoleCommand.h"
 #include "Core.h"
 #include "CoreIncludes.h"
@@ -52,4 +51,5 @@
 #include "GameState.h"
 #include "GUIManager.h"
+#include "command/ConsoleCommand.h"
 
 namespace orxonox
@@ -57,11 +57,11 @@
     static void stop_game()
         { Game::getInstance().stop(); }
-    SetConsoleCommandShortcutExternAlias(stop_game, "exit");
+    SetConsoleCommand("exit", &stop_game);
     static void printFPS()
         { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
-    SetConsoleCommandShortcutExternAlias(printFPS, "printFPS");
+    SetConsoleCommand("printFPS", &printFPS);
     static void printTickTime()
         { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
-    SetConsoleCommandShortcutExternAlias(printTickTime, "printTickTime");
+    SetConsoleCommand("printTickTime", &printTickTime);
 
     std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
Index: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc	(revision 7278)
+++ code/trunk/src/libraries/core/GraphicsManager.cc	(revision 7284)
@@ -52,5 +52,4 @@
 #include "util/StringUtils.h"
 #include "util/SubString.h"
-#include "ConsoleCommand.h"
 #include "ConfigValueIncludes.h"
 #include "CoreIncludes.h"
@@ -62,7 +61,11 @@
 #include "WindowEventListener.h"
 #include "XMLFile.h"
+#include "command/ConsoleCommand.h"
 
 namespace orxonox
 {
+    static const std::string __CC_printScreen_name = "printScreen";
+    DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void);
+
     class OgreWindowEventListener : public Ogre::WindowEventListener
     {
@@ -131,5 +134,5 @@
 
         Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get());
-        // TODO: Destroy the console command
+        ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
 
         // Undeclare the resources
@@ -290,5 +293,5 @@
         boost::filesystem::path folder(ogrePluginsDirectory_);
         // Do some SubString magic to get the comma separated list of plugins
-        SubString plugins(ogrePlugins_, ",", " ", false, '\\', false, '"', false, '(', ')', false, '\0');
+        SubString plugins(ogrePlugins_, ",", " ", false, '\\', false, '"', false, '{', '}', false, '\0');
         // Use backslash paths on Windows! file_string() already does that though.
         for (unsigned int i = 0; i < plugins.size(); ++i)
@@ -321,6 +324,5 @@
 
         // add console commands
-        ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen");
-        CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
+        ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this);
     }
 
Index: code/trunk/src/libraries/core/GraphicsManager.h
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.h	(revision 7278)
+++ code/trunk/src/libraries/core/GraphicsManager.h	(revision 7284)
@@ -114,7 +114,4 @@
         int                 ogreLogLevelCritical_;     //!< Corresponding Orxonox debug level for LL_CRITICAL
 
-        // console commands
-        ConsoleCommand*     ccPrintScreen_;
-
         static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
     };
Index: code/trunk/src/libraries/core/IOConsole.cc
===================================================================
--- code/trunk/src/libraries/core/IOConsole.cc	(revision 7278)
+++ 	(revision )
@@ -1,799 +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:
- *      Oliver Scheuss
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "IOConsole.h"
-
-#include <iomanip>
-#include <iostream>
-
-#include "util/Clock.h"
-#include "util/Math.h"
-#include "Game.h"
-#include "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/trunk/src/libraries/core/IOConsole.h
===================================================================
--- code/trunk/src/libraries/core/IOConsole.h	(revision 7278)
+++ 	(revision )
@@ -1,128 +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:
- *      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 "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/trunk/src/libraries/core/IRC.cc
===================================================================
--- code/trunk/src/libraries/core/IRC.cc	(revision 7278)
+++ 	(revision )
@@ -1,137 +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:
- *      ...
- *
- */
-
-#include "IRC.h"
-
-#include <cpptcl/cpptcl.h>
-
-#include "util/Convert.h"
-#include "util/Exception.h"
-#include "util/StringUtils.h"
-#include "ConsoleCommand.h"
-#include "CoreIncludes.h"
-#include "TclThreadManager.h"
-
-namespace orxonox
-{
-    static const unsigned int IRC_TCL_THREADID  = 1421421421;
-
-    SetConsoleCommand(IRC, say,  true).accessLevel(AccessLevel::User);
-    SetConsoleCommand(IRC, msg,  false).accessLevel(AccessLevel::User);
-    SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User);
-
-    IRC::IRC()
-    {
-        RegisterRootObject(IRC);
-        this->interpreter_ = 0;
-    }
-
-    void IRC::initialize()
-    {
-        unsigned int threadID = IRC_TCL_THREADID;
-        this->interpreter_ = TclThreadManager::createWithId(threadID);
-
-        try
-        {
-            this->interpreter_->def("::orxonox::irc::say", IRC::tcl_say, Tcl::variadic());
-            this->interpreter_->def("::orxonox::irc::privmsg", IRC::tcl_privmsg, Tcl::variadic());
-            this->interpreter_->def("::orxonox::irc::action", IRC::tcl_action, Tcl::variadic());
-            this->interpreter_->def("::orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
-        }
-        catch (Tcl::tcl_error const &e)
-        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
-
-        this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
-        TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
-        TclThreadManager::execute(threadID, "source irc.tcl");
-    }
-
-    IRC& IRC::getInstance()
-    {
-        static IRC instance;
-        return instance;
-    }
-
-    bool IRC::eval(const std::string& command)
-    {
-        if (!IRC::getInstance().interpreter_)
-        {
-            IRC::getInstance().initialize();
-            COUT(1) << "Error: IRC client wasn't yet initialized, please try again." << std::endl;
-            return false;
-        }
-
-        try
-        {
-            IRC::getInstance().interpreter_->eval(command);
-            return true;
-        }
-        catch (Tcl::tcl_error const &e)
-        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
-
-        return false;
-    }
-
-    void IRC::say(const std::string& message)
-    {
-        if (IRC::eval("irk::say $conn #orxonox {" + message + '}'))
-            IRC::tcl_say(Tcl::object(), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
-    }
-
-    void IRC::msg(const std::string& channel, const std::string& message)
-    {
-        if (IRC::eval("irk::say $conn " + channel + " {" + message + '}'))
-            IRC::tcl_privmsg(Tcl::object(channel), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
-    }
-
-    void IRC::nick(const std::string& nickname)
-    {
-        if (IRC::eval("irk::nick $conn " + nickname))
-            IRC::getInstance().nickname_ = nickname;
-    }
-
-    void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
-    {
-        COUT(0) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
-    }
-
-    void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args)
-    {
-        COUT(0) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
-    }
-
-    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;
-    }
-
-    void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args)
-    {
-        COUT(0) << "IRC> --> " << stripEnclosingBraces(args.get()) << std::endl;
-    }
-}
Index: code/trunk/src/libraries/core/IRC.h
===================================================================
--- code/trunk/src/libraries/core/IRC.h	(revision 7278)
+++ 	(revision )
@@ -1,66 +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:
- *      ...
- *
- */
-
-#ifndef _IRC_H__
-#define _IRC_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-#include "OrxonoxClass.h"
-
-namespace orxonox
-{
-    class _CoreExport IRC : public OrxonoxClass
-    {
-        public:
-            static IRC& getInstance();
-
-            static void say(const std::string& message);
-            static void msg(const std::string& channel, const std::string& message);
-            static void nick(const std::string& nickname);
-
-            static void tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
-            static void tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args);
-            static void tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
-            static void tcl_info(Tcl::object const &channel, Tcl::object const &args);
-
-        private:
-            static bool eval(const std::string& command);
-            void initialize();
-
-            IRC();
-            IRC(const IRC& other);
-            ~IRC() {}
-
-            Tcl::interpreter* interpreter_;
-            std::string nickname_;
-    };
-}
-
-#endif /* _IRC_H__ */
Index: code/trunk/src/libraries/core/Identifier.cc
===================================================================
--- code/trunk/src/libraries/core/Identifier.cc	(revision 7278)
+++ code/trunk/src/libraries/core/Identifier.cc	(revision 7284)
@@ -38,5 +38,4 @@
 #include "util/StringUtils.h"
 #include "ConfigValueContainer.h"
-#include "ConsoleCommand.h"
 #include "ClassFactory.h"
 #include "XMLPort.h"
@@ -64,5 +63,4 @@
 
         this->bHasConfigValues_ = false;
-        this->bHasConsoleCommands_ = false;
 
         // Default network ID is the class ID
@@ -80,6 +78,4 @@
             delete this->factory_;
 
-        for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)
-            delete (it->second);
         for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
             delete (it->second);
@@ -433,57 +429,4 @@
 
     /**
-        @brief Adds a new console command of this class.
-        @param executor The executor of the command
-        @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command
-        @return The executor of the command
-    */
-    ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)
-    {
-        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());
-        if (it != this->consoleCommands_.end())
-        {
-            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << '.' << std::endl;
-            delete (it->second);
-        }
-
-        this->bHasConsoleCommands_ = true;
-        this->consoleCommands_[command->getName()] = command;
-        this->consoleCommands_LC_[getLowercase(command->getName())] = command;
-
-        if (bCreateShortcut)
-            CommandExecutor::addConsoleCommandShortcut(command);
-
-        return (*command);
-    }
-
-    /**
-        @brief Returns the executor of a console command with given name.
-        @brief name The name of the requested console command
-        @return The executor of the requested console command
-    */
-    ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const
-    {
-        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);
-        if (it != this->consoleCommands_.end())
-            return it->second;
-        else
-            return 0;
-    }
-
-    /**
-        @brief Returns the executor of a console command with given name in lowercase.
-        @brief name The name of the requested console command in lowercae
-        @return The executor of the requested console command
-    */
-    ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const
-    {
-        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);
-        if (it != this->consoleCommands_LC_.end())
-            return it->second;
-        else
-            return 0;
-    }
-
-    /**
         @brief Returns a XMLPortParamContainer that loads a parameter of this class.
         @param paramname The name of the parameter
Index: code/trunk/src/libraries/core/Identifier.h
===================================================================
--- code/trunk/src/libraries/core/Identifier.h	(revision 7278)
+++ code/trunk/src/libraries/core/Identifier.h	(revision 7284)
@@ -202,29 +202,4 @@
             void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
             ConfigValueContainer* getConfigValueContainer(const std::string& varname);
-
-
-            ////////////////////////////
-            ///// Console Commands /////
-            ////////////////////////////
-            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
-            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
-
-            /** @brief Returns the map that stores all console commands. @return The const_iterator */
-            inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandMap() const { return this->consoleCommands_; }
-            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
-            inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); }
-            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
-            inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); }
-
-            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
-            inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; }
-            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
-            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); }
-            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
-            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }
-
-            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
-            ConsoleCommand* getConsoleCommand(const std::string& name) const;
-            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
 
 
@@ -305,8 +280,4 @@
             bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
             std::map<std::string, ConfigValueContainer*> configValues_;    //!< A map to link the string of configurable variables with their ConfigValueContainer
-
-            bool bHasConsoleCommands_;                                     //!< True if this class has at least one assigned console command
-            std::map<std::string, ConsoleCommand*> consoleCommands_;       //!< All console commands of this class
-            std::map<std::string, ConsoleCommand*> consoleCommands_LC_;    //!< All console commands of this class with their names in lowercase
 
             std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_;     //!< All loadable parameters
Index: code/trunk/src/libraries/core/Language.cc
===================================================================
--- code/trunk/src/libraries/core/Language.cc	(revision 7278)
+++ code/trunk/src/libraries/core/Language.cc	(revision 7284)
@@ -36,4 +36,5 @@
 #include <fstream>
 #include "util/Debug.h"
+#include "util/StringUtils.h"
 #include "Core.h"
 #include "PathConfig.h"
@@ -169,10 +170,10 @@
         @return The localisation
     */
-    const std::string& Language::getLocalisation(const LanguageEntryLabel& label) const
+    const std::string& Language::getLocalisation(const LanguageEntryLabel& label, bool bError) const
     {
         std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
         if (it != this->languageEntries_.end())
             return it->second->getLocalisation();
-        else
+        else if (bError)
         {
             // Uh, oh, an undefined entry was requested: return the default string
@@ -180,4 +181,6 @@
             return this->defaultLocalisation_;
         }
+        else
+            return BLANKSTRING;
     }
 
Index: code/trunk/src/libraries/core/Language.h
===================================================================
--- code/trunk/src/libraries/core/Language.h	(revision 7278)
+++ code/trunk/src/libraries/core/Language.h	(revision 7284)
@@ -116,5 +116,5 @@
 
             void addEntry(const LanguageEntryLabel& label, const std::string& entry);
-            const std::string& getLocalisation(const LanguageEntryLabel& label) const;
+            const std::string& getLocalisation(const LanguageEntryLabel& label, bool bError = true) const;
 
         private:
@@ -145,4 +145,10 @@
         return Language::getInstance().getLocalisation(label);
     }
+
+    //! Shortcut function for Language::getLocalisation without printing an error in case the label doesn't exist
+    inline const std::string& GetLocalisation_noerror(const LanguageEntryLabel& label)
+    {
+        return Language::getInstance().getLocalisation(label, false);
+    }
 }
 
Index: code/trunk/src/libraries/core/LuaState.cc
===================================================================
--- code/trunk/src/libraries/core/LuaState.cc	(revision 7278)
+++ code/trunk/src/libraries/core/LuaState.cc	(revision 7284)
@@ -39,7 +39,7 @@
 #include "util/Debug.h"
 #include "util/Exception.h"
-#include "IOConsole.h"
 #include "Resource.h"
 #include "ToluaBindCore.h"
+#include "command/IOConsole.h"
 
 namespace orxonox
@@ -370,5 +370,5 @@
     }
 
-    void LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    void LuaFunctor::operator()()
     {
         lua_->doString(this->code_);
Index: code/trunk/src/libraries/core/LuaState.h
===================================================================
--- code/trunk/src/libraries/core/LuaState.h	(revision 7278)
+++ code/trunk/src/libraries/core/LuaState.h	(revision 7284)
@@ -40,18 +40,16 @@
 #include <loki/ScopeGuard.h>
 
-#include "Functor.h"
 #include "ToluaInterface.h"
 
 namespace orxonox // tolua_export
 { // tolua_export
-    class Functor; // tolua_export
+    class LuaFunctor; // tolua_export
 
-    //! Functor subclass that simply executes code with 0 arguments.
-    class _CoreExport LuaFunctor : public Functor
+    //! callback class that executes lua code
+    class _CoreExport LuaFunctor
     {
         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 {}
+            void operator()();
 
         private:
@@ -91,5 +89,5 @@
         const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
 
-        Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
+        LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
         //! Tells about whether IOConsole was activated. The Lua debugger only works with a normal console.
         bool usingIOConsole() const; // tolua_export
Index: code/trunk/src/libraries/core/ScopedSingletonManager.cc
===================================================================
--- code/trunk/src/libraries/core/ScopedSingletonManager.cc	(revision 7278)
+++ 	(revision )
@@ -1,49 +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 "ScopedSingletonManager.h"
-
-namespace orxonox
-{
-    /*static*/ std::map<std::string, ScopedSingletonManager*>& ScopedSingletonManager::getManagers()
-    {
-        static std::map<std::string, ScopedSingletonManager*> managers;
-        return managers;
-    }
-    /*static*/ ScopedSingletonManager::ManagerMultiMap& ScopedSingletonManager::getManagersByScope()
-    {
-        static ManagerMultiMap managers;
-        return managers;
-    }
-
-    /*static*/ void ScopedSingletonManager::addManager(ScopedSingletonManager* manager)
-    {
-        getManagers()[manager->className_] = manager;
-        getManagersByScope().insert(std::make_pair(manager->scope_, manager));
-    }
-}
Index: code/trunk/src/libraries/core/ScopedSingletonManager.h
===================================================================
--- code/trunk/src/libraries/core/ScopedSingletonManager.h	(revision 7278)
+++ 	(revision )
@@ -1,212 +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 __ScopedSingletonManager_H__
-#define __ScopedSingletonManager_H__
-
-#include "CorePrereqs.h"
-
-#include <cassert>
-#include <map>
-#include "util/Exception.h"
-#include "util/Scope.h"
-#include "util/Singleton.h"
-
-#define ManageScopedSingleton(className, scope, allowedToFail) \
-    className* className::singletonPtr_s = NULL; \
-    static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
-
-namespace orxonox
-{
-    class _CoreExport ScopedSingletonManager
-    {
-        public:
-            ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
-                : className_(className)
-                , scope_(scope)
-            { }
-            virtual ~ScopedSingletonManager() { }
-            static void addManager(ScopedSingletonManager* manager);
-
-            template<ScopeID::Value scope>
-            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->preUpdate(time);
-            }
-            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();
-            typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap;
-            static ManagerMultiMap& getManagersByScope();
-
-        protected:
-            const std::string className_;
-            const ScopeID::Value scope_;
-    };
-
-    template <class T, ScopeID::Value scope, bool allowedToFail>
-    class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
-    {
-    public:
-        ClassScopedSingletonManager(const std::string& className)
-            : ScopedSingletonManager(className, scope)
-            , ScopeListener(scope)
-            , singletonPtr_(NULL)
-        {
-            ScopedSingletonManager::addManager(this);
-        }
-
-        ~ClassScopedSingletonManager()
-        {
-        }
-
-        //! Called if the Scope of the Singleton gets active (creates the instance)
-        void activated()
-        {
-            assert(singletonPtr_ == NULL);
-            singletonPtr_ = new T();
-        }
-
-        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
-        void deactivated()
-        {
-            assert(singletonPtr_ != NULL);
-            this->destroy(singletonPtr_);
-            singletonPtr_ = NULL;
-        }
-
-        void destroy(OrxonoxClass*)
-        {
-            singletonPtr_->destroy();
-        }
-        void destroy(void*)
-        {
-            delete singletonPtr_;
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        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);
-        }
-
-    private:
-        T* singletonPtr_;
-    };
-
-    template <class T, ScopeID::Value scope>
-    class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
-    {
-    public:
-        ClassScopedSingletonManager(const std::string& className)
-            : ScopedSingletonManager(className, scope)
-            , ScopeListener(scope)
-            , singletonPtr_(NULL)
-        {
-            ScopedSingletonManager::addManager(this);
-        }
-
-        ~ClassScopedSingletonManager()
-        {
-        }
-
-        //! Called if the Scope of the Singleton gets active (creates the instance)
-        void activated()
-        {
-            assert(singletonPtr_ == NULL);
-            try
-                { singletonPtr_ = new T(); }
-            catch (const InitialisationAbortedException& ex)
-                { COUT(3) << ex.getDescription() << std::endl; }
-            catch (...)
-                { COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }
-        }
-
-        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
-        void deactivated()
-        {
-            if (singletonPtr_ != NULL)
-            {
-                this->destroy(singletonPtr_);
-                singletonPtr_ = NULL;
-            }
-        }
-
-        void destroy(OrxonoxClass* ptr)
-        {
-            singletonPtr_->destroy();
-        }
-        void destroy(void* ptr)
-        {
-            delete singletonPtr_;
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void preUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            if (singletonPtr_ != NULL)
-                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);
-        }
-
-    private:
-        T* singletonPtr_;
-    };
-}
-
-#endif /* __ScopedSingletonManager_H__ */
Index: code/trunk/src/libraries/core/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/Shell.cc	(revision 7278)
+++ 	(revision )
@@ -1,455 +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:
- *      Reto Grieder
- *
- */
-
-#include "Shell.h"
-
-#include "util/OutputHandler.h"
-#include "util/StringUtils.h"
-#include "util/SubString.h"
-#include "CommandExecutor.h"
-#include "CoreIncludes.h"
-#include "ConfigFileManager.h"
-#include "ConfigValueIncludes.h"
-#include "ConsoleCommand.h"
-
-namespace orxonox
-{
-    SetConsoleCommandShortcut(OutputHandler, log);
-    SetConsoleCommandShortcut(OutputHandler, error);
-    SetConsoleCommandShortcut(OutputHandler, warning);
-    SetConsoleCommandShortcut(OutputHandler, info);
-    SetConsoleCommandShortcut(OutputHandler, debug);
-
-    Shell::Shell(const std::string& consoleName, bool bScrollable)
-        : OutputListener(consoleName)
-        , inputBuffer_(new InputBuffer())
-        , consoleName_(consoleName)
-        , bScrollable_(bScrollable)
-    {
-        RegisterRootObject(Shell);
-
-        this->scrollPosition_ = 0;
-        this->maxHistoryLength_ = 100;
-        this->historyPosition_ = 0;
-        this->historyOffset_ = 0;
-        this->bFinishedLastLine_ = true;
-
-        this->clearOutput();
-        this->configureInputBuffer();
-
-        // 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();
-
-        // 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::getInstance().unregisterOutputListener(this);
-        this->inputBuffer_->destroy();
-    }
-
-    void Shell::setConfigValues()
-    {
-        SetConfigValue(maxHistoryLength_, 100)
-            .callback(this, &Shell::commandHistoryLengthChanged);
-        SetConfigValue(historyOffset_, 0)
-            .callback(this, &Shell::commandHistoryOffsetChanged);
-        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
-        SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
-            .description("The maximal level of debug output shown in the Shell");
-        this->setSoftDebugLevel(this->softDebugLevel_);
-    }
-
-    void Shell::commandHistoryOffsetChanged()
-    {
-        if (this->historyOffset_ >= this->maxHistoryLength_)
-            this->historyOffset_ = 0;
-    }
-
-    void Shell::commandHistoryLengthChanged()
-    {
-        this->commandHistoryOffsetChanged();
-
-        while (this->commandHistory_.size() > this->maxHistoryLength_)
-        {
-            unsigned int index = this->commandHistory_.size() - 1;
-            this->commandHistory_.erase(this->commandHistory_.begin() + index);
-            ModifyConfigValue(commandHistory_, remove, index);
-        }
-    }
-
-    void Shell::configureInputBuffer()
-    {
-        this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
-        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()
-    {
-        Shell& instance = Shell::getInstance();
-
-        for (unsigned int i = instance.historyOffset_; i < instance.commandHistory_.size(); ++i)
-            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
-        for (unsigned int i =  0; i < instance.historyOffset_; ++i)
-            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
-    }
-    */
-
-    void Shell::registerListener(ShellListener* listener)
-    {
-        this->listeners_.push_back(listener);
-    }
-
-    void Shell::unregisterListener(ShellListener* listener)
-    {
-        for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
-        {
-            if ((*it) == listener)
-                it = this->listeners_.erase(it);
-            else
-                ++it;
-        }
-    }
-
-    void Shell::setCursorPosition(unsigned int cursor)
-    {
-        this->inputBuffer_->setCursorPosition(cursor);
-        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->bFinishedLastLine_ = true;
-
-        this->updateListeners<&ShellListener::linesChanged>();
-    }
-
-    Shell::LineList::const_iterator Shell::getNewestLineIterator() const
-    {
-        if (this->scrollPosition_)
-            return this->scrollIterator_;
-        else
-            return this->outputLines_.begin();
-    }
-
-    Shell::LineList::const_iterator Shell::getEndIterator() const
-    {
-        return this->outputLines_.end();
-    }
-
-    void Shell::addToHistory(const std::string& command)
-    {
-        ModifyConfigValue(commandHistory_, set, this->historyOffset_, command);
-        this->historyPosition_ = 0;
-        ModifyConfigValue(historyOffset_, set, (this->historyOffset_ + 1) % this->maxHistoryLength_);
-    }
-
-    const std::string& Shell::getFromHistory() const
-    {
-        unsigned int index = mod(static_cast<int>(this->historyOffset_) - static_cast<int>(this->historyPosition_), this->maxHistoryLength_);
-        if (index < this->commandHistory_.size() && this->historyPosition_ != 0)
-            return this->commandHistory_[index];
-        else
-            return BLANKSTRING;
-    }
-
-    void Shell::outputChanged(int lineType)
-    {
-        bool newline = false;
-        do
-        {
-            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->bFinishedLastLine_)
-            {
-                this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
-
-                if (this->scrollPosition_)
-                    this->scrollPosition_++;
-                else
-                    this->scrollIterator_ = this->outputLines_.begin();
-
-                this->bFinishedLastLine_ = newline;
-
-                if (!this->scrollPosition_)
-                    this->updateListeners<&ShellListener::lineAdded>();
-            }
-            else
-            {
-                this->outputLines_.front().first += output;
-                this->bFinishedLastLine_ = newline;
-                this->updateListeners<&ShellListener::onlyLastLineChanged>();
-            }
-            this->bFinishedLastLine_ = newline;
-
-        } while (newline);
-    }
-
-    void Shell::clearInput()
-    {
-        this->inputBuffer_->clear();
-        this->historyPosition_ = 0;
-        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();
-        this->updateListeners<&ShellListener::cursorChanged>();
-    }
-
-    void Shell::cursorLeft()
-    {
-        this->inputBuffer_->decreaseCursor();
-        this->updateListeners<&ShellListener::cursorChanged>();
-    }
-
-    void Shell::cursorEnd()
-    {
-        this->inputBuffer_->setCursorToEnd();
-        this->updateListeners<&ShellListener::cursorChanged>();
-    }
-
-    void Shell::cursorHome()
-    {
-        this->inputBuffer_->setCursorToBegin();
-        this->updateListeners<&ShellListener::cursorChanged>();
-    }
-
-    void Shell::historyUp()
-    {
-        if (this->historyPosition_ < this->commandHistory_.size())
-        {
-            this->historyPosition_++;
-            this->inputBuffer_->set(this->getFromHistory());
-        }
-    }
-
-    void Shell::historyDown()
-    {
-        if (this->historyPosition_ > 0)
-        {
-            this->historyPosition_--;
-            this->inputBuffer_->set(this->getFromHistory());
-        }
-    }
-
-    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_;
-
-            this->updateListeners<&ShellListener::linesChanged>();
-        }
-    }
-
-    void Shell::scrollDown()
-    {
-        if (this->scrollIterator_ != this->outputLines_.begin())
-        {
-            --this->scrollIterator_;
-            --this->scrollPosition_;
-
-            this->updateListeners<&ShellListener::linesChanged>();
-        }
-    }
-}
Index: code/trunk/src/libraries/core/Shell.h
===================================================================
--- code/trunk/src/libraries/core/Shell.h	(revision 7278)
+++ 	(revision )
@@ -1,172 +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:
- *      Reto Grieder
- *
- */
-
-#ifndef _Shell_H__
-#define _Shell_H__
-
-#include "CorePrereqs.h"
-
-#include <list>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include "util/OutputHandler.h"
-#include "OrxonoxClass.h"
-#include "input/InputBuffer.h"
-
-namespace orxonox
-{
-    class _CoreExport ShellListener
-    {
-        friend class Shell;
-
-        public:
-            virtual ~ShellListener() {}
-
-        private:
-            virtual void linesChanged() {}
-            virtual void onlyLastLineChanged() {}
-            virtual void lineAdded() {}
-            virtual void inputChanged() {}
-            virtual void cursorChanged() {}
-            virtual void executed() {}
-            virtual void exit() {}
-    };
-
-
-    class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
-    {
-        public:
-            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
-            };
-
-            Shell(const std::string& consoleName, bool bScrollable);
-            ~Shell();
-
-            void setConfigValues();
-            void commandHistoryOffsetChanged();
-            void commandHistoryLengthChanged();
-
-            void registerListener(ShellListener* listener);
-            void unregisterListener(ShellListener* listener);
-
-            inline InputBuffer* getInputBuffer()
-                { return this->inputBuffer_; }
-
-            void setCursorPosition(unsigned int cursor);
-            inline unsigned int getCursorPosition() const
-                { return this->inputBuffer_->getCursorPosition(); }
-
-            inline const std::string& getInput() const
-                { return this->inputBuffer_->get(); }
-
-            typedef std::list<std::pair<std::string, LineType> > LineList;
-            LineList::const_iterator getNewestLineIterator() const;
-            LineList::const_iterator getEndIterator() const;
-
-            void addOutput(const std::string& text, LineType type = None);
-            void clearOutput();
-
-            inline unsigned int getNumLines() const
-                { return this->outputLines_.size(); }
-            inline unsigned int getScrollPosition() const
-                { return this->scrollPosition_; }
-
-            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();
-
-            // InputBuffer callbacks
-            void inputChanged();
-            void execute();
-            void hintAndComplete();
-            void backspace();
-            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_;
-            std::stringstream         outputBuffer_;
-            bool                      bFinishedLastLine_;
-            LineList                  outputLines_;
-            LineList::const_iterator  scrollIterator_;
-            unsigned int              scrollPosition_;
-            unsigned int              historyPosition_;
-
-            std::string               promptPrefix_;
-            const std::string         consoleName_;
-            const bool                bScrollable_;
-
-            // Config values
-            unsigned int              maxHistoryLength_;
-            unsigned int              historyOffset_;
-            std::vector<std::string>  commandHistory_;
-            int                       softDebugLevel_;
-    };
-}
-
-#endif /* _Shell_H__ */
Index: code/trunk/src/libraries/core/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/TclBind.cc	(revision 7278)
+++ 	(revision )
@@ -1,195 +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:
- *      ...
- *
- */
-
-#include "TclBind.h"
-
-#include <exception>
-#include <string>
-#include <cpptcl/cpptcl.h>
-
-#include "SpecialConfig.h"
-#include "util/Debug.h"
-#include "util/Exception.h"
-#include "util/StringUtils.h"
-#include "CommandExecutor.h"
-#include "ConsoleCommand.h"
-#include "PathConfig.h"
-#include "TclThreadManager.h"
-
-namespace orxonox
-{
-    SetConsoleCommandShortcut(TclBind, tcl);
-    SetConsoleCommandShortcut(TclBind, bgerror);
-
-    TclBind* TclBind::singletonPtr_s = 0;
-
-    TclBind::TclBind(const std::string& datapath)
-    {
-        this->interpreter_ = 0;
-        this->bSetTclDataPath_ = false;
-        this->setDataPath(datapath);
-    }
-
-    TclBind::~TclBind()
-    {
-        if (this->interpreter_)
-            delete this->interpreter_;
-    }
-
-    void TclBind::setDataPath(const std::string& datapath)
-    {
-        // String has POSIX slashes
-        this->tclDataPath_ = datapath + "tcl" + '/';
-        this->bSetTclDataPath_ = true;
-
-        this->initializeTclInterpreter();
-    }
-
-    void TclBind::initializeTclInterpreter()
-    {
-        if (this->bSetTclDataPath_ && !this->interpreter_)
-        {
-            this->interpreter_ = this->createTclInterpreter();
-
-            this->interpreter_->def("::orxonox::query", TclBind::tcl_query, Tcl::variadic());
-            this->interpreter_->def("::orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
-            this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
-            this->interpreter_->def("::orxonox::crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic());
-
-            try
-            {
-                this->interpreter_->eval("proc query        {args}    { ::orxonox::query $args }");
-                this->interpreter_->eval("proc crossquery   {id args} { ::orxonox::crossquery 0 $id $args }");
-                this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::crossquery 0 $id $args }");
-                this->interpreter_->eval("proc running      {}        { return 1 }");
-                this->interpreter_->eval("set id 0");
-                this->interpreter_->eval("rename exit ::tcl::exit; proc exit {} { execute exit }");
-            }
-            catch (Tcl::tcl_error const &e)
-            {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
-        }
-    }
-
-    Tcl::interpreter* TclBind::createTclInterpreter()
-    {
-        Tcl::interpreter* interpreter = new Tcl::interpreter();
-        const std::string& libpath = TclBind::getTclLibraryPath();
-
-        try
-        {
-            if (!libpath.empty())
-                interpreter->eval("set tcl_library \"" + libpath + '"');
-
-            Tcl_Init(interpreter->get());
-
-            interpreter->eval("source \"" + TclBind::getInstance().tclDataPath_ + "/init.tcl\"");
-        }
-        catch (Tcl::tcl_error const &e)
-        {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
-
-        return interpreter;
-    }
-
-    std::string TclBind::getTclLibraryPath()
-    {
-#ifdef DEPENDENCY_PACKAGE_ENABLE
-        if (PathConfig::isDevelopmentRun())
-            return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl");
-        else
-            return (PathConfig::getRootPathString() + "lib/tcl");
-#else
-        return "";
-#endif
-    }
-
-    std::string TclBind::tcl_query(Tcl::object const &args)
-    {
-        COUT(4) << "Tcl_query: " << args.get() << std::endl;
-
-        const std::string& command = stripEnclosingBraces(args.get());
-
-        if (!CommandExecutor::execute(command, false))
-        {
-            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
-        }
-
-        if (CommandExecutor::getLastEvaluation().hasReturnvalue())
-            return CommandExecutor::getLastEvaluation().getReturnvalue().getString();
-
-        return "";
-    }
-
-    void TclBind::tcl_execute(Tcl::object const &args)
-    {
-        COUT(4) << "Tcl_execute: " << args.get() << std::endl;
-        const std::string& command = stripEnclosingBraces(args.get());
-
-        if (!CommandExecutor::execute(command, false))
-        {
-            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
-        }
-    }
-
-    std::string TclBind::tcl(const std::string& tclcode)
-    {
-        if (TclBind::getInstance().interpreter_)
-        {
-            try
-            {
-                const std::string& output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
-                if (!output.empty())
-                {
-                    COUT(0) << "tcl> " << output << std::endl;
-                }
-                return output;
-            }
-            catch (Tcl::tcl_error const &e)
-            {   COUT(1) << "tcl> Error: " << e.what() << std::endl;   }
-        }
-
-        return "";
-    }
-
-    void TclBind::bgerror(const std::string& error)
-    {
-        COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
-    }
-
-    bool TclBind::eval(const std::string& tclcode)
-    {
-        try
-        {
-            TclBind::getInstance().interpreter_->eval(tclcode);
-            return true;
-        }
-        catch (Tcl::tcl_error const &e)
-        {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
-
-        return false;
-    }
-}
Index: code/trunk/src/libraries/core/TclBind.h
===================================================================
--- code/trunk/src/libraries/core/TclBind.h	(revision 7278)
+++ 	(revision )
@@ -1,74 +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:
- *      ...
- *
- */
-
-#ifndef _TclBind_H__
-#define _TclBind_H__
-
-#include "CorePrereqs.h"
-
-#include <cassert>
-#include <string>
-#include "util/Singleton.h"
-
-namespace orxonox
-{
-    class _CoreExport TclBind : public Singleton<TclBind>
-    {
-        friend class Singleton<TclBind>;
-        public:
-            TclBind(const std::string& datapath);
-            ~TclBind();
-
-            static std::string tcl(const std::string& tclcode);
-            static void bgerror(const std::string& error);
-
-            void setDataPath(const std::string& datapath);
-            const std::string& getTclDataPath() const { return this->tclDataPath_; }
-            static std::string getTclLibraryPath();
-
-            void initializeTclInterpreter();
-            static Tcl::interpreter* createTclInterpreter();
-            Tcl::interpreter* getTclInterpreter() const { return this->interpreter_; }
-
-            static std::string tcl_query(Tcl::object const &args);
-            static void tcl_execute(Tcl::object const &args);
-
-            static bool eval(const std::string& tclcode);
-
-        private:
-            TclBind(const TclBind& other);
-
-            Tcl::interpreter* interpreter_;
-            std::string tclDataPath_;
-            bool bSetTclDataPath_;
-
-            static TclBind* singletonPtr_s;
-    };
-}
-
-#endif /* _TclBind_H__ */
Index: code/trunk/src/libraries/core/TclThreadList.h
===================================================================
--- code/trunk/src/libraries/core/TclThreadList.h	(revision 7278)
+++ 	(revision )
@@ -1,263 +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:
- *      ...
- *
- */
-
-#ifndef _TclThreadList_H__
-#define _TclThreadList_H__
-
-#include "CorePrereqs.h"
-
-#include <list>
-
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <boost/thread/locks.hpp>
-
-namespace orxonox
-{
-    template <class T>
-    class TclThreadList
-    {
-        public:
-            void push_front(const T& value);
-            void push_back(const T& value);
-            template <class InputIterator> void insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end);
-
-            void wait_and_pop_front(T* value);
-            void wait_and_pop_back(T* value);
-            bool try_pop_front(T* value);
-            bool try_pop_back(T* value);
-            void clear();
-
-            size_t size() const;
-            bool empty() const;
-            bool is_in(const T& value) const;
-
-            /**
-                @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
-            */
-            inline std::list<T>& getList()
-                { return this->list_; }
-
-            /**
-                @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
-            */
-            inline const std::list<T>& getList() const
-                { return this->list_; }
-
-            /**
-                @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref begin and @ref end).
-            */
-            inline boost::shared_mutex& getMutex() const
-                { return this->mutex_; }
-
-        private:
-            std::list<T>                  list_;        ///< A standard list for type T
-            mutable boost::shared_mutex   mutex_;       ///< A mutex to grant exclusive access to the list
-            boost::condition_variable_any condition_;   ///< A condition variable to wake threads waiting for the mutex to become ready
-    };
-
-    /**
-        @brief Pushes a new element to the front of the list. A unique_lock is needed.
-    */
-    template <class T>
-    void TclThreadList<T>::push_front(const T& value)
-    {
-        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-        this->list_.push_front(value);
-        lock.unlock();                  // unlock the mutex...
-        this->condition_.notify_all();  // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
-    }
-
-    /**
-        @brief Pushes a new element to the back of the list. A unique_lock is needed.
-    */
-    template <class T>
-    void TclThreadList<T>::push_back(const T& value)
-    {
-        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-        this->list_.push_back(value);
-        lock.unlock();                  // unlock the mutex...
-        this->condition_.notify_all();  // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
-    }
-
-    /**
-        @brief Inserts new elements into the list. A unique_lock is needed.
-    */
-    template <class T>
-    template <class InputIterator> void TclThreadList<T>::insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end)
-    {
-        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-        this->list_.insert(position, begin, end);
-        lock.unlock();                  // unlock the mutex...
-        this->condition_.notify_all();  // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
-    }
-
-    /**
-        @brief Waits until the list contains at least one element and then pops and returns the front element.
-        @param value The front value will be stored in the variable referenced by this pointer.
-    */
-    template <class T>
-    void TclThreadList<T>::wait_and_pop_front(T* value)
-    {
-        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-
-        while (this->list_.empty())       // check if there's an element in the list
-            this->condition_.wait(lock);  // wait until the condition becomes true (a notification comes from push_front, push_back or insert
-
-        *value = this->list_.front();
-        this->list_.pop_front();
-    }
-
-    /**
-        @brief Waits until the list contains at least one element and then pops and returns the back element.
-        @param value The back value will be stored in the variable referenced by this pointer.
-    */
-    template <class T>
-    void TclThreadList<T>::wait_and_pop_back(T* value)
-    {
-        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-
-        while (this->list_.empty())       // check if there's an element in the list
-            this->condition_.wait(lock);  // wait until the condition becomes true (a notification comes from push_front, push_back or insert
-
-        *value = this->list_.back();
-        this->list_.pop_back();
-    }
-
-    /**
-        @brief Pops and returns the front element if there's at least one element in the list.
-        @param value The front value will be stored in the variable referenced by this pointer.
-        @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
-
-        Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
-    */
-    template <class T>
-    bool TclThreadList<T>::try_pop_front(T* value)
-    {
-        boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
-
-        if (this->list_.empty())
-        {
-            // No elements - return immediately
-            return false;
-        }
-        else
-        {
-            // At least one element - write it into the passed variable and pop it from the list
-            boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
-            *value = this->list_.front();
-            this->list_.pop_front();
-        }
-        return true;
-    }
-
-    /**
-        @brief Pops and returns the back element if there's at least one element in the list.
-        @param value The back value will be stored in the variable referenced by this pointer.
-        @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
-
-        Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
-    */
-    template <class T>
-    bool TclThreadList<T>::try_pop_back(T* value)
-    {
-        boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
-
-        if (this->list_.empty())
-        {
-            // No elements - return immediately
-            return false;
-        }
-        else
-        {
-            // At least one element - write it into the passed variable and pop it from the list
-            boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
-            *value = this->list_.back();
-            this->list_.pop_back();
-        }
-        return true;
-    }
-
-    /**
-        @brief Clears the list. A unique_lock is needed.
-    */
-    template <class T>
-    void TclThreadList<T>::clear()
-    {
-        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-        this->list_.clear();
-    }
-
-    /**
-        @brief Returns the size of the list. A shared_lock is needed.
-
-        Warning: Don't change the list based on the result of size(). Use an atomic function instead. Other threads may change the list
-        beween your call to size() and your further actions, so be careful and use this function only if you really want nothing else than
-        just the size of the list.
-    */
-    template <class T>
-    size_t TclThreadList<T>::size() const
-    {
-        boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
-        return this->list_.size();
-    }
-
-    /**
-        @brief Returns true if the list is empty, false otherwise. A shared_lock is needed.
-
-        Warning: Don't change the list based on the result of empty(). Use an atomic function instead. Other threads may change the list
-        beween your call to empty() and your further actions, so be careful and use this function only if you really want nothing else than
-        just if the list is empty or not.
-    */
-    template <class T>
-    bool TclThreadList<T>::empty() const
-    {
-        boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
-        return this->list_.empty();
-    }
-
-    /**
-        @brief Returns true if a given element is in the list, false otherwise. A shared_lock is needed.
-
-        Warning: The result of this function might be wrong just one instruction after the call. Use this function just to get information
-        about a temporary snapshot and don't change the list based on the result of this function.
-    */
-    template <class T>
-    bool TclThreadList<T>::is_in(const T& value) const
-    {
-        boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
-
-        for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
-            if (*it == value)
-                return true;
-
-        return false;
-    }
-}
-
-#endif /* _TclThreadList_H__ */
Index: code/trunk/src/libraries/core/TclThreadManager.cc
===================================================================
--- code/trunk/src/libraries/core/TclThreadManager.cc	(revision 7278)
+++ 	(revision )
@@ -1,670 +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:
- *      ...
- *
- */
-
-#include "TclThreadManager.h"
-
-#include <boost/bind.hpp>
-#include <boost/thread/thread.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <OgreTimer.h>
-#include <cpptcl/cpptcl.h>
-
-#include "util/Clock.h"
-#include "util/Convert.h"
-#include "util/Exception.h"
-#include "util/StringUtils.h"
-#include "CommandExecutor.h"
-#include "ConsoleCommand.h"
-#include "CoreIncludes.h"
-#include "TclBind.h"
-#include "TclThreadList.h"
-
-namespace orxonox
-{
-    const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f;
-
-    SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads());
-    SetConsoleCommandShortcutAlias(TclThreadManager, query,   "tclquery"  ).argumentCompleter(0, autocompletion::tclthreads());
-    SetConsoleCommand(TclThreadManager, create,  false);
-    SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads());
-    SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads());
-    SetConsoleCommand(TclThreadManager, query,   false).argumentCompleter(0, autocompletion::tclthreads());
-    SetConsoleCommand(TclThreadManager, source,  false).argumentCompleter(0, autocompletion::tclthreads());
-
-    /**
-        @brief A struct containing all information about a Tcl-interpreter
-    */
-    struct TclInterpreterBundle
-    {
-        TclInterpreterBundle()
-        {
-            this->lock_ = new boost::unique_lock<boost::mutex>(this->mutex_, boost::defer_lock);
-            this->bRunning_ = true;
-        }
-
-        ~TclInterpreterBundle()
-        {
-            delete this->lock_;
-        }
-
-        unsigned int                      id_;             ///< The id of the interpreter
-        Tcl::interpreter*                 interpreter_;    ///< The Tcl-interpreter
-        boost::mutex                      mutex_;          ///< A mutex to lock the interpreter while it's being used
-        boost::unique_lock<boost::mutex>* lock_;           ///< The corresponding lock for the mutex
-        TclThreadList<std::string>        queue_;          ///< The command queue for commands passed by execute(command)
-        TclThreadList<unsigned int>       queriers_;       ///< A list containing the id's of all other threads sending a query to this interpreter (to avoid circular queries and deadlocks)
-        bool                              bRunning_;       ///< This variable stays true until destroy() gets called
-    };
-
-    TclThreadManager* TclThreadManager::singletonPtr_s = 0;
-
-    /**
-        @brief Constructor
-        @param interpreter A pointer to the standard Tcl-interpreter (see @ref TclBind)
-    */
-    TclThreadManager::TclThreadManager(Tcl::interpreter* interpreter)
-    {
-        RegisterRootObject(TclThreadManager);
-
-        this->numInterpreterBundles_ = 0;
-
-        this->interpreterBundlesMutex_ = new boost::shared_mutex();
-        this->mainInterpreterMutex_ = new boost::mutex();
-        this->messageQueue_ = new TclThreadList<std::string>();
-
-        TclInterpreterBundle* newbundle = new TclInterpreterBundle();
-        newbundle->id_ = 0;
-        newbundle->interpreter_ = interpreter;
-        newbundle->lock_->lock();
-
-        {
-            boost::unique_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
-            this->interpreterBundles_[0] = newbundle;
-        }
-    }
-
-    /**
-        @brief Destructor
-    */
-    TclThreadManager::~TclThreadManager()
-    {
-        delete this->interpreterBundlesMutex_;
-//        delete this->mainInterpreterMutex_; // <-- temporary disabled to avoid crash if a thread is still actively queriyng
-        delete this->messageQueue_;
-    }
-
-    /**
-        @brief The "main loop" of the TclThreadManager. Creates new threads if needed and handles queries and queued commands for the main interpreter.
-    */
-    void TclThreadManager::preUpdate(const Clock& time)
-    {
-        // Get the bundle of the main interpreter (0)
-        TclInterpreterBundle* bundle = this->getInterpreterBundle(0);
-        if (bundle)
-        {
-            // Unlock the mutex to allow other threads accessing the main interpreter
-            bundle->lock_->unlock();
-
-            // Lock the main interpreter mutex once to synchronize with threads that want to query the main interpreter
-            {
-                boost::unique_lock<boost::mutex> lock(*this->mainInterpreterMutex_);
-            }
-
-            // Lock the mutex again to gain exclusive access to the interpreter for the rest of the mainloop
-            bundle->lock_->lock();
-
-            // Execute commands in the queues of the threaded interpreters
-            {
-                boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
-                for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
-                {
-                    if (it->first == 0)
-                        continue; // We'll handle the default interpreter later (and without threads of course)
-
-                    TclInterpreterBundle* bundle = it->second;
-                    if (!bundle->queue_.empty())
-                    {
-                        // There are commands in the queue
-                        try
-                        {
-                            if (!bundle->lock_->owns_lock() && bundle->lock_->try_lock())
-                            {
-                                // We sucessfully obtained a lock for the interpreter
-                                std::string command;
-                                if (bundle->queue_.try_pop_front(&command))
-                                {
-                                    // Start a thread to execute the command
-                                    boost::thread(boost::bind(&tclThread, bundle, command));
-                                }
-                                else
-                                {
-                                    // Somehow the queue become empty (maybe multiple consumers) - unlock the mutex
-                                    bundle->lock_->unlock();
-                                }
-                            }
-                        }
-                        catch (...)
-                        {
-                            // A lock error occurred - this is possible if the lock gets locked between !bundle->lock_->owns_lock() and bundle->lock_->try_lock()
-                            // This isn't too bad, just continue
-                        }
-                    }
-                }
-            }
-
-            // Execute commands in the message queue
-            if (!this->messageQueue_->empty())
-            {
-                std::string command;
-                while (true)
-                {
-                    // Pop the front value from the list (break the loop if there are no elements in the list)
-                    if (!this->messageQueue_->try_pop_front(&command))
-                        break;
-
-                    // Execute the command
-                    CommandExecutor::execute(command, false);
-                }
-            }
-
-            // Execute commands in the queue of the main interpreter
-            if (!bundle->queue_.empty())
-            {
-                // Calculate the time we have until we reach the maximal cpu usage
-                unsigned long maxtime = (unsigned long)(time.getDeltaTime() * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
-
-                Ogre::Timer timer;
-                std::string command;
-
-                while (timer.getMicroseconds() < maxtime)
-                {
-                    // Pop the front value from the list (break the loop if there are no elements in the list)
-                    if (!bundle->queue_.try_pop_front(&command))
-                        break;
-
-                    // Execute the command
-                    CommandExecutor::execute(command, false);
-                }
-            }
-        }
-    }
-
-    /**
-        @brief Creates a new Tcl-interpreter.
-    */
-    unsigned int TclThreadManager::create()
-    {
-        TclThreadManager::getInstance().numInterpreterBundles_++;
-        TclThreadManager::createWithId(TclThreadManager::getInstance().numInterpreterBundles_);
-        COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().numInterpreterBundles_ << std::endl;
-        return TclThreadManager::getInstance().numInterpreterBundles_;
-    }
-
-    /**
-        @brief Creates a new Tcl-interpreter with a given id.
-
-        Use with caution - if the id collides with an already existing interpreter, this call will fail.
-        This will also be a problem, if the auto-numbered interpreters (by using create()) reach an id
-        which was previously used in this function. Use high numbers to be safe.
-    */
-    Tcl::interpreter* TclThreadManager::createWithId(unsigned int id)
-    {
-        TclInterpreterBundle* newbundle = new TclInterpreterBundle();
-        newbundle->id_ = id;
-        newbundle->interpreter_ = TclBind::createTclInterpreter();
-
-        TclThreadManager::initialize(newbundle);
-
-        {
-            // Add the new bundle to the map
-            boost::unique_lock<boost::shared_mutex> lock(*TclThreadManager::getInstance().interpreterBundlesMutex_);
-            TclThreadManager::getInstance().interpreterBundles_[id] = newbundle;
-        }
-
-        return newbundle->interpreter_;
-    }
-
-    void TclThreadManager::initialize(TclInterpreterBundle* bundle)
-    {
-        const std::string& id_string = getConvertedValue<unsigned int, std::string>(bundle->id_);
-
-        // Initialize the new interpreter
-        try
-        {
-            // Define the functions which are implemented in C++
-            bundle->interpreter_->def("::orxonox::execute",      TclThreadManager::tcl_execute,      Tcl::variadic());
-            bundle->interpreter_->def("::orxonox::crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic());
-            bundle->interpreter_->def("::orxonox::query",        TclThreadManager::tcl_query,        Tcl::variadic());
-            bundle->interpreter_->def("::orxonox::crossquery",   TclThreadManager::tcl_crossquery,   Tcl::variadic());
-            bundle->interpreter_->def("::orxonox::running",      TclThreadManager::tcl_running);
-
-            // Create threadspecific shortcuts for the functions above
-            bundle->interpreter_->def("execute",      TclThreadManager::tcl_execute,      Tcl::variadic());
-            bundle->interpreter_->def("crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic());
-            bundle->interpreter_->eval("proc query      {args}    { ::orxonox::query " + id_string + " $args }");
-            bundle->interpreter_->eval("proc crossquery {id args} { ::orxonox::crossquery " + id_string + " $id $args }");
-            bundle->interpreter_->eval("proc running    {}        { return [::orxonox::running " + id_string + "] }");
-
-            // Define a variable containing the thread id
-            bundle->interpreter_->eval("set id " + id_string);
-
-            // Use our own exit function to avoid shutting down the whole program instead of just the interpreter
-            bundle->interpreter_->eval("rename exit ::tcl::exit");
-            bundle->interpreter_->eval("proc exit {} { execute TclThreadManager destroy " + id_string + " }");
-
-            // Redefine some native functions
-            bundle->interpreter_->eval("rename while ::tcl::while");
-            bundle->interpreter_->eval("rename ::orxonox::while while");
-            bundle->interpreter_->eval("rename for ::tcl::for");
-            bundle->interpreter_->eval("rename ::orxonox::for for");
-        }
-        catch (const Tcl::tcl_error& e)
-        {   bundle->interpreter_ = 0; COUT(1) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl;   }
-    }
-
-    /**
-        @brief Stops and destroys a given Tcl-interpreter
-    */
-    void TclThreadManager::destroy(unsigned int id)
-    {
-        // TODO
-        // Not yet implemented
-        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(id);
-        if (bundle)
-        {
-            bundle->bRunning_ = false;
-        }
-    }
-
-    /**
-        @brief Sends a command to the queue of a given Tcl-interpreter
-        @param id The id of the target interpreter
-        @param command The command to be sent
-    */
-    void TclThreadManager::execute(unsigned int target_id, const std::string& command)
-    {
-        TclThreadManager::getInstance()._execute(target_id, command);
-    }
-
-    /**
-        @brief This function can be called from Tcl to execute a console command.
-
-        Commands which shall be executed are put into a queue and processed as soon as the
-        main thread feels ready to do so. The queue may also be full which results in a temporary
-        suspension of the calling thread until the queue gets ready again.
-    */
-    void TclThreadManager::tcl_execute(const Tcl::object& args)
-    {
-        TclThreadManager::getInstance()._execute(0, stripEnclosingBraces(args.get()));
-    }
-
-    /**
-        @brief This function can be called from Tcl to send a command to the queue of any interpreter.
-        @param target_id The id of the target thread
-    */
-    void TclThreadManager::tcl_crossexecute(int target_id, const Tcl::object& args)
-    {
-        TclThreadManager::getInstance()._execute(static_cast<unsigned int>(target_id), stripEnclosingBraces(args.get()));
-    }
-
-    /**
-        @brief Sends a command to the queue of a given Tcl-interpreter
-        @param id The id of the target interpreter
-        @param command The command to be sent
-    */
-    void TclThreadManager::_execute(unsigned int target_id, const std::string& command)
-    {
-        TclInterpreterBundle* bundle = this->getInterpreterBundle(target_id);
-        if (bundle)
-            bundle->queue_.push_back(command);
-    }
-
-
-    /**
-        @brief Sends a query to a given Tcl-interpreter and waits for the result
-        @param id The id of the target interpreter
-        @param command The command to be sent
-        @return The result of the command
-    */
-    std::string TclThreadManager::query(unsigned int target_id, const std::string& command)
-    {
-        return TclThreadManager::getInstance()._query(0, target_id, command);
-    }
-
-    /**
-        @brief This function can be called from Tcl to send a query to the main thread.
-        @param source_id The id of the calling thread
-
-        A query waits for the result of the command. This means, the calling thread will be blocked until
-        the main thread answers the query. In return, the main thread sends the result of the console
-        command back to Tcl.
-    */
-    std::string TclThreadManager::tcl_query(int source_id, const Tcl::object& args)
-    {
-        return TclThreadManager::getInstance()._query(static_cast<unsigned int>(source_id), 0, stripEnclosingBraces(args.get()), true);
-    }
-
-    /**
-        @brief This function can be called from Tcl to send a query to another thread.
-        @param source_id The id of the calling thread
-        @param target_id The id of the target thread
-    */
-    std::string TclThreadManager::tcl_crossquery(int source_id, int target_id, const Tcl::object& args)
-    {
-        return TclThreadManager::getInstance()._query(static_cast<unsigned int>(source_id), static_cast<unsigned int>(target_id), stripEnclosingBraces(args.get()));
-    }
-
-    /**
-        @brief This function performs a query to any Tcl interpreter
-        @param source_id The id of the calling thread
-        @param target_id The id of the target thread
-        @param command The command to send as a query
-        @param bUseCommandExecutor Only used if the target_id is 0 (which references the main interpreter). In this case it means if the command should be passed to the CommandExecutor (true) or to the main Tcl interpreter (false). This is true when called by tcl_query and false when called by tcl_crossquery.
-    */
-    std::string TclThreadManager::_query(unsigned int source_id, unsigned int target_id, const std::string& command, bool bUseCommandExecutor)
-    {
-        TclInterpreterBundle* source_bundle = this->getInterpreterBundle(source_id);
-        TclInterpreterBundle* target_bundle = this->getInterpreterBundle(target_id);
-        std::string output;
-
-        if (source_bundle && target_bundle)
-        {
-            // At this point we assume the mutex of source_bundle to be locked (because it's executing this query right now an waits for the return value)
-            // We can safely use it's querier list (because there's no other place in the code using the list except this query - and the interpreter can't start more than one query)
-
-            if ((source_bundle->id_ == target_bundle->id_) || source_bundle->queriers_.is_in(target_bundle->id_))
-            {
-                // 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_) \
-                            + " -> " + 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_) + '.');
-            }
-            else
-            {
-                boost::unique_lock<boost::mutex> lock(target_bundle->mutex_, boost::try_to_lock);
-                boost::unique_lock<boost::mutex> mainlock(*this->mainInterpreterMutex_, boost::defer_lock);
-
-                if (!lock.owns_lock() && source_bundle->id_ != 0)
-                {
-                    // We couldn't obtain the try_lock immediately and we're not the main interpreter - wait until the lock becomes possible (note: the main interpreter won't wait and instead returns an error - see below)
-                    if (target_bundle->id_ == 0)
-                    {
-                        // We're querying the main interpreter - use the main interpreter mutex to synchronize
-                        mainlock.lock();
-                        lock.lock();
-                    }
-                    else
-                    {
-                        // We're querying a threaded interpreter - no synchronization needed
-                        lock.lock();
-                    }
-                }
-
-                if (lock.owns_lock())
-                {
-                    // Now the mutex of target_bundle is also locked an we can update the querier list
-                    target_bundle->queriers_.insert(target_bundle->queriers_.getList().begin(), source_bundle->queriers_.getList().begin(), source_bundle->queriers_.getList().end());
-                    target_bundle->queriers_.push_back(source_bundle->id_);
-
-                    // Perform the query (note: this happens in the main thread because we need the returnvalue)
-                    if (target_bundle->id_ == 0 && bUseCommandExecutor)
-                    {
-                        // It's a query to the CommandExecutor
-                        TclThreadManager::debug("TclThread_query -> CE: " + command);
-                        if (!CommandExecutor::execute(command, false))
-                            TclThreadManager::error("Error: Can't execute command \"" + command + "\"!");
-
-                        if (CommandExecutor::getLastEvaluation().hasReturnvalue())
-                            output = CommandExecutor::getLastEvaluation().getReturnvalue().getString();
-                    }
-                    else
-                    {
-                        // It's a query to a Tcl interpreter
-                        TclThreadManager::debug("TclThread_query: " + command);
-
-                        output = TclThreadManager::eval(target_bundle, command, "query");
-                    }
-
-                    // Clear the queriers list of the target
-                    target_bundle->queriers_.clear();
-
-                    // Unlock the mutex of the target_bundle
-                    lock.unlock();
-
-                    // Finally unlock the main interpreter lock if necessary
-                    if (mainlock.owns_lock())
-                        mainlock.unlock();
-                }
-                else
-                {
-                    // This happens if the main thread tries to query a busy interpreter
-                    // To avoid a lock of the main thread, we simply don't proceed with the query in this case
-                    TclThreadManager::error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target_bundle->id_) + ", interpreter is busy right now.");
-                }
-            }
-
-        }
-
-        return output;
-    }
-
-    /**
-        @brief Creates a non-interactive Tcl-interpreter which executes a file.
-    */
-    void TclThreadManager::source(const std::string& file)
-    {
-        boost::thread(boost::bind(&sourceThread, file));
-    }
-
-    /**
-        @brief This function can be called from Tcl to ask if the thread is still suposed to be running.
-        @param id The id of the thread in question
-    */
-    bool TclThreadManager::tcl_running(int id)
-    {
-        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(static_cast<unsigned int>(id));
-        if (bundle)
-            return bundle->bRunning_;
-        else
-            return false;
-    }
-
-    /**
-        @brief Returns the interpreter bundle with the given id.
-        @param id The id of the interpreter
-        @return The interpreter or 0 if the id doesn't exist
-    */
-    TclInterpreterBundle* TclThreadManager::getInterpreterBundle(unsigned int id)
-    {
-        boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
-
-        std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.find(id);
-        if (it != this->interpreterBundles_.end())
-        {
-            return it->second;
-        }
-        else
-        {
-            TclThreadManager::error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(id) + " existing.");
-            return 0;
-        }
-    }
-
-    /**
-        @brief Returns a string containing all elements of a unsigned-integer-list separated by spaces.
-    */
-    std::string TclThreadManager::dumpList(const std::list<unsigned int>& list)
-    {
-        std::string output;
-        for (std::list<unsigned int>::const_iterator it = list.begin(); it != list.end(); ++it)
-        {
-            if (it != list.begin())
-                output += ' ';
-
-            output += getConvertedValue<unsigned int, std::string>(*it);
-        }
-        return output;
-    }
-
-    /**
-        @brief Returns a list with the numbers of all existing Tcl-interpreters.
-
-        This function is used by the auto completion function.
-    */
-    std::list<unsigned int> TclThreadManager::getThreadList() const
-    {
-        boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
-
-        std::list<unsigned int> threads;
-        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
-            if (it->first > 0 && it->first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters)
-                threads.push_back(it->first);
-        return threads;
-    }
-
-    /**
-        @brief A helper function to print errors in a thread safe manner.
-    */
-    void TclThreadManager::error(const std::string& error)
-    {
-        TclThreadManager::getInstance().messageQueue_->push_back("error " + error);
-    }
-
-    /**
-        @brief A helper function to print debug information in a thread safe manner.
-    */
-    void TclThreadManager::debug(const std::string& error)
-    {
-        TclThreadManager::getInstance().messageQueue_->push_back("debug " + error);
-    }
-
-    /**
-        @brief Evaluates a Tcl command without throwing exceptions (which may rise problems on certain machines).
-        @return The Tcl return value
-
-        Errors are reported through the @ref error function.
-    */
-    std::string TclThreadManager::eval(TclInterpreterBundle* bundle, const std::string& command, const std::string& action)
-    {
-        Tcl_Interp* interpreter = bundle->interpreter_->get();
-        int cc = Tcl_Eval(interpreter, command.c_str());
-
-        Tcl::details::result result(interpreter);
-
-        if (cc != TCL_OK)
-        {
-            TclThreadManager::error("Tcl error (" + action + ", ID " + getConvertedValue<unsigned int, std::string>(bundle->id_) + "): " + static_cast<std::string>(result));
-            return "";
-        }
-        else
-        {
-            return result;
-        }
-    }
-
-    ////////////////
-    // The Thread //
-    ////////////////
-
-    /**
-        @brief The main function of the thread. Executes a Tcl command.
-        @param bundle The interpreter bundle containing all necessary variables
-        @param command the Command to execute
-    */
-    void tclThread(TclInterpreterBundle* bundle, const std::string& command)
-    {
-        TclThreadManager::debug("TclThread_execute: " + command);
-
-        TclThreadManager::eval(bundle, command, "execute");
-
-        bundle->lock_->unlock();
-    }
-
-    /**
-        @brief The main function of a non-interactive source thread. Executes the file.
-        @param file The name of the file that should be executed by the non-interactive interpreter.
-    */
-    void sourceThread(const std::string& file)
-    {
-        TclThreadManager::debug("TclThread_source: " + file);
-
-        // Prepare the command-line arguments
-        const int argc = 2;
-        char* argv[argc];
-        argv[0] = const_cast<char*>("tclthread");
-        argv[1] = const_cast<char*>(file.c_str());
-
-        // Start the Tcl-command Tcl_Main with the Tcl_OrxonoxAppInit hook
-        Tcl_Main(argc, argv, Tcl_OrxonoxAppInit);
-
-//        Tcl::object object(file);
-//        int cc = Tcl_FSEvalFile(bundle->interpreter_->get(), object.get_object());
-//        Tcl::details::result result(bundle->interpreter_->get());
-//        if (cc != TCL_OK)
-//            TclThreadManager::error("Tcl error (source, ID " + getConvertedValue<unsigned int, std::string>(bundle->id_) + "): " + static_cast<std::string>(result));
-//
-//        // Unlock the mutex
-//        bundle->lock_->unlock();
-    }
-
-    /**
-        @brief A tcl-init hook to inject the non-interactive Tcl-interpreter into the TclThreadManager.
-    */
-    int Tcl_OrxonoxAppInit(Tcl_Interp* interp)
-    {
-        // Create a new interpreter bundle
-        unsigned int id = TclThreadManager::create();
-        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(id);
-
-        // Replace the default interpreter in the bundle with the non-interactive one (passed as an argument to this function)
-        if (bundle->interpreter_)
-            delete bundle->interpreter_;
-        bundle->interpreter_ = new Tcl::interpreter(interp, true);
-
-        // Initialize the non-interactive interpreter (like in @ref TclBind::createTclInterpreter but exception safe)
-        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");
-
-        // Initialize the non-interactive interpreter also with the thread-specific stuff
-        TclThreadManager::initialize(bundle);
-
-        // Lock the mutex (this will be locked until the thread finishes - no chance to interact with the interpreter)
-        bundle->lock_->lock();
-
-        // Return to Tcl_Main
-        if (!bundle->interpreter_)
-            return TCL_ERROR;
-        else
-            return cc;
-    }
-}
Index: code/trunk/src/libraries/core/TclThreadManager.h
===================================================================
--- code/trunk/src/libraries/core/TclThreadManager.h	(revision 7278)
+++ 	(revision )
@@ -1,102 +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:
- *      ...
- *
- */
-
-#ifndef _TclThreadManager_H__
-#define _TclThreadManager_H__
-
-#include "CorePrereqs.h"
-
-#include <cassert>
-#include <list>
-#include <map>
-#include <string>
-
-#include "util/Singleton.h"
-#include "OrxonoxClass.h"
-
-struct Tcl_Interp;
-
-namespace orxonox
-{
-    class _CoreExport TclThreadManager : public Singleton<TclThreadManager>, public OrxonoxClass
-    {
-        friend class Singleton<TclThreadManager>;
-        friend class TclBind;
-        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);
-
-        public:
-            TclThreadManager(Tcl::interpreter* interpreter);
-            virtual ~TclThreadManager();
-
-            static unsigned int      create();
-            static Tcl::interpreter* createWithId(unsigned int id);
-            static void              destroy(unsigned int id);
-            static void              execute(unsigned int target_id, const std::string& command);
-            static std::string       query(unsigned int target_id, const std::string& command);
-            static void              source(const std::string& file);
-
-            static void error(const std::string& error);
-            static void debug(const std::string& error);
-
-            void preUpdate(const Clock& time);
-
-            std::list<unsigned int> getThreadList() const;
-
-        private:
-            static void tcl_execute(const Tcl::object& args);
-            static void tcl_crossexecute(int target_id, const Tcl::object& args);
-            static std::string tcl_query(int source_id, const Tcl::object& args);
-            static std::string tcl_crossquery(int source_id, int target_id, const Tcl::object& args);
-            static bool tcl_running(int id);
-
-            void _execute(unsigned int target_id, const std::string& command);
-            std::string _query(unsigned int source_id, unsigned int target_id, const std::string& command, bool bUseCommandExecutor = false);
-
-            TclInterpreterBundle* getInterpreterBundle(unsigned int id);
-            std::string dumpList(const std::list<unsigned int>& list);
-
-            static void initialize(TclInterpreterBundle* bundle);
-            static std::string eval(TclInterpreterBundle* bundle, const std::string& command, const std::string& action);
-
-            static TclThreadManager* singletonPtr_s;                            ///< Singleton pointer
-
-            unsigned int numInterpreterBundles_;                                ///< Number of created Tcl-interpreters (only used for auto-numbered interpreters, not affected by @ref createWithId)
-            std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;  ///< A map containing all Tcl-interpreters
-            boost::shared_mutex* interpreterBundlesMutex_;                      ///< A mutex used to synchronize threads when accessing @ref interpreterBundles_
-            TclThreadList<std::string>* messageQueue_;                          ///< A queue to pass messages from Tcl-threads to the main thread
-            boost::mutex* mainInterpreterMutex_;                                ///< A mutex to synchronize queries to the main interpreter
-    };
-
-    _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
-    _CoreExport void sourceThread(const std::string& file);
-    _CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
-}
-
-#endif /* _TclThreadManager_H__ */
Index: code/trunk/src/libraries/core/Thread.cc
===================================================================
--- code/trunk/src/libraries/core/Thread.cc	(revision 7278)
+++ code/trunk/src/libraries/core/Thread.cc	(revision 7284)
@@ -36,5 +36,5 @@
 
 #include "util/Sleep.h"
-#include "Executor.h"
+#include "command/Executor.h"
 
 namespace orxonox
@@ -75,5 +75,5 @@
     }
 
-    bool Thread::evaluateExecutor( Executor* executor )
+    bool Thread::evaluateExecutor( const ExecutorPtr& executor )
     {
         this->isWorkingMutex_->lock();
@@ -92,5 +92,5 @@
         {
             //this->executorMutex_->lock();
-            Executor* executor = this->executor_;
+            ExecutorPtr executor = this->executor_;
             //this->executorMutex_->unlock();
             if( executor )
@@ -98,5 +98,4 @@
                 (*executor)();
                 this->executorMutex_->lock();
-                delete this->executor_;
                 this->executor_ = 0;
                 this->executorMutex_->unlock();
Index: code/trunk/src/libraries/core/Thread.h
===================================================================
--- code/trunk/src/libraries/core/Thread.h	(revision 7278)
+++ code/trunk/src/libraries/core/Thread.h	(revision 7284)
@@ -46,15 +46,15 @@
         bool isWorking();
         void waitUntilFinished();
-        bool evaluateExecutor( Executor* executor );
+        bool evaluateExecutor( const ExecutorPtr& executor );
 
     private:
         void            threadLoop();
 
-        Executor*       executor_;
+        ExecutorPtr     executor_;
         bool            isWorking_;
         bool            stopThread_;
         boost::thread*  workerThread_;
         boost::mutex*   executorMutex_;
-        boost::mutex*     isWorkingMutex_;
+        boost::mutex*   isWorkingMutex_;
         boost::mutex*   stopThreadMutex_;
     };
Index: code/trunk/src/libraries/core/ThreadPool.cc
===================================================================
--- code/trunk/src/libraries/core/ThreadPool.cc	(revision 7278)
+++ code/trunk/src/libraries/core/ThreadPool.cc	(revision 7284)
@@ -81,5 +81,5 @@
     }
 
-    bool ThreadPool::passFunction( Executor* executor, bool addThread )
+    bool ThreadPool::passFunction( const ExecutorPtr& executor, bool addThread )
     {
         std::vector<Thread*>::iterator it;
Index: code/trunk/src/libraries/core/ThreadPool.h
===================================================================
--- code/trunk/src/libraries/core/ThreadPool.h	(revision 7278)
+++ code/trunk/src/libraries/core/ThreadPool.h	(revision 7284)
@@ -46,5 +46,5 @@
         unsigned int setNrOfThreads( unsigned int nr );
 
-        bool passFunction( Executor* executor, bool addThread=false );
+        bool passFunction( const ExecutorPtr& executor, bool addThread=false );
         void synchronise();
 
Index: code/trunk/src/libraries/core/WeakPtr.h
===================================================================
--- code/trunk/src/libraries/core/WeakPtr.h	(revision 7278)
+++ code/trunk/src/libraries/core/WeakPtr.h	(revision 7284)
@@ -37,5 +37,5 @@
 #include "Identifier.h"
 #include "OrxonoxClass.h"
-#include "Functor.h"
+#include "command/Functor.h"
 
 namespace orxonox
@@ -78,6 +78,4 @@
                 if (this->base_)
                     this->base_->unregisterWeakPtr(this);
-                if (this->callback_)
-                    delete this->callback_;
 
             }
@@ -169,10 +167,10 @@
             }
 
-            inline void setCallback(Functor* callback)
+            inline void setCallback(const FunctorPtr& callback)
             {
                 this->callback_ = callback;
             }
 
-            inline Functor* getFunctor() const
+            inline const FunctorPtr& getCallback() const
             {
                 return this->callback_;
@@ -190,5 +188,5 @@
             T* pointer_;
             OrxonoxClass* base_;
-            Functor* callback_;
+            FunctorPtr callback_;
     };
 
Index: code/trunk/src/libraries/core/XMLPort.h
===================================================================
--- code/trunk/src/libraries/core/XMLPort.h	(revision 7278)
+++ code/trunk/src/libraries/core/XMLPort.h	(revision 7284)
@@ -53,6 +53,6 @@
 #include "util/StringUtils.h"
 #include "Identifier.h"
-#include "Executor.h"
 #include "BaseObject.h"
+#include "command/Executor.h"
 
 // ------------
@@ -75,6 +75,6 @@
 */
 #define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
 
@@ -94,6 +94,6 @@
 #define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \
     XMLPortVariableHelperClass xmlcontainer##variable##dummy(static_cast<void*>(&variable)); \
-    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader")); \
-    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##saveexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" )); \
+    static ExecutorMemberPtr<orxonox::XMLPortVariableHelperClass> xmlcontainer##variable##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader"); \
+    static ExecutorMemberPtr<orxonox::XMLPortVariableHelperClass> xmlcontainer##variable##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" ); \
     XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode)
 
@@ -110,6 +110,6 @@
 */
 #define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
 
@@ -129,5 +129,5 @@
 */
 #define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
 /**
@@ -135,5 +135,5 @@
 */
 #define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
 
@@ -161,6 +161,6 @@
 */
 #define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \
-    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
-    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
 /**
@@ -168,6 +168,6 @@
 */
 #define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
-    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
-    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
 
@@ -249,6 +249,6 @@
 */
 #define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
 /**
@@ -256,6 +256,6 @@
 */
 #define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
 
@@ -267,6 +267,6 @@
 */
 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
 /**
@@ -274,6 +274,6 @@
 */
 #define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
-    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
 
@@ -317,6 +317,8 @@
                 { return this->paramname_; }
 
-            virtual XMLPortParamContainer& description(const std::string& description) = 0;
-            virtual const std::string& getDescription() = 0;
+            inline XMLPortParamContainer& description(const std::string& description)
+                { this->description_ = description; return *this; }
+            inline const std::string& getDescription() const
+                { return this->description_; }
 
             virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0;
@@ -332,4 +334,5 @@
             Identifier* identifier_;
             BaseObject* owner_;
+            std::string description_;
     };
 
@@ -345,5 +348,5 @@
 
         public:
-            XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
+            XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, const ExecutorMemberPtr<T>& loadexecutor, const ExecutorMemberPtr<T>& saveexecutor)
             {
                 this->paramname_ = paramname;
@@ -355,8 +358,4 @@
             ~XMLPortClassParamContainer()
             {
-                assert(this->loadexecutor_);
-                delete this->loadexecutor_;
-                if (this->saveexecutor_)
-                    delete this->saveexecutor_;
             }
 
@@ -395,5 +394,7 @@
                         {
                             COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
-                            if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode  == XMLPort::ExpandObject))
+                            int error;
+                            this->loadexecutor_->parse(object, attributeValue, &error, ",");
+                            if (!error || (mode  == XMLPort::ExpandObject))
                                 this->parseResult_ = PR_finished;
                             else
@@ -436,9 +437,4 @@
             }
 
-            virtual XMLPortParamContainer& description(const std::string& description)
-                { this->loadexecutor_->setDescription(description); return (*this); }
-            virtual const std::string& getDescription()
-                { return this->loadexecutor_->getDescription(); }
-
             virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param)
             {
@@ -479,6 +475,6 @@
 
         private:
-            ExecutorMember<T>* loadexecutor_;
-            ExecutorMember<T>* saveexecutor_;
+            ExecutorMemberPtr<T> loadexecutor_;
+            ExecutorMemberPtr<T> saveexecutor_;
             ParseParams parseParams_;
     };
@@ -502,6 +498,8 @@
                 { return this->sectionname_; }
 
-            virtual XMLPortObjectContainer& description(const std::string& description) = 0;
-            virtual const std::string& getDescription() = 0;
+            inline XMLPortObjectContainer& description(const std::string& description)
+                { this->description_ = description; return *this; }
+            const std::string& getDescription() const
+                { return this->description_; }
 
             bool identifierIsIncludedInLoaderMask(const Identifier* identifier);
@@ -513,4 +511,5 @@
             Identifier* identifier_;
             Identifier* objectIdentifier_;
+            std::string description_;
     };
 
@@ -519,5 +518,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, const ExecutorMemberPtr<T>& loadexecutor, const ExecutorMemberPtr<T>& saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
             {
                 this->sectionname_ = sectionname;
@@ -533,8 +532,4 @@
             ~XMLPortClassObjectContainer()
             {
-                assert(this->loadexecutor_);
-                delete this->loadexecutor_;
-                if (this->saveexecutor_)
-                    delete this->saveexecutor_;
             }
 
@@ -549,12 +544,7 @@
             }
 
-            virtual XMLPortObjectContainer& description(const std::string& description)
-                { this->loadexecutor_->setDescription(description); return (*this); }
-            virtual const std::string& getDescription()
-                { return this->loadexecutor_->getDescription(); }
-
         private:
-            ExecutorMember<T>* loadexecutor_;
-            ExecutorMember<T>* saveexecutor_;
+            ExecutorMemberPtr<T> loadexecutor_;
+            ExecutorMemberPtr<T> saveexecutor_;
     };
 
Index: code/trunk/src/libraries/core/command/ArgumentCompleter.h
===================================================================
--- code/trunk/src/libraries/core/command/ArgumentCompleter.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/ArgumentCompleter.h	(revision 7284)
@@ -0,0 +1,83 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompleter_H__
+#define _ArgumentCompleter_H__
+
+#include "core/CorePrereqs.h"
+#include "ArgumentCompletionListElement.h"
+
+namespace orxonox
+{
+    class _CoreExport ArgumentCompleter
+    {
+        public:
+            ArgumentCompleter(ArgumentCompletionList (*function) (void), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(0), function_0_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(1), function_1_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(2), function_2_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(3), function_3_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(4), function_4_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(5), function_5_(function) {}
+
+            ArgumentCompletionList operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "")
+            {
+                switch (this->paramCount_)
+                {
+                    case 0:
+                        return (*this->function_0_)();
+                    case 1:
+                        return (*this->function_1_)(param1);
+                    case 2:
+                        return (*this->function_2_)(param1, param2);
+                    case 3:
+                        return (*this->function_3_)(param1, param2, param3);
+                    case 4:
+                        return (*this->function_4_)(param1, param2, param3, param4);
+                    case 5:
+                        return (*this->function_5_)(param1, param2, param3, param4, param5);
+                    default:
+                        return ArgumentCompletionList();
+                }
+            }
+
+            inline bool useMultipleWords() const
+                { return this->bUseMultipleWords_; }
+
+        private:
+            bool bUseMultipleWords_;
+            unsigned char paramCount_;
+            ArgumentCompletionList (*function_0_) (void);
+            ArgumentCompletionList (*function_1_) (const std::string& param1);
+            ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2);
+            ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3);
+            ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4);
+            ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5);
+    };
+}
+
+#endif /* _ArgumentCompleter_H__ */
Index: code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc	(revision 7284)
@@ -0,0 +1,268 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "ArgumentCompletionFunctions.h"
+
+#include <map>
+#include <boost/version.hpp>
+#include <boost/filesystem.hpp>
+
+#include "util/Convert.h"
+#include "util/StringUtils.h"
+#include "core/Identifier.h"
+#include "core/ConfigFileManager.h"
+#include "core/ConfigValueContainer.h"
+#include "CommandExecutor.h"
+#include "ConsoleCommand.h"
+#include "TclThreadManager.h"
+
+// Boost 1.36 has some issues with deprecated functions that have been omitted
+#if (BOOST_VERSION == 103600)
+#  define BOOST_LEAF_FUNCTION filename
+#else
+#  define BOOST_LEAF_FUNCTION leaf
+#endif
+
+namespace orxonox
+{
+    namespace autocompletion
+    {
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(fallback)()
+        {
+            return ArgumentCompletionList();
+        }
+
+        namespace detail
+        {
+            bool groupIsVisible(const std::map<std::string, ConsoleCommand*>& group, bool bOnlyShowHidden)
+            {
+                for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = group.begin(); it_command != group.end(); ++it_command)
+                    if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
+                        return true;
+
+                return false;
+            }
+
+            ArgumentCompletionList _groupsandcommands(const std::string& fragment, bool bOnlyShowHidden)
+            {
+                ArgumentCompletionList groupList;
+                std::string fragmentLC = getLowercase(fragment);
+
+                const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommand::getCommands();
+                for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
+                    if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find_first_of(fragmentLC) == 0))
+                        groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
+
+                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.find("");
+                if (it_group != commands.end())
+                {
+                    if (!groupList.empty())
+                        groupList.push_back(ArgumentCompletionListElement("", "", "\n"));
+
+                    for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
+                        if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find_first_of(fragmentLC) == 0))
+                            groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+                }
+
+                if (!groupList.empty() && groupList.back().getDisplay() == "\n")
+                    groupList.pop_back();
+
+                return groupList;
+            }
+
+            ArgumentCompletionList _subcommands(const std::string& fragment, const std::string& group, bool bOnlyShowHidden)
+            {
+                ArgumentCompletionList commandList;
+
+                std::string groupLC = getLowercase(group);
+
+                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommands().begin();
+                for ( ; it_group != ConsoleCommand::getCommands().end(); ++it_group)
+                    if (getLowercase(it_group->first) == groupLC)
+                        break;
+
+                if (it_group != ConsoleCommand::getCommands().end())
+                {
+                    for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
+                        if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
+                            commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+                }
+
+                return commandList;
+            }
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)(const std::string& fragment)
+        {
+            return detail::_groupsandcommands(fragment, false);
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(subcommands)(const std::string& fragment, const std::string& group)
+        {
+            return detail::_subcommands(fragment, group, false);
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(command)(const std::string& fragment)
+        {
+            CommandEvaluation evaluation = CommandExecutor::evaluate(fragment);
+            const std::string& hint = evaluation.hint();
+
+            if (evaluation.getPossibleArguments().size() > 0 && evaluation.getPossibleArgumentsSize() > 0)
+            {
+                return evaluation.getPossibleArguments();
+            }
+            else
+            {
+                ArgumentCompletionList list;
+                list.push_back(ArgumentCompletionListElement("", "", hint));
+                return list;
+            }
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(hiddencommand)(const std::string& fragment)
+        {
+            SubString tokens(fragment, " ", SubString::WhiteSpaces, false, '\\', true, '"', true, '{', '}', true, '\0');
+
+            if (tokens.size() == 0)
+                return detail::_groupsandcommands(fragment, true);
+
+            if (ConsoleCommand::getCommandLC(getLowercase(tokens[0])))
+                return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
+
+            if (tokens.size() == 1)
+            {
+                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommands().find(tokens[0]);
+                if (it_group != ConsoleCommand::getCommands().end())
+                    return detail::_subcommands(fragment, tokens[0], true);
+                else
+                    return detail::_groupsandcommands(fragment, true);
+            }
+
+            if (ConsoleCommand::getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))
+                return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
+
+            return ArgumentCompletionList();
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment)
+        {
+            ArgumentCompletionList dirlist;
+            ArgumentCompletionList filelist;
+
+            try
+            {
+                boost::filesystem::path input(fragment);
+                boost::filesystem::path startdirectory(input.branch_path());
+
+                if (!boost::filesystem::exists(startdirectory))
+                {
+                    startdirectory = ".";
+                }
+#ifdef ORXONOX_PLATFORM_WINDOWS
+                else
+                {
+                    const std::string& dir = startdirectory.string();
+                    if (dir.size() > 0 && dir[dir.size() - 1] == ':')
+                        startdirectory = dir + '/';
+                }
+#endif
+
+                boost::filesystem::directory_iterator file(startdirectory);
+                boost::filesystem::directory_iterator end;
+
+                while (file != end)
+                {
+                    if (boost::filesystem::is_directory(*file))
+                        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()));
+                    ++file;
+                }
+            }
+            catch (...) {}
+
+            filelist.insert(filelist.begin(), dirlist.begin(), dirlist.end());
+            return filelist;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingssections)()
+        {
+            ArgumentCompletionList sectionList;
+
+            const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames();
+            for (std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
+                sectionList.push_back(ArgumentCompletionListElement(*it, getLowercase(*it)));
+
+            return sectionList;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsentries)(const std::string& fragment, const std::string& section)
+        {
+            ArgumentCompletionList entryList;
+            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
+            const std::string& sectionLC = getLowercase(section);
+
+            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
+            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
+                entryList.push_back(ArgumentCompletionListElement(it->second.second->getName(), it->second.first));
+
+            return entryList;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section)
+        {
+            ArgumentCompletionList oldValue;
+            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
+            const std::string& sectionLC = getLowercase(section);
+            const std::string& entryLC = getLowercase(entry);
+
+            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
+            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
+            {
+                if (it->second.first == entryLC)
+                {
+                    const std::string& valuestring = it->second.second->toString();
+                    oldValue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
+                }
+            }
+
+            return oldValue;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(tclthreads)()
+        {
+            std::list<unsigned int> threadnumbers = TclThreadManager::getInstance().getThreadList();
+            ArgumentCompletionList threads;
+
+            for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
+                threads.push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));
+
+            return threads;
+        }
+    }
+}
Index: code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.h
===================================================================
--- code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.h	(revision 7284)
@@ -0,0 +1,74 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompletionFunctions_H__
+#define _ArgumentCompletionFunctions_H__
+
+#include "core/CorePrereqs.h"
+#include "ArgumentCompleter.h"
+
+
+#define ARGUMENT_COMPLETION_FUNCTION_DECLARATION(functionname) \
+    _CoreExport ArgumentCompleter* functionname(); \
+    _CoreExport ArgumentCompletionList acf_##functionname
+
+#define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(functionname) \
+    _ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_INTERNAL(functionname, false)
+#define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(functionname) \
+    _ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_INTERNAL(functionname, true)
+
+#define _ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_INTERNAL(functionname, bUseMultipleWords) \
+    ArgumentCompleter* functionname() \
+    { \
+        static ArgumentCompleter completer = ArgumentCompleter(&acf_##functionname, bUseMultipleWords); \
+        return &completer; \
+    } \
+    \
+    ArgumentCompletionList acf_##functionname
+
+#define ARGUMENT_COMPLETION_FUNCTION_CALL(functionname) acf_##functionname
+
+
+namespace orxonox
+{
+    namespace autocompletion
+    {
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(groupsandcommands)(const std::string& fragment);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(subcommands)(const std::string& fragment, const std::string& group);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(command)(const std::string& fragment);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(hiddencommand)(const std::string& fragment);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingssections)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsentries)(const std::string& fragment, const std::string& section);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(tclthreads)();
+    }
+}
+
+#endif /* _ArgumentCompletionFunctions_H__ */
Index: code/trunk/src/libraries/core/command/ArgumentCompletionListElement.h
===================================================================
--- code/trunk/src/libraries/core/command/ArgumentCompletionListElement.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/ArgumentCompletionListElement.h	(revision 7284)
@@ -0,0 +1,75 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompletionListElement_H__
+#define _ArgumentCompletionListElement_H__
+
+#include "core/CorePrereqs.h"
+
+#include <list>
+#include <string>
+
+namespace orxonox
+{
+    const int ACL_MODE_NORMAL    = 1;
+    const int ACL_MODE_COMPARABLE = 2;
+    const int ACL_MODE_DISPLAY   = 4;
+
+    typedef std::list<ArgumentCompletionListElement> ArgumentCompletionList;
+
+    class _CoreExport ArgumentCompletionListElement
+    {
+        public:
+            ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normal_(normalcase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE), normal_(normalcase), comparable_(lowercase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE | ACL_MODE_DISPLAY), normal_(normalcase), comparable_(lowercase), display_(display) {}
+
+            const std::string& getString() const
+                { return this->normal_; }
+            const std::string& getComparable() const
+                { return (this->mode_ & ACL_MODE_COMPARABLE) ? this->comparable_ : this->normal_; }
+            const std::string& getDisplay() const
+                { return (this->mode_ & ACL_MODE_DISPLAY) ? this->display_ : this->normal_; }
+
+            bool hasComparable() const
+                { return (this->mode_ & ACL_MODE_COMPARABLE); }
+            bool hasDisplay() const
+                { return (this->mode_ & ACL_MODE_DISPLAY); }
+
+            bool operator<(const ArgumentCompletionListElement& other) const
+                { return (this->getComparable() < other.getComparable()); }
+
+        private:
+            unsigned char mode_;
+            std::string normal_;
+            std::string comparable_;
+            std::string display_;
+    };
+}
+
+#endif /* _ArgumentCompletionListElement_H__ */
Index: code/trunk/src/libraries/core/command/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/command/CMakeLists.txt	(revision 7284)
+++ code/trunk/src/libraries/core/command/CMakeLists.txt	(revision 7284)
@@ -0,0 +1,11 @@
+ADD_SOURCE_FILES(CORE_SRC_FILES
+  CommandEvaluation.cc
+  CommandExecutor.cc
+  ConsoleCommand.cc
+  ConsoleCommandCompilation.cc
+  Executor.cc
+  IOConsole.cc
+  IRC.cc
+  Shell.cc
+  TclBind.cc
+)
Index: code/trunk/src/libraries/core/command/CommandEvaluation.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandEvaluation.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/CommandEvaluation.cc	(revision 7284)
@@ -0,0 +1,446 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "CommandEvaluation.h"
+
+#include "util/StringUtils.h"
+#include "CommandExecutor.h"
+#include "ConsoleCommand.h"
+
+namespace orxonox
+{
+    CommandEvaluation::CommandEvaluation()
+    {
+        this->initialize("");
+    }
+
+    void CommandEvaluation::initialize(const std::string& command)
+    {
+        this->execCommand_ = 0;
+        this->hintCommand_ = 0;
+        this->string_ = command;
+        this->execArgumentsOffset_ = 0;
+        this->hintArgumentsOffset_ = 0;
+        this->bPossibleArgumentsRetrieved_ = false;
+        this->possibleArguments_.clear();
+        this->bEvaluatedParams_ = false;
+        this->bTriedToEvaluatedParams_ = false;
+        this->numberOfEvaluatedParams_ = 0;
+
+        this->tokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', true, '"', true, '{', '}', true, '\0');
+    }
+
+    unsigned int CommandEvaluation::getNumberOfArguments() const
+    {
+        unsigned int count = this->tokens_.size();
+        if (count > 0 && this->string_[this->string_.size() - 1] != ' ')
+            return count;
+        else
+            return count + 1;
+    }
+
+    const std::string& CommandEvaluation::getLastArgument() const
+    {
+        if (this->tokens_.size() > 0 && this->string_[this->string_.size() - 1] != ' ')
+            return this->tokens_.back();
+        else
+            return BLANKSTRING;
+    }
+
+    const std::string& CommandEvaluation::getToken(unsigned int i) const
+    {
+        if (i < this->tokens_.size())
+            return this->tokens_[i];
+        else
+            return BLANKSTRING;
+    }
+
+    int CommandEvaluation::execute()
+    {
+        int error;
+        this->query(&error);
+        return error;
+    }
+
+    MultiType CommandEvaluation::query(int* error)
+    {
+        if (error)
+        {
+            *error = CommandExecutor::Success;
+
+            if (!this->execCommand_)
+                *error = CommandExecutor::Error;
+            else if (!this->execCommand_->isActive())
+                *error = CommandExecutor::Deactivated;
+            else if (!this->execCommand_->hasAccess())
+                *error = CommandExecutor::Denied;
+
+            if (*error != CommandExecutor::Success)
+                return MT_Type::Null;
+        }
+
+        if (this->execCommand_ && this->execCommand_->isActive() && this->execCommand_->hasAccess())
+        {
+            if (!this->bTriedToEvaluatedParams_)
+                this->evaluateParams(false);
+
+            if (this->bEvaluatedParams_)
+            {
+                COUT(6) << "CE_execute (evaluation): " << this->execCommand_->getName() << " with " << this->numberOfEvaluatedParams_ << " params: " << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl;
+                switch (this->numberOfEvaluatedParams_)
+                {
+                    case 0:  return (*this->execCommand_->getExecutor())();
+                    case 1:  return (*this->execCommand_->getExecutor())(this->param_[0]);
+                    case 2:  return (*this->execCommand_->getExecutor())(this->param_[0], this->param_[1]);
+                    case 3:  return (*this->execCommand_->getExecutor())(this->param_[0], this->param_[1], this->param_[2]);
+                    case 4:  return (*this->execCommand_->getExecutor())(this->param_[0], this->param_[1], this->param_[2], this->param_[3]);
+                    case 5:
+                    default: return (*this->execCommand_->getExecutor())(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
+                }
+            }
+            else if (error)
+                *error = CommandExecutor::Incomplete;
+        }
+
+        return MT_Type::Null;
+    }
+
+    int CommandEvaluation::evaluateParams(bool bPrintError)
+    {
+        this->bTriedToEvaluatedParams_ = true;
+
+        if (!this->execCommand_)
+        {
+            if (bPrintError)
+                COUT(1) << "Error: Can't evaluate params, no console command assigned." << std::endl;
+            return CommandExecutor::Error;
+        }
+
+        int error;
+        this->numberOfEvaluatedParams_ = this->execCommand_->getExecutor()->evaluateParams(this->tokens_.subSet(this->execArgumentsOffset_), this->param_, &error, " ");
+        if (!error)
+            this->bEvaluatedParams_ = true;
+        else if (bPrintError)
+            COUT(1) << "Error: Can't evaluate params, not enough arguments given." << std::endl;
+
+        return error;
+    }
+
+    void CommandEvaluation::setEvaluatedParameter(unsigned int index, const MultiType& param)
+    {
+        if (index < MAX_FUNCTOR_ARGUMENTS)
+            this->param_[index] = param;
+    }
+
+    MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const
+    {
+        if (index < MAX_FUNCTOR_ARGUMENTS)
+            return this->param_[index];
+
+        return MT_Type::Null;
+    }
+
+    std::string CommandEvaluation::complete()
+    {
+        if (!this->hintCommand_ || !this->hintCommand_->isActive())
+            return this->string_;
+
+        if (!this->bPossibleArgumentsRetrieved_)
+            this->retrievePossibleArguments();
+
+        if (CommandEvaluation::getSize(this->possibleArguments_) == 0)
+        {
+            return this->string_;
+        }
+        else
+        {
+            std::string output = this->string_.substr(0, this->string_.find_last_of(' ') + 1);
+            output += CommandEvaluation::getCommonBegin(this->possibleArguments_);
+            return output;
+        }
+    }
+
+    std::string CommandEvaluation::hint()
+    {
+        if (!this->hintCommand_ || !this->hintCommand_->isActive())
+            return "";
+
+        if (!this->bPossibleArgumentsRetrieved_)
+            this->retrievePossibleArguments();
+
+        if (CommandEvaluation::getSize(this->possibleArguments_) > 0 || (!this->possibleArguments_.empty() && this->isValid()))
+            return CommandEvaluation::dump(this->possibleArguments_);
+
+        if (this->isValid())
+        {
+            return CommandEvaluation::dump(this->hintCommand_);
+        }
+        else
+        {
+            if (this->getNumberOfArguments() > 2)
+            {
+                return std::string("Error: There is no command with name \"") + this->getToken(0) + " " + this->getToken(1) + "\".";
+            }
+            else
+            {
+                std::string groupLC = getLowercase(this->getToken(0));
+                for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)
+                    if (it_group->first == groupLC)
+                        return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\".";
+
+                return std::string("Error: There is no command starting with \"") + this->getToken(0) + "\".";
+            }
+        }
+    }
+
+    std::string CommandEvaluation::getCommandSuggestion() const
+    {
+        std::string token0_LC = getLowercase(this->getToken(0));
+        std::string token1_LC = getLowercase(this->getToken(1));
+
+        std::string nearestCommand;
+        unsigned int nearestDistance = (unsigned int)-1;
+
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)
+        {
+            if (it_group->first != "")
+            {
+                for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
+                {
+                    std::string command = it_group->first + " " + it_name->first;
+                    unsigned int distance = getLevenshteinDistance(command, token0_LC + " " + token1_LC);
+                    if (distance < nearestDistance)
+                    {
+                        nearestCommand = command;
+                        nearestDistance = distance;
+                    }
+                }
+            }
+        }
+
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().find("");
+        if (it_group !=  ConsoleCommand::getCommandsLC().end())
+        {
+            for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
+            {
+                std::string command = it_name->first;
+                unsigned int distance = getLevenshteinDistance(command, token0_LC);
+                if (distance < nearestDistance)
+                {
+                    nearestCommand = command;
+                    nearestDistance = distance;
+                }
+            }
+        }
+
+        return nearestCommand;
+    }
+
+    void CommandEvaluation::retrievePossibleArguments()
+    {
+        this->bPossibleArgumentsRetrieved_ = true;
+        unsigned int argumentID = std::min(this->getNumberOfArguments() - this->hintArgumentsOffset_, this->hintCommand_->getExecutor()->getParamCount());
+        ArgumentCompleter* ac = this->hintCommand_->getArgumentCompleter(argumentID - 1);
+
+        if (ac)
+        {
+            MultiType param[MAX_FUNCTOR_ARGUMENTS];
+
+            size_t max = this->hintArgumentsOffset_ + this->hintCommand_->getExecutor()->getParamCount();
+
+            for (size_t i = 0; i < argumentID; ++i)
+                param[i] = this->getToken(std::min(this->getNumberOfArguments(), max) - i - 1);
+
+            if (this->getNumberOfArguments() > max)
+            {
+                if (ac->useMultipleWords())
+                {
+                    std::string surplusArguments = this->tokens_.subSet(max - 1).join();
+                    if (this->string_[this->string_.size() - 1] == ' ')
+                        surplusArguments += ' ';
+
+                    this->possibleArguments_ = (*ac)(surplusArguments, param[1], param[2], param[3], param[4]);
+                    CommandEvaluation::strip(this->possibleArguments_, this->getToken(this->getNumberOfArguments() - 1));
+                }
+            }
+            else
+            {
+                this->possibleArguments_ = (*ac)(param[0], param[1], param[2], param[3], param[4]);
+                CommandEvaluation::strip(this->possibleArguments_, param[0]);
+            }
+        }
+    }
+
+    /* static */ size_t CommandEvaluation::getSize(const ArgumentCompletionList& list)
+    {
+        size_t count = 0;
+        for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+            if (it->getComparable() != "")
+                ++count;
+        return count;
+    }
+
+    /* static */ void CommandEvaluation::strip(ArgumentCompletionList& list, const std::string& fragment)
+    {
+        std::string fragmentLC = getLowercase(fragment);
+
+        for (ArgumentCompletionList::iterator it = list.begin(); it != list.end(); )
+        {
+            const std::string& entry = it->getComparable();
+
+            if (entry == "")
+            {
+                ++it;
+                continue;
+            }
+
+            if (entry.size() < fragmentLC.size())
+            {
+                list.erase(it++);
+            }
+            else
+            {
+                bool bErase = false;
+                for (size_t i = 0; i < fragmentLC.size(); ++i)
+                {
+                    if (fragmentLC[i] != entry[i])
+                    {
+                        bErase = true;
+                        break;
+                    }
+                }
+
+                if (bErase)
+                    list.erase(it++);
+                else
+                    ++it;
+            }
+        }
+    }
+
+    /* static */ std::string CommandEvaluation::getCommonBegin(const ArgumentCompletionList& list)
+    {
+        if (CommandEvaluation::getSize(list) == 0)
+        {
+            return "";
+        }
+        else if (CommandEvaluation::getSize(list) == 1)
+        {
+            for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+            {
+                if (it->getComparable() != "")
+                {
+                    if (it->hasDisplay())
+                        return (it->getString());
+                    else
+                        return (it->getString() + ' ');
+                }
+            }
+
+            return "";
+        }
+        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)
+                {
+                    const std::string& argumentComparable = it->getComparable();
+                    const std::string& argument = it->getString();
+
+                    if (argumentComparable == "")
+                        continue;
+
+                    if (argument.size() > i)
+                    {
+                        if (tempComparable == 0)
+                        {
+                            tempComparable = argumentComparable[i];
+                            temp = argument[i];
+                        }
+                        else
+                        {
+                            if (tempComparable != argumentComparable[i])
+                                return output;
+                            else if (temp != argument[i])
+                                temp = tempComparable;
+                        }
+                    }
+                    else
+                    {
+                        return output;
+                    }
+                }
+                output += temp;
+            }
+            return output;
+        }
+    }
+
+    /* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
+    {
+        std::string output;
+        for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            output += it->getDisplay();
+
+            if (it->getComparable() != "")
+                output += ' ';
+        }
+        return output;
+    }
+
+    /* static */ std::string CommandEvaluation::dump(const ConsoleCommand* command)
+    {
+        std::string output = command->getName();
+        if (command->getExecutor()->getParamCount() > 0)
+            output += ": ";
+
+        for (unsigned int i = 0; i < command->getExecutor()->getParamCount(); i++)
+        {
+            if (i != 0)
+                output += ' ';
+
+            if (command->getExecutor()->defaultValueSet(i))
+                output += '[';
+            else
+                output += '{';
+
+            output += command->getExecutor()->getTypenameParam(i);
+
+            if (command->getExecutor()->defaultValueSet(i))
+                output += '=' + command->getExecutor()->getDefaultValue(i).getString() + ']';
+            else
+                output += '}';
+        }
+        return output;
+    }
+}
Index: code/trunk/src/libraries/core/command/CommandEvaluation.h
===================================================================
--- code/trunk/src/libraries/core/command/CommandEvaluation.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/CommandEvaluation.h	(revision 7284)
@@ -0,0 +1,108 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _CommandEvaluation_H__
+#define _CommandEvaluation_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+
+#include "util/SubString.h"
+#include "util/MultiType.h"
+#include "ArgumentCompletionListElement.h"
+#include "Functor.h"
+
+namespace orxonox
+{
+    class _CoreExport CommandEvaluation
+    {
+        friend class CommandExecutor;
+
+        public:
+            CommandEvaluation();
+
+            int execute();
+            MultiType query(int* error = 0);
+
+            std::string complete();
+            std::string hint();
+
+            std::string getCommandSuggestion() const;
+
+            int evaluateParams(bool bPrintError = false);
+
+            inline bool isValid() const
+                { return (this->execCommand_ != 0); }
+
+            inline const ConsoleCommand* getConsoleCommand() const
+                { return this->execCommand_; }
+
+            void setEvaluatedParameter(unsigned int index, const MultiType& param);
+            MultiType getEvaluatedParameter(unsigned int index) const;
+
+            const ArgumentCompletionList& getPossibleArguments() const
+                { return this->possibleArguments_; }
+
+            size_t getPossibleArgumentsSize() const
+                { return CommandEvaluation::getSize(this->possibleArguments_); }
+
+        private:
+            void initialize(const std::string& command);
+
+            unsigned int getNumberOfArguments() const;
+            const std::string& getLastArgument() const;
+            const std::string& getToken(unsigned int i) const;
+
+            void retrievePossibleArguments();
+
+            static void strip(ArgumentCompletionList& list, const std::string& fragment);
+            static size_t getSize(const ArgumentCompletionList& list);
+
+            static std::string dump(const ArgumentCompletionList& list);
+            static std::string dump(const ConsoleCommand* command);
+
+            static std::string getCommonBegin(const ArgumentCompletionList& list);
+
+            const ConsoleCommand* execCommand_;
+            const ConsoleCommand* hintCommand_;
+            SubString tokens_;
+            std::string string_;
+            unsigned int execArgumentsOffset_;
+            unsigned int hintArgumentsOffset_;
+            bool bPossibleArgumentsRetrieved_;
+            ArgumentCompletionList possibleArguments_;
+
+            bool bEvaluatedParams_;
+            bool bTriedToEvaluatedParams_;
+            unsigned int numberOfEvaluatedParams_;
+            MultiType param_[MAX_FUNCTOR_ARGUMENTS];
+    };
+}
+
+#endif /* _CommandEvaluation_H__ */
Index: code/trunk/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandExecutor.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/CommandExecutor.cc	(revision 7284)
@@ -0,0 +1,194 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "CommandExecutor.h"
+
+#include "ConsoleCommand.h"
+#include "TclBind.h"
+#include "Shell.h"
+
+namespace orxonox
+{
+    static const std::string __CC_CommandExecutor_name = "CommandExecutor";
+    static const std::string __CC_autocomplete_name = "autocomplete";
+
+    SetConsoleCommand(__CC_CommandExecutor_name, __CC_autocomplete_name, &CommandExecutor::_autocomplete)
+        .hide()
+        .argumentCompleter(0, autocompletion::groupsandcommands())
+        .argumentCompleter(1, autocompletion::subcommands());
+
+    SetConsoleCommand("unhide", &CommandExecutor::unhide)
+        .argumentCompleter(0, autocompletion::hiddencommand());
+
+    SetConsoleCommand("alias", &CommandExecutor::alias)
+        .argumentCompleter(1, autocompletion::command());
+
+    /* static */ CommandExecutor& CommandExecutor::getInstance()
+    {
+        static CommandExecutor instance;
+        return instance;
+    }
+
+    /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl)
+    {
+        int error;
+        CommandExecutor::queryMT(command, &error, useTcl);
+        return error;
+    }
+
+    /* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl)
+    {
+        if (useTcl)
+            return TclBind::eval(command, error);
+        else
+        {
+            CommandEvaluation evaluation;
+            if (!CommandExecutor::getInstance().getCached(command, evaluation))
+            {
+                evaluation = CommandExecutor::evaluate(command);
+                evaluation.evaluateParams();
+                CommandExecutor::getInstance().cache(command, evaluation);
+            }
+
+            return evaluation.query(error);
+        }
+    }
+
+    /* static */ std::string CommandExecutor::query(const std::string& command, int* error, bool useTcl)
+    {
+        return CommandExecutor::queryMT(command, error, useTcl).getString();
+    }
+
+    /* static */ CommandEvaluation CommandExecutor::evaluate(const std::string& command)
+    {
+        CommandEvaluation evaluation;
+        evaluation.initialize(command);
+
+        evaluation.hintCommand_ = ConsoleCommand::getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name);
+
+        if (evaluation.getNumberOfArguments() >= 1)
+        {
+            evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0));
+            if (evaluation.execCommand_)
+                evaluation.execArgumentsOffset_ = 1;
+            else if (evaluation.getNumberOfArguments() >= 2)
+            {
+                evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0), evaluation.getToken(1));
+                if (evaluation.execCommand_)
+                    evaluation.execArgumentsOffset_ = 2;
+            }
+        }
+
+        if (evaluation.execCommand_ && evaluation.getNumberOfArguments() > evaluation.execArgumentsOffset_)
+        {
+            evaluation.hintCommand_ = evaluation.execCommand_;
+            evaluation.hintArgumentsOffset_ = evaluation.execArgumentsOffset_;
+        }
+
+        return evaluation;
+    }
+
+    bool CommandExecutor::getCached(const std::string& command, CommandEvaluation& evaluation)
+    {
+        if (Shell::getCacheSize() == 0)
+            return false;
+
+        std::map<std::string, CacheEntry>::iterator it = this->cache_.find(command);
+        if (it != this->cache_.end())
+        {
+            // update ordered list of cached commands (move it to the front)
+            this->cachelist_.erase(it->second.iterator_);
+            this->cachelist_.push_front(command);
+            it->second.iterator_ = this->cachelist_.begin();
+
+            // assign the cached evaluation
+            evaluation = it->second.evaluation_;
+            return true;
+        }
+        return false;
+    }
+
+    void CommandExecutor::cache(const std::string& command, const CommandEvaluation& evaluation)
+    {
+        if (Shell::getCacheSize() == 0)
+            return;
+
+        // push command to the front of the ordered list
+        this->cachelist_.push_front(command);
+
+        // create a cache entry and store it in the cache
+        CacheEntry entry;
+        entry.evaluation_ = evaluation;
+        entry.iterator_ = this->cachelist_.begin();
+        this->cache_[command] = entry;
+
+        // remove the last command in the ordered list from the cache if it exceeds the maximum size of the cache
+        if (this->cachelist_.size() > Shell::getCacheSize())
+        {
+            this->cache_.erase(this->cachelist_.back());
+            this->cachelist_.pop_back();
+        }
+    }
+
+    /* static */ MultiType CommandExecutor::unhide(const std::string& command)
+    {
+        return CommandExecutor::queryMT(command);
+    }
+
+    /* static */ void CommandExecutor::alias(const std::string& alias, const std::string& command)
+    {
+        CommandEvaluation evaluation = CommandExecutor::evaluate(command);
+        if (evaluation.isValid())
+        {
+            ExecutorPtr executor = new Executor(*evaluation.getConsoleCommand()->getExecutor().get());
+
+            if (!evaluation.evaluateParams())
+            {
+                for (size_t i = 0; i < MAX_FUNCTOR_ARGUMENTS; ++i)
+                    executor->setDefaultValue(i, evaluation.getEvaluatedParameter(i));
+            }
+
+            SubString tokens(alias, " ");
+
+            if ((tokens.size() == 1 && ConsoleCommand::getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommand::getCommand(tokens[0], tokens[1])))
+            {
+                COUT(1) << "Error: A command with name \"" << alias << "\" already exists." << std::endl;
+                return;
+            }
+
+            if (tokens.size() == 1)
+                createConsoleCommand(tokens[0], executor);
+            else if (tokens.size() == 2)
+                createConsoleCommand(tokens[0], tokens[1], executor);
+            else
+                COUT(1) << "Error: \"" << alias << "\" is not a valid alias name (must have one or two words)." << std::endl;
+        }
+        else
+            COUT(1) << "Error: \"" << command << "\" is not a valid command (did you mean \"" << evaluation.getCommandSuggestion() << "\"?)." << std::endl;
+    }
+}
Index: code/trunk/src/libraries/core/command/CommandExecutor.h
===================================================================
--- code/trunk/src/libraries/core/command/CommandExecutor.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/CommandExecutor.h	(revision 7284)
@@ -0,0 +1,86 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _CommandExecutor_H__
+#define _CommandExecutor_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <list>
+#include <string>
+
+#include "util/MultiType.h"
+#include "CommandEvaluation.h"
+
+// tolua_begin
+namespace orxonox
+{
+    class _CoreExport CommandExecutor
+    {
+// tolua_end
+        public:
+            static int execute(const std::string& command, bool useTcl = true); // tolua_export
+
+            static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true);
+            static std::string query(const std::string& command, int* error = 0, bool useTcl = true); // tolua_export
+
+            static CommandEvaluation evaluate(const std::string& command);
+
+            static const int Success = 0;
+            static const int Error = 1;
+            static const int Incomplete = 2;
+            static const int Deactivated = 3;
+            static const int Denied = 4;
+
+            static MultiType unhide(const std::string& command);
+            static void alias(const std::string& alias, const std::string& command);
+            static void _autocomplete(const std::string& group, const std::string& name) {}
+
+        private:
+            CommandExecutor() {}
+            CommandExecutor(const CommandExecutor& other);
+            ~CommandExecutor() {}
+
+            static CommandExecutor& getInstance();
+
+            bool getCached(const std::string& command, CommandEvaluation& evaluation);
+            void cache(const std::string& command, const CommandEvaluation& evaluation);
+
+            struct CacheEntry
+            {
+                CommandEvaluation evaluation_;
+                std::list<std::string>::iterator iterator_;
+            };
+
+            std::map<std::string, CacheEntry> cache_;
+            std::list<std::string> cachelist_;
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _CommandExecutor_H__ */
Index: code/trunk/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.cc	(revision 7284)
@@ -0,0 +1,533 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "ConsoleCommand.h"
+
+#include "util/Convert.h"
+#include "util/StringUtils.h"
+#include "core/Language.h"
+#include "core/GameMode.h"
+
+namespace orxonox
+{
+    ConsoleCommand::ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
+    {
+        this->bActive_ = true;
+        this->bHidden_ = false;
+        this->accessLevel_ = AccessLevel::All;
+
+        this->baseName_ = name;
+        this->baseFunctor_ = executor->getFunctor();
+
+        this->argumentCompleter_[0] = 0;
+        this->argumentCompleter_[1] = 0;
+        this->argumentCompleter_[2] = 0;
+        this->argumentCompleter_[3] = 0;
+        this->argumentCompleter_[4] = 0;
+
+        this->keybindMode_ = KeybindMode::OnPress;
+        this->inputConfiguredParam_ = -1;
+
+        if (bInitialized)
+            this->executor_ = executor;
+
+        ConsoleCommand::registerCommand(group, name, this);
+    }
+
+    ConsoleCommand::~ConsoleCommand()
+    {
+        ConsoleCommand::unregisterCommand(this);
+    }
+
+    ConsoleCommand& ConsoleCommand::addShortcut()
+    {
+        ConsoleCommand::registerCommand("", this->baseName_, this);
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::addShortcut(const std::string&  name)
+    {
+        ConsoleCommand::registerCommand("", name, this);
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::addGroup(const std::string& group)
+    {
+        ConsoleCommand::registerCommand(group, this->baseName_, this);
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string&  name)
+    {
+        ConsoleCommand::registerCommand(group, name, this);
+        return *this;
+    }
+
+    bool ConsoleCommand::isActive() const
+    {
+        return (this->bActive_ && this->executor_ && this->executor_->getFunctor() && (this->executor_->getFunctor()->getType() == Functor::Type::Static || this->executor_->getFunctor()->getRawObjectPointer()));
+    }
+
+    bool ConsoleCommand::hasAccess() const
+    {
+        switch (this->accessLevel_)
+        {
+            case AccessLevel::All:        return true;
+            case AccessLevel::Standalone: return GameMode::isStandalone();
+            case AccessLevel::Master:     return GameMode::isMaster();
+            case AccessLevel::Server:     return GameMode::hasServer();
+            case AccessLevel::Client:     return GameMode::isClient();
+            case AccessLevel::Online:     return (GameMode::hasServer() || GameMode::isClient());
+            case AccessLevel::Offline:    return GameMode::isStandalone();
+            case AccessLevel::None:       return false;
+            default:                      return false;
+        }
+    }
+
+    bool ConsoleCommand::headersMatch(const FunctorPtr& functor)
+    {
+        unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), functor->getParamCount());
+
+        if (this->baseFunctor_->getHeaderIdentifier(minparams) != functor->getHeaderIdentifier(minparams))
+            return false;
+        else if (functor->getParamCount() <= this->baseFunctor_->getParamCount())
+            return true;
+        else if (!this->executor_)
+            return false;
+        else
+        {
+            for (unsigned int i = this->baseFunctor_->getParamCount(); i < functor->getParamCount(); ++i)
+            {
+                if (!this->executor_->defaultValueSet(i))
+                {
+                    COUT(2) << "Default value " << i << " is missing" << std::endl;
+                    return false;
+                }
+            }
+
+            return true;
+        }
+    }
+
+    bool ConsoleCommand::headersMatch(const ExecutorPtr& executor)
+    {
+        unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), executor->getParamCount());
+
+        if (this->baseFunctor_->getHeaderIdentifier(minparams) != executor->getFunctor()->getHeaderIdentifier(minparams))
+            return false;
+        else if (executor->getParamCount() <= this->baseFunctor_->getParamCount())
+            return true;
+        else
+        {
+            for (unsigned int i = this->baseFunctor_->getParamCount(); i < executor->getParamCount(); ++i)
+            {
+                if (!executor->defaultValueSet(i))
+                {
+                    COUT(2) << "Default value " << i << " is missing" << std::endl;
+                    return false;
+                }
+            }
+
+            return true;
+        }
+    }
+
+    bool ConsoleCommand::setFunction(const ExecutorPtr& executor, bool bForce)
+    {
+        if (!executor || !executor->getFunctor() || bForce || this->headersMatch(executor))
+        {
+            this->executor_ = executor;
+            this->objectStack_.clear();
+            return true;
+        }
+        else
+        {
+            COUT(1) << "Error: Couldn't assign new executor to console command \"" << this->baseName_ << "\", headers don't match." << std::endl;
+            return false;
+        }
+    }
+
+    bool ConsoleCommand::setFunction(const FunctorPtr& functor, bool bForce)
+    {
+        if (!functor || bForce || this->headersMatch(functor))
+        {
+            if (this->executor_)
+                this->executor_->setFunctor(functor);
+            else if (functor)
+                this->executor_ = createExecutor(functor);
+            this->objectStack_.clear();
+
+            return true;
+        }
+        else
+        {
+            COUT(1) << "Error: Couldn't assign new functor to console command \"" << this->baseName_ << "\", headers don't match." << std::endl;
+            return false;
+        }
+    }
+
+    void ConsoleCommand::pushFunction(const ExecutorPtr& executor, bool bForce)
+    {
+        Command command;
+        command.executor_ = this->executor_;
+        if (command.executor_)
+            command.functor_ = this->executor_->getFunctor();
+        command.objectStack_ = this->objectStack_;
+
+        if (this->setFunction(executor, bForce))
+            this->commandStack_.push(command);
+    }
+
+    void ConsoleCommand::pushFunction(const FunctorPtr& functor, bool bForce)
+    {
+        Command command;
+        command.executor_ = this->executor_;
+        if (command.executor_)
+            command.functor_ = this->executor_->getFunctor();
+        command.objectStack_ = this->objectStack_;
+
+        if (this->setFunction(functor, bForce))
+            this->commandStack_.push(command);
+    }
+
+    void ConsoleCommand::pushFunction()
+    {
+        if (this->executor_)
+            this->pushFunction(new Executor(*this->executor_.get()));
+        else
+            COUT(1) << "Error: Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+    }
+
+    void ConsoleCommand::popFunction()
+    {
+        Command command;
+        if (!this->commandStack_.empty())
+        {
+            command = this->commandStack_.top();
+            this->commandStack_.pop();
+        }
+
+        this->executor_ = command.executor_;
+        if (command.executor_)
+            this->executor_->setFunctor(command.functor_);
+        this->objectStack_ = command.objectStack_;
+    }
+
+    void ConsoleCommand::resetFunction()
+    {
+        if (this->executor_)
+            this->executor_->setFunctor(0);
+        this->objectStack_.clear();
+    }
+
+    const ExecutorPtr& ConsoleCommand::getExecutor() const
+    {
+        return this->executor_;
+    }
+
+    bool ConsoleCommand::setObject(void* object)
+    {
+        if (this->executor_)
+        {
+            if (this->executor_->getFunctor())
+            {
+                this->executor_->getFunctor()->setRawObjectPointer(object);
+                return true;
+            }
+            else if (object)
+                COUT(1) << "Error: Can't assign object to console command \"" << this->baseName_ << "\", no functor set." << std::endl;
+        }
+        else if (object)
+            COUT(1) << "Error: Can't assign object to console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+
+        return false;
+    }
+
+    void ConsoleCommand::pushObject(void* object)
+    {
+        void* oldobject = this->getObject();
+        if (this->setObject(object))
+            this->objectStack_.push_back(oldobject);
+    }
+
+    void ConsoleCommand::popObject()
+    {
+        void* newobject = 0;
+        if (!this->objectStack_.empty())
+        {
+            newobject = this->objectStack_.back();
+            this->objectStack_.pop_back();
+        }
+        this->setObject(newobject);
+    }
+
+    void* ConsoleCommand::getObject() const
+    {
+        if (this->executor_ && this->executor_->getFunctor())
+            return this->executor_->getFunctor()->getRawObjectPointer();
+        else
+            return 0;
+    }
+
+    ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1)
+    {
+        if (this->executor_)
+            this->executor_->setDefaultValues(param1);
+        else
+            COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2)
+    {
+        if (this->executor_)
+            this->executor_->setDefaultValues(param1, param2);
+        else
+            COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+    {
+        if (this->executor_)
+            this->executor_->setDefaultValues(param1, param2, param3);
+        else
+            COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+    {
+        if (this->executor_)
+            this->executor_->setDefaultValues(param1, param2, param3, param4);
+        else
+            COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    {
+        if (this->executor_)
+            this->executor_->setDefaultValues(param1, param2, param3, param4, param5);
+        else
+            COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::defaultValue(unsigned int index, const MultiType& param)
+    {
+        if (this->executor_)
+            this->executor_->setDefaultValue(index, param);
+        else
+            COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+
+        return *this;
+    }
+
+    ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer)
+    {
+        if (param < 5)
+            this->argumentCompleter_[param] = completer;
+        else
+            COUT(2) << "Warning: Couldn't add autocompletion-function for param " << param << " in console command \"" << this->baseName_ << "\": index out of bound." << std::endl;
+
+        return *this;
+    }
+
+    ArgumentCompleter* ConsoleCommand::getArgumentCompleter(unsigned int param) const
+    {
+        if (param < 5)
+            return this->argumentCompleter_[param];
+        else
+            return 0;
+    }
+
+    ConsoleCommand& ConsoleCommand::description(const std::string& description)
+    {
+        this->description_ = std::string("ConsoleCommandDescription::" + this->baseName_ + "::function");
+        AddLanguageEntry(this->description_, description);
+        return *this;
+    }
+
+    const std::string& ConsoleCommand::getDescription() const
+    {
+        return GetLocalisation_noerror(this->description_);
+    }
+
+    ConsoleCommand& ConsoleCommand::descriptionParam(unsigned int param, const std::string& description)
+    {
+        if (param < MAX_FUNCTOR_ARGUMENTS)
+        {
+            this->descriptionParam_[param] = std::string("ConsoleCommandDescription::" + this->baseName_ + "::param" + multi_cast<std::string>(param));
+            AddLanguageEntry(this->descriptionParam_[param], description);
+        }
+        return *this;
+    }
+
+    const std::string& ConsoleCommand::getDescriptionParam(unsigned int param) const
+    {
+        if (param < MAX_FUNCTOR_ARGUMENTS)
+            return GetLocalisation_noerror(this->descriptionParam_[param]);
+
+        return this->descriptionParam_[0];
+    }
+
+    ConsoleCommand& ConsoleCommand::descriptionReturnvalue(const std::string& description)
+    {
+        this->descriptionReturnvalue_ = std::string("ConsoleCommandDescription::" + this->baseName_ + "::returnvalue");
+        AddLanguageEntry(this->descriptionReturnvalue_, description);
+        return *this;
+    }
+
+    const std::string& ConsoleCommand::getDescriptionReturnvalue(int param) const
+    {
+        return GetLocalisation_noerror(this->descriptionReturnvalue_);
+    }
+
+    /* static */ const ConsoleCommand* ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError)
+    {
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMap().find(group);
+        if (it_group != ConsoleCommand::getCommandMap().end())
+        {
+            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(name);
+            if (it_name != it_group->second.end())
+            {
+                return it_name->second;
+            }
+        }
+        if (bPrintError)
+        {
+            if (group == "")
+                COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
+            else
+                COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
+        }
+        return 0;
+    }
+
+    /* static */ const ConsoleCommand* ConsoleCommand::getCommandLC(const std::string& group, const std::string& name, bool bPrintError)
+    {
+        std::string groupLC = getLowercase(group);
+        std::string nameLC = getLowercase(name);
+
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMapLC().find(groupLC);
+        if (it_group != ConsoleCommand::getCommandMapLC().end())
+        {
+            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC);
+            if (it_name != it_group->second.end())
+            {
+                return it_name->second;
+            }
+        }
+        if (bPrintError)
+        {
+            if (group == "")
+                COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
+            else
+                COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
+        }
+        return 0;
+    }
+
+    /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMap()
+    {
+        static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap;
+        return commandMap;
+    }
+
+    /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMapLC()
+    {
+        static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC;
+        return commandMapLC;
+    }
+
+    /* static */ void ConsoleCommand::registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command)
+    {
+        if (name == "")
+            return;
+
+        if (ConsoleCommand::getCommand(group, name) != 0)
+        {
+            if (group == "")
+                COUT(2) << "Warning: A console command with shortcut \"" << name << "\" already exists." << std::endl;
+            else
+                COUT(2) << "Warning: A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << std::endl;
+        }
+        else
+        {
+            ConsoleCommand::getCommandMap()[group][name] = command;
+            ConsoleCommand::getCommandMapLC()[getLowercase(group)][getLowercase(name)] = command;
+        }
+    }
+
+    /* static */ void ConsoleCommand::unregisterCommand(ConsoleCommand* command)
+    {
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMap().begin(); it_group != ConsoleCommand::getCommandMap().end(); )
+        {
+            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
+            {
+                if (it_name->second == command)
+                    it_group->second.erase(it_name++);
+                else
+                    ++it_name;
+            }
+
+            if (it_group->second.empty())
+                ConsoleCommand::getCommandMap().erase(it_group++);
+            else
+                ++it_group;
+        }
+
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMapLC().begin(); it_group != ConsoleCommand::getCommandMapLC().end(); )
+        {
+            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
+            {
+                if (it_name->second == command)
+                    it_group->second.erase(it_name++);
+                else
+                    ++it_name;
+            }
+
+            if (it_group->second.empty())
+                ConsoleCommand::getCommandMapLC().erase(it_group++);
+            else
+                ++it_group;
+        }
+    }
+
+    /* static */ void ConsoleCommand::destroyAll()
+    {
+        while (!ConsoleCommand::getCommandMap().empty() && !ConsoleCommand::getCommandMap().begin()->second.empty())
+            delete ConsoleCommand::getCommandMap().begin()->second.begin()->second;
+    }
+}
Index: code/trunk/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.h	(revision 7284)
@@ -0,0 +1,367 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ConsoleCommand_H__
+#define _ConsoleCommand_H__
+
+#include "core/CorePrereqs.h"
+
+#include <stack>
+#include <vector>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/facilities/expand.hpp>
+
+#include "util/VA_NARGS.h"
+#include "ArgumentCompletionFunctions.h"
+#include "Executor.h"
+
+
+#define SetConsoleCommand(...) \
+    BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
+#define SetConsoleCommand2(name, functionpointer) \
+    SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
+#define SetConsoleCommand3(group, name, functionpointer) \
+    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
+#define SetConsoleCommand4(group, name, functionpointer, object) \
+    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
+
+#define SetConsoleCommandGeneric(group, name, functor) \
+    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
+
+
+#define DeclareConsoleCommand(...) \
+    BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
+#define DeclareConsoleCommand2(name, functionpointer) \
+    DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
+#define DeclareConsoleCommand3(group, name, functionpointer) \
+    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
+#define DeclareConsoleCommand4(group, name, functionpointer, object) \
+    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
+
+#define DeclareConsoleCommandGeneric(group, name, functor) \
+    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
+
+
+namespace orxonox
+{
+    namespace prototype
+    {
+        inline void void__void(void) {}
+        inline void void__string(const std::string&) {}
+    }
+
+    namespace AccessLevel
+    {
+        enum Enum
+        {
+            All,
+            Standalone,
+            Master,
+            Server,
+            Client,
+            Online,
+            Offline,
+            None
+        };
+    }
+
+    class _CoreExport ConsoleCommand
+    {
+        friend struct ConsoleCommandManipulator;
+
+        struct Command
+        {
+            ExecutorPtr executor_;
+            FunctorPtr functor_;
+            std::vector<void*> objectStack_;
+        };
+
+        public:
+            struct ConsoleCommandManipulator
+            {
+                public:
+                    ConsoleCommandManipulator(const ConsoleCommand* command) : command_(const_cast<ConsoleCommand*>(command)) {}
+
+                    template <class F>
+                    inline ConsoleCommandManipulator& setFunction(F function, bool bForce = false)
+                        {
+                            if (this->command_)
+                            {
+                                if (this->command_->getExecutor() && this->command_->getExecutor()->getFunctor() && this->command_->getExecutor()->getFunctor()->getFullIdentifier() == typeid(F))
+                                {
+                                    FunctorPointer<F>* functor = static_cast<FunctorPointer<F>*>(this->command_->getExecutor()->getFunctor().get());
+                                    functor->setFunction(function);
+                                    return *this;
+                                }
+                                this->command_->setFunction(createFunctor(function), bForce);
+                            }
+                            return *this;
+                        }
+                    template <class F, class O>
+                    inline ConsoleCommandManipulator& setFunction(F function, O* object, bool bForce = false)
+                        {
+                            if (this->command_)
+                            {
+                                if (this->command_->getExecutor() && this->command_->getExecutor()->getFunctor() && this->command_->getExecutor()->getFunctor()->getFullIdentifier() == typeid(F))
+                                {
+                                    FunctorPointer<F, O>* functor = static_cast<FunctorPointer<F, O>*>(this->command_->getExecutor()->getFunctor().get());
+                                    functor->setFunction(function);
+                                    functor->setObject(object);
+                                    return *this;
+                                }
+                                this->command_->setFunction(createFunctor(function, object), bForce);
+                            }
+                            return *this;
+                        }
+                    inline ConsoleCommandManipulator& setFunction(const FunctorPtr& functor, bool bForce = false)
+                        { if (this->command_) { this->command_->setFunction(functor, bForce); } return *this; }
+                    inline ConsoleCommandManipulator& setFunction(const ExecutorPtr& executor, bool bForce = false)
+                        { if (this->command_) { this->command_->setFunction(executor, bForce); } return *this; }
+
+                    inline ConsoleCommandManipulator& pushFunction()
+                        { if (this->command_) { this->command_->pushFunction(); } return *this; }
+                    template <class F>
+                    inline ConsoleCommandManipulator& pushFunction(F function, bool bForce = false)
+                        { if (this->command_) { this->command_->pushFunction(createFunctor(function), bForce); } return *this; }
+                    template <class F, class O>
+                    inline ConsoleCommandManipulator& pushFunction(F function, O* object, bool bForce = false)
+                        { if (this->command_) { this->command_->pushFunction(createFunctor(function, object), bForce); } return *this; }
+                    inline ConsoleCommandManipulator& pushFunction(const FunctorPtr& functor, bool bForce = false)
+                        { if (this->command_) { this->command_->pushFunction(functor, bForce); } return *this; }
+                    inline ConsoleCommandManipulator& pushFunction(const ExecutorPtr& executor, bool bForce = false)
+                        { if (this->command_) { this->command_->pushFunction(executor, bForce); } return *this; }
+
+                    inline ConsoleCommandManipulator& popFunction()
+                        { if (this->command_) { this->command_->popFunction(); } return *this; }
+
+                    inline ConsoleCommandManipulator& resetFunction()
+                        { if (this->command_) { this->command_->resetFunction(); } return *this; }
+
+                    inline ConsoleCommandManipulator& setObject(void* object)
+                        { if (this->command_) { this->command_->setObject(object); } return *this; }
+                    inline ConsoleCommandManipulator& pushObject(void* object)
+                        { if (this->command_) { this->command_->pushObject(object); } return *this; }
+                    inline ConsoleCommandManipulator& popObject()
+                        { if (this->command_) { this->command_->popObject(); } return *this; }
+
+                    inline ConsoleCommandManipulator& setActive(bool bActive)
+                        { if (this->command_) { this->command_->setActive(bActive); } return *this; }
+                    inline ConsoleCommandManipulator& activate()
+                        { return this->setActive(true); }
+                    inline ConsoleCommandManipulator& deactivate()
+                        { return this->setActive(false); }
+
+                    inline ConsoleCommandManipulator& setHidden(bool bHidden)
+                        { if (this->command_) { this->command_->setHidden(bHidden); } return *this; }
+                    inline ConsoleCommandManipulator& hide()
+                        { return this->setHidden(true); }
+                    inline ConsoleCommandManipulator& show()
+                        { return this->setHidden(false); }
+
+                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1)
+                        { if (this->command_) { this->command_->defaultValues(param1); } return *this; }
+                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2)
+                        { if (this->command_) { this->command_->defaultValues(param1, param2); } return *this; }
+                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+                        { if (this->command_) { this->command_->defaultValues(param1, param2, param3); } return *this; }
+                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+                        { if (this->command_) { this->command_->defaultValues(param1, param2, param3, param4); } return *this; }
+                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+                        { if (this->command_) { this->command_->defaultValues(param1, param2, param3, param4, param5); } return *this; }
+                    inline ConsoleCommandManipulator& defaultValue(unsigned int index, const MultiType& param)
+                        { if (this->command_) { this->command_->defaultValue(index, param); } return *this; }
+
+                    inline ConsoleCommandManipulator& accessLevel(AccessLevel::Enum level)
+                        { if (this->command_) { this->command_->accessLevel(level); } return *this; }
+
+                    inline ConsoleCommandManipulator& argumentCompleter(unsigned int param, ArgumentCompleter* completer)
+                        { if (this->command_) { this->command_->argumentCompleter(param, completer); } return *this; }
+
+                    inline ConsoleCommandManipulator& setAsInputCommand()
+                        { if (this->command_) { this->command_->setAsInputCommand(); } return *this; }
+                    inline ConsoleCommandManipulator& keybindMode(KeybindMode::Value mode)
+                        { if (this->command_) { this->command_->keybindMode(mode); } return *this; }
+                    inline ConsoleCommandManipulator& inputConfiguredParam(int index)
+                        { if (this->command_) { this->command_->inputConfiguredParam(index); } return *this; }
+
+                private:
+                    ConsoleCommand* command_;
+            };
+
+        public:
+            ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
+            ~ConsoleCommand();
+
+            ConsoleCommand& addShortcut();
+            ConsoleCommand& addShortcut(const std::string&  name);
+            ConsoleCommand& addGroup(const std::string& group);
+            ConsoleCommand& addGroup(const std::string& group, const std::string&  name);
+
+            inline const std::string& getName() const
+                { return this->baseName_; }
+
+            const ExecutorPtr& getExecutor() const;
+            inline const FunctorPtr& getBaseFunctor() const
+                { return this->baseFunctor_; }
+
+            inline ConsoleCommand& setActive(bool bActive)
+                { this->bActive_ = bActive; return *this; }
+            inline ConsoleCommand& activate()
+                { return this->setActive(true); }
+            inline ConsoleCommand& deactivate()
+                { return this->setActive(false); }
+
+            inline ConsoleCommand& setHidden(bool bHidden)
+                { this->bHidden_ = bHidden; return *this; }
+            inline ConsoleCommand& hide()
+                { return this->setHidden(true); }
+            inline ConsoleCommand& show()
+                { return this->setHidden(false); }
+
+            bool isActive() const;
+            bool hasAccess() const;
+            inline bool isHidden() const
+                { return this->bHidden_; }
+
+            ConsoleCommand& description(const std::string& description);
+            const std::string& getDescription() const;
+
+            ConsoleCommand& descriptionParam(unsigned int param, const std::string& description);
+            const std::string& getDescriptionParam(unsigned int param) const;
+
+            ConsoleCommand& descriptionReturnvalue(const std::string& description);
+            const std::string& getDescriptionReturnvalue(int param) const;
+
+            ConsoleCommand& defaultValues(const MultiType& param1);
+            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2);
+            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
+            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
+            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
+            ConsoleCommand& defaultValue(unsigned int index, const MultiType& param);
+
+            inline ConsoleCommand& accessLevel(AccessLevel::Enum level)
+                { this->accessLevel_ = level; return *this; }
+            inline AccessLevel::Enum getAccessLevel() const
+                { return this->accessLevel_; }
+
+            ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
+            ArgumentCompleter* getArgumentCompleter(unsigned int param) const;
+
+            inline ConsoleCommand& setAsInputCommand()
+            {
+                this->keybindMode(KeybindMode::OnHold);
+                this->defaultValue(0, Vector2(0.0f, 0.0f));
+                this->inputConfiguredParam(0);
+                return *this;
+            }
+
+            inline ConsoleCommand& keybindMode(KeybindMode::Value mode)
+                { this->keybindMode_ = mode; return *this; }
+            inline KeybindMode::Value getKeybindMode() const
+                { return this->keybindMode_; }
+
+            inline ConsoleCommand& inputConfiguredParam(int index)
+                { this->inputConfiguredParam_ = index; return *this; }
+            inline int getInputConfiguredParam_() const
+                { return this->inputConfiguredParam_; }
+
+            inline ConsoleCommandManipulator getManipulator() const
+                { return this; }
+
+        private:
+            bool headersMatch(const FunctorPtr& functor);
+            bool headersMatch(const ExecutorPtr& executor);
+
+            bool setFunction(const ExecutorPtr& executor, bool bForce = false);
+            bool setFunction(const FunctorPtr& functor, bool bForce = false);
+            void pushFunction(const ExecutorPtr& executor, bool bForce = false);
+            void pushFunction(const FunctorPtr& functor, bool bForce = false);
+            void pushFunction();
+            void popFunction();
+            void resetFunction();
+
+            bool setObject(void* object);
+            void pushObject(void* object);
+            void popObject();
+            void* getObject() const;
+
+            bool bActive_;
+            bool bHidden_;
+            AccessLevel::Enum accessLevel_;
+            std::string baseName_;
+            FunctorPtr baseFunctor_;
+
+            ExecutorPtr executor_;
+            std::stack<Command> commandStack_;
+            std::vector<void*> objectStack_;
+
+            ArgumentCompleter* argumentCompleter_[5];
+
+            KeybindMode::Value keybindMode_;
+            int inputConfiguredParam_;
+
+            LanguageEntryLabel description_;
+            LanguageEntryLabel descriptionReturnvalue_;
+            LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS];
+
+        public:
+            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
+                { return ConsoleCommand::getCommandMap(); }
+            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
+                { return ConsoleCommand::getCommandMapLC(); }
+
+            static inline const ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
+                { return ConsoleCommand::getCommand("", name, bPrintError); }
+            static inline const ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
+                { return ConsoleCommand::getCommandLC("", name, bPrintError); }
+
+            static const ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
+            static const ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
+
+            static void destroyAll();
+
+        private:
+            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMap();
+            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMapLC();
+
+            static void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
+            static void unregisterCommand(ConsoleCommand* command);
+    };
+
+    inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
+        { return new ConsoleCommand("", name, executor, bInitialized); }
+    inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
+        { return new ConsoleCommand(group, name, executor, bInitialized); }
+
+    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name)
+        { return ConsoleCommand::getCommand(name, true); }
+    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name)
+        { return ConsoleCommand::getCommand(group, name, true); }
+}
+
+#endif /* _ConsoleCommand_H__ */
Index: code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc	(revision 7284)
@@ -0,0 +1,182 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "ConsoleCommandCompilation.h"
+
+#include <fstream>
+#include <set>
+#include <string>
+
+#include "util/Debug.h"
+#include "util/ExprParser.h"
+#include "util/StringUtils.h"
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+
+namespace orxonox
+{
+    SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommand("echo", echo);
+    SetConsoleCommand("puts", puts);
+
+    SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files());
+
+    SetConsoleCommand("calculate", calculate);
+
+    void source(const std::string& filename)
+    {
+        static std::set<std::string> executingFiles;
+
+        std::set<std::string>::const_iterator it = executingFiles.find(filename);
+        if (it != executingFiles.end())
+        {
+            COUT(1) << "Error: Recurring source command in \"" << filename << "\". Stopped execution." << std::endl;
+            return;
+        }
+
+        // Open the file
+        std::ifstream file;
+        file.open(filename.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't open file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        executingFiles.insert(filename);
+
+        // Iterate through the file and put the lines into the CommandExecutor
+        while (file.good() && !file.eof())
+        {
+            std::string line;
+            std::getline(file, line);
+            CommandExecutor::execute(line);
+        }
+
+        executingFiles.erase(filename);
+        file.close();
+    }
+
+    std::string echo(const std::string& text)
+    {
+        return text;
+    }
+
+    void puts(bool newline, const std::string& text)
+    {
+        if (newline)
+        {
+            COUT(0) << stripEnclosingBraces(text) << std::endl;
+        }
+        else
+        {
+            COUT(0) << stripEnclosingBraces(text);
+        }
+    }
+
+    void write(const std::string& filename, const std::string& text)
+    {
+        std::ofstream file;
+        file.open(filename.c_str(), std::fstream::out);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't write to file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        file << text << std::endl;
+        file.close();
+    }
+
+    void append(const std::string& filename, const std::string& text)
+    {
+        std::ofstream file;
+        file.open(filename.c_str(), std::fstream::app);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't append to file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        file << text << std::endl;
+        file.close();
+    }
+
+    std::string read(const std::string& filename)
+    {
+        std::ifstream file;
+        file.open(filename.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't read from file \"" << filename << "\"." << std::endl;
+            return "";
+        }
+
+        std::string output;
+        while (file.good() && !file.eof())
+        {
+            std::string line;
+            std::getline(file, line);
+            output += line;
+            output += "\n";
+        }
+
+        file.close();
+
+        return output;
+    }
+
+    float calculate(const std::string& calculation)
+    {
+        ExprParser expr;
+        expr.parse(calculation);
+        if (expr.getSuccess())
+        {
+            if (expr.getResult() == 42.0)
+            {
+                COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;
+            }
+            if (!expr.getRemains().empty())
+            {
+                COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;
+            }
+            return static_cast<float>(expr.getResult());
+        }
+        else
+        {
+            COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;
+            return 0;
+        }
+    }
+}
Index: code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h	(revision 7284)
@@ -0,0 +1,47 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ConsoleCommandCompilation_H__
+#define _ConsoleCommandCompilation_H__
+
+#include "core/CorePrereqs.h"
+
+namespace orxonox
+{
+    _CoreExport void source(const std::string& filename);
+    _CoreExport std::string echo(const std::string& text);
+    _CoreExport void puts(bool newline, const std::string& test);
+
+    _CoreExport void write(const std::string& filename, const std::string& text);
+    _CoreExport void append(const std::string& filename, const std::string& text);
+    _CoreExport std::string read(const std::string& filename);
+
+    _CoreExport float calculate(const std::string& calculation);
+}
+
+#endif /* _ConsoleCommandCompilation_H__ */
Index: code/trunk/src/libraries/core/command/Executor.cc
===================================================================
--- code/trunk/src/libraries/core/command/Executor.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/Executor.cc	(revision 7284)
@@ -0,0 +1,176 @@
+/*
+ *   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:
+ *      ...
+ *
+ *   Inspiration: Executor by Benjamin Grauer
+ */
+
+#include "Executor.h"
+
+#include <algorithm>
+
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "util/StringUtils.h"
+#include "util/SubString.h"
+#include "CommandExecutor.h"
+
+namespace orxonox
+{
+    Executor::Executor(const FunctorPtr& functor, const std::string& name)
+    {
+        this->functor_ = functor;
+        this->name_ = name;
+    }
+
+    Executor::Executor(const Executor& other) : name_(other.name_)
+    {
+        for (size_t i = 0; i < MAX_FUNCTOR_ARGUMENTS; ++i)
+            defaultValue_[i] = other.defaultValue_[i];
+        this->functor_ = other.functor_->clone();
+    }
+
+    Executor::~Executor()
+    {
+    }
+
+    MultiType Executor::parse(const std::string& arguments, int* error, const std::string& delimiter, bool bPrintError) const
+    {
+        return this->parse(SubString(arguments, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '{', '}', true, '\0'), error, delimiter, bPrintError);
+    }
+
+    MultiType Executor::parse(const SubString& arguments, int* error, const std::string& delimiter, bool bPrintError) const
+    {
+        MultiType param[MAX_FUNCTOR_ARGUMENTS];
+        unsigned int paramCount = this->evaluateParams(arguments, param, error, delimiter);
+
+        if (error && *error)
+        {
+            if (bPrintError)
+                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << arguments.join() << ")." << std::endl;
+            return MT_Type::Null;
+        }
+
+        COUT(5) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << paramCount << " params: " << param[0] << " / " << param[1] << " / " << param[2] << " / " << param[3] << " / " << param[4] << std::endl;
+
+        switch (paramCount)
+        {
+            case 0:  return (*this->functor_)();
+            case 1:  return (*this->functor_)(param[0]);
+            case 2:  return (*this->functor_)(param[0], param[1]);
+            case 3:  return (*this->functor_)(param[0], param[1], param[2]);
+            case 4:  return (*this->functor_)(param[0], param[1], param[2], param[3]);
+            case 5:
+            default: return (*this->functor_)(param[0], param[1], param[2], param[3], param[4]);
+        }
+    }
+
+    int Executor::evaluateParams(const SubString& arguments, MultiType param[MAX_FUNCTOR_ARGUMENTS], int* error, const std::string& delimiter) const
+    {
+        unsigned int paramCount = this->functor_->getParamCount();
+        unsigned int argumentCount = arguments.size();
+
+        // if there are not enough params given, check if there are default values
+        for (unsigned int i = argumentCount; i < paramCount; i++)
+        {
+            if (this->defaultValue_[i].null())
+            {
+                if (error)
+                    *error = CommandExecutor::Incomplete;
+                return 0;
+            }
+        }
+
+        // assign all given arguments to the multitypes
+        for (unsigned int i = 0; i < std::min(std::min(argumentCount, paramCount), MAX_FUNCTOR_ARGUMENTS); i++)
+            param[i] = arguments[i];
+
+        // fill the remaining multitypes with default values
+        for (unsigned int i = argumentCount; i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++)
+            param[i] = this->defaultValue_[i];
+
+        // assign the remaining arguments all to the last parameter if it is a string
+        if ((paramCount <= MAX_FUNCTOR_ARGUMENTS) &&(argumentCount > paramCount) && (paramCount == 1 || this->functor_->getTypenameParam(paramCount - 1) == "string"))
+            param[paramCount - 1] = arguments.subSet(paramCount - 1).join(delimiter);
+
+        // evaluate the param types through the functor
+        for (unsigned int i = 0; i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++)
+            this->functor_->evaluateParam(i, param[i]);
+
+        if (error)
+            *error = CommandExecutor::Success;
+        return paramCount;
+    }
+
+    void Executor::setDefaultValues(const MultiType& param1)
+    {
+        this->defaultValue_[0] = param1;
+    }
+
+    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
+    {
+        this->defaultValue_[0] = param1;
+        this->defaultValue_[1] = param2;
+    }
+
+    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+    {
+        this->defaultValue_[0] = param1;
+        this->defaultValue_[1] = param2;
+        this->defaultValue_[2] = param3;
+    }
+
+    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+    {
+        this->defaultValue_[0] = param1;
+        this->defaultValue_[1] = param2;
+        this->defaultValue_[2] = param3;
+        this->defaultValue_[3] = param4;
+    }
+
+    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    {
+        this->defaultValue_[0] = param1;
+        this->defaultValue_[1] = param2;
+        this->defaultValue_[2] = param3;
+        this->defaultValue_[3] = param4;
+        this->defaultValue_[4] = param5;
+    }
+
+    void Executor::setDefaultValue(unsigned int index, const MultiType& param)
+    {
+        if (index < MAX_FUNCTOR_ARGUMENTS)
+            this->defaultValue_[index] = param;
+    }
+
+    bool Executor::allDefaultValuesSet() const
+    {
+        for (unsigned int i = 0; i < this->functor_->getParamCount(); i++)
+            if (this->defaultValue_[i].null())
+                return false;
+
+        return true;
+    }
+}
Index: code/trunk/src/libraries/core/command/Executor.h
===================================================================
--- code/trunk/src/libraries/core/command/Executor.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/Executor.h	(revision 7284)
@@ -0,0 +1,211 @@
+/*
+ *   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:
+ *      ...
+ *
+ *   Inspiration: Executor by Benjamin Grauer
+ */
+
+#ifndef _Executor_H__
+#define _Executor_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include "util/MultiType.h"
+#include "Functor.h"
+#include "ExecutorPtr.h"
+
+namespace orxonox
+{
+    class _CoreExport Executor
+    {
+        public:
+            Executor(const FunctorPtr& functor, const std::string& name = "");
+            Executor(const Executor& other);
+            virtual ~Executor();
+
+            inline MultiType operator()() const
+                { return (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const MultiType& param1) const
+                { return (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const MultiType& param1, const MultiType& param2) const
+                { return (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { return (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { return (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { return (*this->functor_)(param1, param2, param3, param4, param5); }
+
+            MultiType parse(const std::string& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const;
+            MultiType parse(const SubString& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const;
+
+            int evaluateParams(const SubString& arguments, MultiType param[MAX_FUNCTOR_ARGUMENTS], int* error = 0, const std::string& delimiter = " ") const;
+
+            inline void setFunctor(const FunctorPtr& functor)
+                { this->functor_ = functor; }
+            inline const FunctorPtr& getFunctor() const
+                { return this->functor_; }
+
+            inline void setName(const std::string& name)
+                { this->name_ = name; }
+            inline const std::string& getName() const
+                { return this->name_; }
+
+            inline unsigned int getParamCount() const
+                { return this->functor_->getParamCount(); }
+            inline bool hasReturnvalue() const
+                { return this->functor_->hasReturnvalue(); }
+            inline Functor::Type::Enum getType() const
+                { return this->functor_->getType(); }
+            inline std::string getTypenameParam(unsigned int param) const
+                { return this->functor_->getTypenameParam(param); }
+            inline std::string getTypenameReturnvalue() const
+                { return this->functor_->getTypenameReturnvalue(); }
+
+            void setDefaultValues(const MultiType& param1);
+            void setDefaultValues(const MultiType& param1, const MultiType& param2);
+            void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
+            void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
+            void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
+            void setDefaultValue(unsigned int index, const MultiType& param);
+
+            inline MultiType getDefaultValue(unsigned int index) const
+            {
+                if (index < MAX_FUNCTOR_ARGUMENTS)
+                    return this->defaultValue_[index];
+
+                return MT_Type::Null;
+            }
+
+            bool allDefaultValuesSet() const;
+            inline bool defaultValueSet(unsigned int index) const
+            {
+                if (index < MAX_FUNCTOR_ARGUMENTS)
+                    return !this->defaultValue_[index].null();
+
+                return false;
+            }
+
+        protected:
+            FunctorPtr functor_;
+            std::string name_;
+            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
+    };
+
+    class _CoreExport ExecutorStatic : public Executor
+    {
+        public:
+            ExecutorStatic(const FunctorStaticPtr& functor, const std::string& name = "") : Executor(functor, name) {}
+            virtual ~ExecutorStatic() {}
+    };
+
+    template <class T>
+    class ExecutorMember : public Executor
+    {
+        public:
+            ExecutorMember(const FunctorMemberPtr<T>& functor, const std::string& name = "") : Executor(functor, name), functorMember_(functor) {}
+            virtual ~ExecutorMember() {}
+
+            using Executor::operator();
+
+            inline MultiType operator()(T* object) const
+                { return (*this->functorMember_)(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(T* object, const MultiType& param1) const
+                { return (*this->functorMember_)(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2) const
+                { return (*this->functorMember_)(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { return (*this->functorMember_)(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, param5); }
+
+
+            inline MultiType operator()(const T* object) const
+                { return (*this->functorMember_)(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const T* object, const MultiType& param1) const
+                { return (*this->functorMember_)(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2) const
+                { return (*this->functorMember_)(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { return (*this->functorMember_)(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, param5); }
+
+            inline void setObject(T* object) const
+                { this->functorMember_->setObject(object); }
+            inline void setObject(const T* object) const
+                { this->functorMember_->setObject(object); }
+
+            using Executor::parse;
+
+            MultiType parse(T* object, const std::string& params, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const
+            {
+                T* oldobject = this->functorMember_->getObject();
+
+                this->functorMember_->setObject(object);
+                const MultiType& result = this->Executor::parse(params, error, delimiter, bPrintError);
+                this->functorMember_->setObject(oldobject);
+
+                return result;
+            }
+
+            MultiType parse(const T* object, const std::string& params, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const
+            {
+                T* oldobject = this->functorMember_->getObject();
+
+                this->functorMember_->setObject(object);
+                const MultiType& result = this->Executor::parse(params, error, delimiter, bPrintError);
+                this->functorMember_->setObjects(oldobject);
+
+                return result;
+            }
+
+        protected:
+            FunctorMemberPtr<T> functorMember_;
+    };
+
+    inline ExecutorPtr createExecutor(const FunctorPtr& functor, const std::string& name = "")
+    {
+        return new Executor(functor, name);
+    }
+
+    template <class T>
+    inline ExecutorMemberPtr<T> createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "")
+    {
+        return new ExecutorMember<T>(functor, name);
+    }
+
+    inline ExecutorStaticPtr createExecutor(const FunctorStaticPtr& functor, const std::string& name = "")
+    {
+        return new ExecutorStatic(functor, name);
+    }
+}
+
+#endif /* _Executor_H__ */
Index: code/trunk/src/libraries/core/command/ExecutorPtr.h
===================================================================
--- code/trunk/src/libraries/core/command/ExecutorPtr.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/ExecutorPtr.h	(revision 7284)
@@ -0,0 +1,51 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ExecutorPtr_H__
+#define _ExecutorPtr_H__
+
+#include "core/CorePrereqs.h"
+#include "util/SharedPtr.h"
+
+namespace orxonox
+{
+    typedef SharedPtr<Executor> ExecutorPtr;
+
+    typedef SharedChildPtr<ExecutorStatic, ExecutorPtr> ExecutorStaticPtr;
+
+    template <class T>
+    class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, ExecutorPtr>
+    {
+        public:
+            inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>() {}
+            inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(pointer) {}
+            inline ExecutorMemberPtr(const SharedPtr<ExecutorMember<T> >& other) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(other) {}
+    };
+}
+
+#endif /* _ExecutorPtr_H__ */
Index: code/trunk/src/libraries/core/command/Functor.h
===================================================================
--- code/trunk/src/libraries/core/command/Functor.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/Functor.h	(revision 7284)
@@ -0,0 +1,371 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _Functor_H__
+#define _Functor_H__
+
+#include <typeinfo>
+
+#include "core/CorePrereqs.h"
+
+#include "util/Debug.h"
+#include "util/MultiType.h"
+#include "FunctorPtr.h"
+
+namespace orxonox
+{
+    const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
+
+    template <class T>
+    inline std::string _typeToString() { return "unknown"; }
+
+    template <> inline std::string _typeToString<void>()               { return ""; }
+    template <> inline std::string _typeToString<int>()                { return "int"; }
+    template <> inline std::string _typeToString<unsigned int>()       { return "uint"; }
+    template <> inline std::string _typeToString<char>()               { return "char"; }
+    template <> inline std::string _typeToString<unsigned char>()      { return "uchar"; }
+    template <> inline std::string _typeToString<short>()              { return "short"; }
+    template <> inline std::string _typeToString<unsigned short>()     { return "ushort"; }
+    template <> inline std::string _typeToString<long>()               { return "long"; }
+    template <> inline std::string _typeToString<unsigned long>()      { return "ulong"; }
+    template <> inline std::string _typeToString<long long>()          { return "longlong"; }
+    template <> inline std::string _typeToString<unsigned long long>() { return "ulonglong"; }
+    template <> inline std::string _typeToString<float>()              { return "float"; }
+    template <> inline std::string _typeToString<double>()             { return "double"; }
+    template <> inline std::string _typeToString<long double>()        { return "longdouble"; }
+    template <> inline std::string _typeToString<bool>()               { return "bool"; }
+    template <> inline std::string _typeToString<std::string>()        { return "string"; }
+    template <> inline std::string _typeToString<Vector2>()            { return "Vector2"; }
+    template <> inline std::string _typeToString<Vector3>()            { return "Vector3"; }
+    template <> inline std::string _typeToString<Quaternion>()         { return "Quaternion"; }
+    template <> inline std::string _typeToString<ColourValue>()        { return "ColourValue"; }
+    template <> inline std::string _typeToString<Radian>()             { return "Radian"; }
+    template <> inline std::string _typeToString<Degree>()             { return "Degree"; }
+
+    template <class T>
+    inline std::string typeToString() { return _typeToString<typename Loki::TypeTraits<T>::UnqualifiedReferredType>(); }
+
+    class _CoreExport Functor
+    {
+        public:
+            struct Type
+            {
+                enum Enum
+                {
+                    Static,
+                    Member
+                };
+            };
+
+        public:
+            virtual MultiType 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) = 0;
+
+            virtual FunctorPtr clone() = 0;
+
+            virtual Type::Enum getType() const = 0;
+            virtual unsigned int getParamCount() const = 0;
+            virtual bool hasReturnvalue() const = 0;
+
+            virtual std::string getTypenameParam(unsigned int param) const = 0;
+            virtual std::string getTypenameReturnvalue() const = 0;
+
+            virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
+
+            virtual void setRawObjectPointer(void* object) {}
+            virtual void* getRawObjectPointer() const { return 0; }
+
+            template <class F>
+            inline bool setFunction(F* function)
+            {
+                if (this->getFullIdentifier() == typeid(F*))
+                {
+                    modifyFunctor(this, function);
+                    return true;
+                }
+                return false;
+            }
+
+            virtual const std::type_info& getFullIdentifier() const = 0;
+            virtual const std::type_info& getHeaderIdentifier() const = 0;
+            virtual const std::type_info& getHeaderIdentifier(unsigned int params) const = 0;
+    };
+
+    namespace detail
+    {
+        template <class O>
+        struct FunctorTypeStatic
+        { enum { result = false }; };
+        template <>
+        struct FunctorTypeStatic<void>
+        { enum { result = true }; };
+    }
+
+    template <class O>
+    class FunctorMember : public Functor
+    {
+        public:
+            FunctorMember(O* object = 0) : object_(object) {}
+
+            virtual MultiType operator()(O* object, 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) = 0;
+
+            MultiType 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)
+            {
+                if (detail::FunctorTypeStatic<O>::result || this->object_)
+                    return (*this)(this->object_, param1, param2, param3, param4, param5);
+                else
+                {
+                    COUT(1) << "Error: Can't execute FunctorMember, no object set." << std::endl;
+                    return MT_Type::Null;
+                }
+            }
+
+            Functor::Type::Enum getType() const
+                { return detail::FunctorTypeStatic<O>::result ? Functor::Type::Static : Functor::Type::Member; }
+
+            inline void setObject(O* object)
+                { this->object_ = object;}
+            inline O* getObject() const
+                { return this->object_; }
+
+            inline void setRawObjectPointer(void* object)
+                { this->object_ = (O*)object; }
+            inline void* getRawObjectPointer() const
+                { return this->object_; }
+
+        protected:
+            O* object_;
+    };
+
+    typedef FunctorMember<void> FunctorStatic;
+
+    template <class F, class O = void>
+    class FunctorPointer : public FunctorMember<O>
+    {
+        public:
+            FunctorPointer(F functionPointer, O* object = 0) : FunctorMember<O>(object), functionPointer_(functionPointer) {}
+
+            inline void setFunction(F functionPointer)
+                { this->functionPointer_ = functionPointer; }
+            inline F getFunction() const
+                { return this->functionPointer_; }
+
+            const std::type_info& getFullIdentifier() const
+                { return typeid(F); }
+
+        protected:
+            F functionPointer_;
+    };
+
+    namespace detail
+    {
+        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer                                            { typedef R (O::*Type)(P1, P2, P3, P4, P5); };
+        template <class R, class O, class P1, class P2, class P3, class P4, class P5>               struct FunctionPointer<R, O, false, P1, P2, P3, P4, P5>           { typedef R (O::*Type)(P1, P2, P3, P4, P5); };
+        template <class R, class O, class P1, class P2, class P3, class P4>                         struct FunctionPointer<R, O, false, P1, P2, P3, P4, void>         { typedef R (O::*Type)(P1, P2, P3, P4); };
+        template <class R, class O, class P1, class P2, class P3>                                   struct FunctionPointer<R, O, false, P1, P2, P3, void, void>       { typedef R (O::*Type)(P1, P2, P3); };
+        template <class R, class O, class P1, class P2>                                             struct FunctionPointer<R, O, false, P1, P2, void, void, void>     { typedef R (O::*Type)(P1, P2); };
+        template <class R, class O, class P1>                                                       struct FunctionPointer<R, O, false, P1, void, void, void, void>   { typedef R (O::*Type)(P1); };
+        template <class R, class O>                                                                 struct FunctionPointer<R, O, false, void, void, void, void, void> { typedef R (O::*Type)(); };
+        template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, true, P1, P2, P3, P4, P5>           { typedef R (O::*Type)(P1, P2, P3, P4, P5) const; };
+        template <class R, class O, class P1, class P2, class P3, class P4>           struct FunctionPointer<R, O, true, P1, P2, P3, P4, void>         { typedef R (O::*Type)(P1, P2, P3, P4) const; };
+        template <class R, class O, class P1, class P2, class P3>                     struct FunctionPointer<R, O, true, P1, P2, P3, void, void>       { typedef R (O::*Type)(P1, P2, P3) const; };
+        template <class R, class O, class P1, class P2>                               struct FunctionPointer<R, O, true, P1, P2, void, void, void>     { typedef R (O::*Type)(P1, P2) const; };
+        template <class R, class O, class P1>                                         struct FunctionPointer<R, O, true, P1, void, void, void, void>   { typedef R (O::*Type)(P1) const; };
+        template <class R, class O>                                                   struct FunctionPointer<R, O, true, void, void, void, void, void> { typedef R (O::*Type)() const; };
+        template <class R, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, void, false, P1, P2, P3, P4, P5>           { typedef R (*Type)(P1, P2, P3, P4, P5); };
+        template <class R, class P1, class P2, class P3, class P4>           struct FunctionPointer<R, void, false, P1, P2, P3, P4, void>         { typedef R (*Type)(P1, P2, P3, P4); };
+        template <class R, class P1, class P2, class P3>                     struct FunctionPointer<R, void, false, P1, P2, P3, void, void>       { typedef R (*Type)(P1, P2, P3); };
+        template <class R, class P1, class P2>                               struct FunctionPointer<R, void, false, P1, P2, void, void, void>     { typedef R (*Type)(P1, P2); };
+        template <class R, class P1>                                         struct FunctionPointer<R, void, false, P1, void, void, void, void>   { typedef R (*Type)(P1); };
+        template <class R>                                                   struct FunctionPointer<R, void, false, void, void, void, void, void> { typedef R (*Type)(); };
+
+        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller                                              { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4, param5); } };
+        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4); } };
+        template <class R, class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3); } };
+        template <class R, class O, bool isconst, class P1, class P2>                               struct FunctorCaller<R, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2); } };
+        template <class R, class O, bool isconst, class P1>                                         struct FunctorCaller<R, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1); } };
+        template <class R, class O, bool isconst>                                                   struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(); } };
+        template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
+        template <class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
+        template <class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
+        template <class O, bool isconst, class P1, class P2>                               struct FunctorCaller<void, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2); return MT_Type::Null; } };
+        template <class O, bool isconst, class P1>                                         struct FunctorCaller<void, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1); return MT_Type::Null; } };
+        template <class O, bool isconst>                                                   struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(); return MT_Type::Null; } };
+        template <class R, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4, param5); } };
+        template <class R, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4); } };
+        template <class R, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3); } };
+        template <class R, bool isconst, class P1, class P2>                               struct FunctorCaller<R, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2); } };
+        template <class R, bool isconst, class P1>                                         struct FunctorCaller<R, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1); } };
+        template <class R, bool isconst>                                                   struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(); } };
+        template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
+        template <bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
+        template <bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
+        template <bool isconst, class P1, class P2>                               struct FunctorCaller<void, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2); return MT_Type::Null; } };
+        template <bool isconst, class P1>                                         struct FunctorCaller<void, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1); return MT_Type::Null; } };
+        template <bool isconst>                                                   struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(); return MT_Type::Null; } };
+
+        template <class R, class P1, class P2, class P3, class P4, class P5>
+        struct FunctorHeaderIdentifier
+        {};
+
+        template <class T>
+        struct FunctorHasReturnvalue
+        { enum { result = true }; };
+        template <>
+        struct FunctorHasReturnvalue<void>
+        { enum { result = false }; };
+
+        template <class P1, class P2, class P3, class P4, class P5>
+        struct FunctorParamCount
+        { enum { result = 5 }; };
+        template <class P1, class P2, class P3, class P4>
+        struct FunctorParamCount<P1, P2, P3, P4, void>
+        { enum { result = 4 }; };
+        template <class P1, class P2, class P3>
+        struct FunctorParamCount<P1, P2, P3, void, void>
+        { enum { result = 3 }; };
+        template <class P1, class P2>
+        struct FunctorParamCount<P1, P2, void, void, void>
+        { enum { result = 2 }; };
+        template <class P1>
+        struct FunctorParamCount<P1, void, void, void, void>
+        { enum { result = 1 }; };
+        template <>
+        struct FunctorParamCount<void, void, void, void, void>
+        { enum { result = 0 }; };
+    }
+
+    template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5>
+    class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>
+    {
+        public:
+            FunctorTemplate(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object = 0) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>(functionPointer, object) {}
+
+            MultiType operator()(O* object, 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)
+            {
+                return detail::FunctorCaller<R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);
+            }
+
+            FunctorPtr clone()
+            {
+                return new FunctorTemplate(*this);
+            }
+
+            void evaluateParam(unsigned int index, MultiType& param) const
+            {
+                switch (index)
+                {
+                    case 0: param.convert<P1>(); break;
+                    case 1: param.convert<P2>(); break;
+                    case 2: param.convert<P3>(); break;
+                    case 3: param.convert<P4>(); break;
+                    case 4: param.convert<P5>(); break;
+                }
+            }
+
+            unsigned int getParamCount() const
+            {
+                return detail::FunctorParamCount<P1, P2, P3, P4, P5>::result;
+            }
+
+            bool hasReturnvalue() const
+            {
+                return detail::FunctorHasReturnvalue<R>::result;
+            }
+
+            std::string getTypenameParam(unsigned int param) const
+            {
+                switch (param)
+                {
+                    case 0:  return typeToString<P1>();
+                    case 1:  return typeToString<P2>();
+                    case 2:  return typeToString<P3>();
+                    case 3:  return typeToString<P4>();
+                    case 4:  return typeToString<P5>();
+                    default: return "";
+                }
+            }
+
+            std::string getTypenameReturnvalue() const
+            {
+                return typeToString<R>();
+            }
+
+            const std::type_info& getHeaderIdentifier() const
+            {
+                return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);
+            }
+
+            const std::type_info& getHeaderIdentifier(unsigned int params) const
+            {
+                switch (params)
+                {
+                    case 0:  return typeid(detail::FunctorHeaderIdentifier<R, void, void, void, void, void>);
+                    case 1:  return typeid(detail::FunctorHeaderIdentifier<R, P1, void, void, void, void>);
+                    case 2:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, void, void, void>);
+                    case 3:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, void, void>);
+                    case 4:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, void>);
+                    default: return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);
+                }
+            }
+    };
+
+    template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer, object); }
+    template <class R, class O, class OO, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object)     { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer, object); }
+    template <class R, class O, class OO, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object)         { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer, object); }
+    template <class R, class O, class OO, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object)             { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer, object); }
+    template <class R, class O, class OO, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object)                 { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer, object); }
+    template <class R, class O, class OO>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object)                   { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer, object); }
+    template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer, object); }
+    template <class R, class O, class OO, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object)     { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer, object); }
+    template <class R, class O, class OO, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object)         { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer, object); }
+    template <class R, class O, class OO, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object)             { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer, object); }
+    template <class R, class O, class OO, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object)                 { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer, object); }
+    template <class R, class O, class OO>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object)                   { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer, object); }
+
+    template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer); }
+    template <class R, class O, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4))     { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer); }
+    template <class R, class O, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3))         { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer); }
+    template <class R, class O, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2))             { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer); }
+    template <class R, class O, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1))                 { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer); }
+    template <class R, class O>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)())                   { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer); }
+    template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer); }
+    template <class R, class O, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const)     { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer); }
+    template <class R, class O, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const)         { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer); }
+    template <class R, class O, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const)             { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer); }
+    template <class R, class O, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const)                 { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer); }
+    template <class R, class O>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const)                   { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer); }
+
+    template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>(functionPointer); }
+    template <class R, class P1, class P2, class P3, class P4>           inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4))     { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, void>(functionPointer); }
+    template <class R, class P1, class P2, class P3>                     inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3))         { return new FunctorTemplate<R, void, false, P1, P2, P3, void, void>(functionPointer); }
+    template <class R, class P1, class P2>                               inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2))             { return new FunctorTemplate<R, void, false, P1, P2, void, void, void>(functionPointer); }
+    template <class R, class P1>                                         inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1))                 { return new FunctorTemplate<R, void, false, P1, void, void, void, void>(functionPointer); }
+    template <class R>                                                   inline FunctorStaticPtr createFunctor(R (*functionPointer)())                   { return new FunctorTemplate<R, void, false, void, void, void, void, void>(functionPointer); }
+}
+
+#endif /* _Functor_H__ */
Index: code/trunk/src/libraries/core/command/FunctorPtr.h
===================================================================
--- code/trunk/src/libraries/core/command/FunctorPtr.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/FunctorPtr.h	(revision 7284)
@@ -0,0 +1,60 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _FunctorPtr_H__
+#define _FunctorPtr_H__
+
+#include "core/CorePrereqs.h"
+#include "util/SharedPtr.h"
+
+namespace orxonox
+{
+    typedef SharedPtr<Functor> FunctorPtr;
+
+    template <class T>
+    class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr>
+    {
+        public:
+            inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, FunctorPtr>() {}
+            inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {}
+            inline FunctorMemberPtr(const SharedPtr<FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
+    };
+
+    typedef FunctorMemberPtr<void> FunctorStaticPtr;
+
+    template <class F, class T>
+    class FunctorPointerPtr : public SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >
+    {
+        public:
+            inline FunctorPointerPtr() : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >() {}
+            inline FunctorPointerPtr(FunctorPointer<F, T>* pointer) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(pointer) {}
+            inline FunctorPointerPtr(const SharedPtr<FunctorPointer<F, T> >& other) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(other) {}
+    };
+}
+
+#endif /* _FunctorPtr_H__ */
Index: code/trunk/src/libraries/core/command/IOConsole.cc
===================================================================
--- code/trunk/src/libraries/core/command/IOConsole.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/IOConsole.cc	(revision 7284)
@@ -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/trunk/src/libraries/core/command/IOConsole.h
===================================================================
--- code/trunk/src/libraries/core/command/IOConsole.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/IOConsole.h	(revision 7284)
@@ -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 "core/CorePrereqs.h"
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include "util/Singleton.h"
+#include "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/trunk/src/libraries/core/command/IRC.cc
===================================================================
--- code/trunk/src/libraries/core/command/IRC.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/IRC.cc	(revision 7284)
@@ -0,0 +1,135 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "IRC.h"
+
+#include <cpptcl/cpptcl.h>
+
+#include "util/Convert.h"
+#include "util/Exception.h"
+#include "util/StringUtils.h"
+#include "ConsoleCommand.h"
+#include "TclThreadManager.h"
+
+namespace orxonox
+{
+    static const unsigned int IRC_TCL_THREADID  = 1421421421;
+
+    SetConsoleCommand("IRC", "say",  &IRC::say);
+    SetConsoleCommand("IRC", "msg",  &IRC::msg);
+    SetConsoleCommand("IRC", "nick", &IRC::nick);
+
+    IRC::IRC()
+    {
+        this->interpreter_ = 0;
+    }
+
+    void IRC::initialize()
+    {
+        unsigned int threadID = IRC_TCL_THREADID;
+        this->interpreter_ = TclThreadManager::createWithId(threadID);
+
+        try
+        {
+            this->interpreter_->def("::orxonox::irc::say", IRC::tcl_say, Tcl::variadic());
+            this->interpreter_->def("::orxonox::irc::privmsg", IRC::tcl_privmsg, Tcl::variadic());
+            this->interpreter_->def("::orxonox::irc::action", IRC::tcl_action, Tcl::variadic());
+            this->interpreter_->def("::orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+
+        this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
+        TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
+        TclThreadManager::execute(threadID, "source irc.tcl");
+    }
+
+    IRC& IRC::getInstance()
+    {
+        static IRC instance;
+        return instance;
+    }
+
+    bool IRC::eval(const std::string& command)
+    {
+        if (!IRC::getInstance().interpreter_)
+        {
+            IRC::getInstance().initialize();
+            COUT(1) << "Error: IRC client wasn't yet initialized, please try again." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            IRC::getInstance().interpreter_->eval(command);
+            return true;
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+
+        return false;
+    }
+
+    void IRC::say(const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn #orxonox {" + message + '}'))
+            IRC::tcl_say(Tcl::object(), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::msg(const std::string& channel, const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn " + channel + " {" + message + '}'))
+            IRC::tcl_privmsg(Tcl::object(channel), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::nick(const std::string& nickname)
+    {
+        if (IRC::eval("irk::nick $conn " + nickname))
+            IRC::getInstance().nickname_ = nickname;
+    }
+
+    void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    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;
+    }
+
+    void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> --> " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+}
Index: code/trunk/src/libraries/core/command/IRC.h
===================================================================
--- code/trunk/src/libraries/core/command/IRC.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/IRC.h	(revision 7284)
@@ -0,0 +1,65 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _IRC_H__
+#define _IRC_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+
+namespace orxonox
+{
+    class _CoreExport IRC
+    {
+        public:
+            static IRC& getInstance();
+
+            static void say(const std::string& message);
+            static void msg(const std::string& channel, const std::string& message);
+            static void nick(const std::string& nickname);
+
+            static void tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_info(Tcl::object const &channel, Tcl::object const &args);
+
+        private:
+            static bool eval(const std::string& command);
+            void initialize();
+
+            IRC();
+            IRC(const IRC& other);
+            ~IRC() {}
+
+            Tcl::interpreter* interpreter_;
+            std::string nickname_;
+    };
+}
+
+#endif /* _IRC_H__ */
Index: code/trunk/src/libraries/core/command/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/command/Shell.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/Shell.cc	(revision 7284)
@@ -0,0 +1,478 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *
+ */
+
+#include "Shell.h"
+
+#include "util/OutputHandler.h"
+#include "util/StringUtils.h"
+#include "util/SubString.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigFileManager.h"
+#include "core/ConfigValueIncludes.h"
+#include "CommandExecutor.h"
+#include "ConsoleCommand.h"
+
+namespace orxonox
+{
+    SetConsoleCommand("log",     OutputHandler::log    );
+    SetConsoleCommand("error",   OutputHandler::error  );
+    SetConsoleCommand("warning", OutputHandler::warning);
+    SetConsoleCommand("info",    OutputHandler::info   );
+    SetConsoleCommand("debug",   OutputHandler::debug  );
+
+    unsigned int Shell::cacheSize_s;
+
+    Shell::Shell(const std::string& consoleName, bool bScrollable)
+        : OutputListener(consoleName)
+        , inputBuffer_(new InputBuffer())
+        , consoleName_(consoleName)
+        , bScrollable_(bScrollable)
+    {
+        RegisterRootObject(Shell);
+
+        this->scrollPosition_ = 0;
+        this->maxHistoryLength_ = 100;
+        this->historyPosition_ = 0;
+        this->historyOffset_ = 0;
+        this->bFinishedLastLine_ = true;
+
+        this->clearOutput();
+        this->configureInputBuffer();
+
+        // 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();
+
+        // 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::getInstance().unregisterOutputListener(this);
+        this->inputBuffer_->destroy();
+    }
+
+    void Shell::setConfigValues()
+    {
+        SetConfigValue(maxHistoryLength_, 100)
+            .callback(this, &Shell::commandHistoryLengthChanged);
+        SetConfigValue(historyOffset_, 0)
+            .callback(this, &Shell::commandHistoryOffsetChanged);
+        setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
+        SetConfigValue(cacheSize_s, 32);
+
+#ifdef ORXONOX_RELEASE
+        const unsigned int defaultLevel = 1;
+#else
+        const unsigned int defaultLevel = 3;
+#endif
+        SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
+            .description("The maximal level of debug output shown in the Shell");
+        this->setSoftDebugLevel(this->softDebugLevel_);
+    }
+
+    void Shell::commandHistoryOffsetChanged()
+    {
+        if (this->historyOffset_ >= this->maxHistoryLength_)
+            this->historyOffset_ = 0;
+    }
+
+    void Shell::commandHistoryLengthChanged()
+    {
+        this->commandHistoryOffsetChanged();
+
+        while (this->commandHistory_.size() > this->maxHistoryLength_)
+        {
+            unsigned int index = this->commandHistory_.size() - 1;
+            this->commandHistory_.erase(this->commandHistory_.begin() + index);
+            ModifyConfigValue(commandHistory_, remove, index);
+        }
+    }
+
+    void Shell::configureInputBuffer()
+    {
+        this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
+        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()
+    {
+        Shell& instance = Shell::getInstance();
+
+        for (unsigned int i = instance.historyOffset_; i < instance.commandHistory_.size(); ++i)
+            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
+        for (unsigned int i =  0; i < instance.historyOffset_; ++i)
+            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
+    }
+    */
+
+    void Shell::registerListener(ShellListener* listener)
+    {
+        this->listeners_.push_back(listener);
+    }
+
+    void Shell::unregisterListener(ShellListener* listener)
+    {
+        for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+        {
+            if ((*it) == listener)
+                it = this->listeners_.erase(it);
+            else
+                ++it;
+        }
+    }
+
+    void Shell::setCursorPosition(unsigned int cursor)
+    {
+        this->inputBuffer_->setCursorPosition(cursor);
+        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->bFinishedLastLine_ = true;
+
+        this->updateListeners<&ShellListener::linesChanged>();
+    }
+
+    Shell::LineList::const_iterator Shell::getNewestLineIterator() const
+    {
+        if (this->scrollPosition_)
+            return this->scrollIterator_;
+        else
+            return this->outputLines_.begin();
+    }
+
+    Shell::LineList::const_iterator Shell::getEndIterator() const
+    {
+        return this->outputLines_.end();
+    }
+
+    void Shell::addToHistory(const std::string& command)
+    {
+        if (command == "")
+            return;
+
+        size_t previous_offset = mod(this->historyOffset_ - 1, this->maxHistoryLength_);
+        if (previous_offset < this->commandHistory_.size() && command == this->commandHistory_[previous_offset])
+            return;
+
+        ModifyConfigValue(commandHistory_, set, this->historyOffset_, command);
+        this->historyPosition_ = 0;
+        ModifyConfigValue(historyOffset_, set, (this->historyOffset_ + 1) % this->maxHistoryLength_);
+    }
+
+    const std::string& Shell::getFromHistory() const
+    {
+        unsigned int index = mod(static_cast<int>(this->historyOffset_) - static_cast<int>(this->historyPosition_), this->maxHistoryLength_);
+        if (index < this->commandHistory_.size() && this->historyPosition_ != 0)
+            return this->commandHistory_[index];
+        else
+            return BLANKSTRING;
+    }
+
+    void Shell::outputChanged(int lineType)
+    {
+        bool newline = false;
+        do
+        {
+            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->bFinishedLastLine_)
+            {
+                this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
+
+                if (this->scrollPosition_)
+                    this->scrollPosition_++;
+                else
+                    this->scrollIterator_ = this->outputLines_.begin();
+
+                this->bFinishedLastLine_ = newline;
+
+                if (!this->scrollPosition_)
+                    this->updateListeners<&ShellListener::lineAdded>();
+            }
+            else
+            {
+                this->outputLines_.front().first += output;
+                this->bFinishedLastLine_ = newline;
+                this->updateListeners<&ShellListener::onlyLastLineChanged>();
+            }
+            this->bFinishedLastLine_ = newline;
+
+        } while (newline);
+    }
+
+    void Shell::clearInput()
+    {
+        this->inputBuffer_->clear();
+        this->historyPosition_ = 0;
+        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>();
+
+        int error;
+        const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &error);
+        if (error)
+        {
+            switch (error)
+            {
+                case CommandExecutor::Error:       this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command doesn't exist. (S)" << std::endl; break;
+                case CommandExecutor::Incomplete:  this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", not enough arguments given. (S)" << std::endl; break;
+                case CommandExecutor::Deactivated: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command is not active. (S)" << std::endl; break;
+                case CommandExecutor::Denied:      this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", access denied. (S)" << std::endl; break;
+            }
+            this->outputChanged(Error);
+        }
+        else if (result != "")
+        {
+            this->outputBuffer_ << result << std::endl;
+            this->outputChanged(Command);
+        }
+
+        this->clearInput();
+    }
+
+    void Shell::hintAndComplete()
+    {
+        this->inputBuffer_->set(CommandExecutor::evaluate(this->inputBuffer_->get()).complete());
+        this->outputBuffer_ << CommandExecutor::evaluate(this->inputBuffer_->get()).hint() << 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();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::cursorLeft()
+    {
+        this->inputBuffer_->decreaseCursor();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::cursorEnd()
+    {
+        this->inputBuffer_->setCursorToEnd();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::cursorHome()
+    {
+        this->inputBuffer_->setCursorToBegin();
+        this->updateListeners<&ShellListener::cursorChanged>();
+    }
+
+    void Shell::historyUp()
+    {
+        if (this->historyPosition_ < this->commandHistory_.size())
+        {
+            this->historyPosition_++;
+            this->inputBuffer_->set(this->getFromHistory());
+        }
+    }
+
+    void Shell::historyDown()
+    {
+        if (this->historyPosition_ > 0)
+        {
+            this->historyPosition_--;
+            this->inputBuffer_->set(this->getFromHistory());
+        }
+    }
+
+    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_;
+
+            this->updateListeners<&ShellListener::linesChanged>();
+        }
+    }
+
+    void Shell::scrollDown()
+    {
+        if (this->scrollIterator_ != this->outputLines_.begin())
+        {
+            --this->scrollIterator_;
+            --this->scrollPosition_;
+
+            this->updateListeners<&ShellListener::linesChanged>();
+        }
+    }
+}
Index: code/trunk/src/libraries/core/command/Shell.h
===================================================================
--- code/trunk/src/libraries/core/command/Shell.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/Shell.h	(revision 7284)
@@ -0,0 +1,176 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _Shell_H__
+#define _Shell_H__
+
+#include "core/CorePrereqs.h"
+
+#include <list>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "util/OutputHandler.h"
+#include "core/OrxonoxClass.h"
+#include "core/input/InputBuffer.h"
+
+namespace orxonox
+{
+    class _CoreExport ShellListener
+    {
+        friend class Shell;
+
+        public:
+            virtual ~ShellListener() {}
+
+        private:
+            virtual void linesChanged() {}
+            virtual void onlyLastLineChanged() {}
+            virtual void lineAdded() {}
+            virtual void inputChanged() {}
+            virtual void cursorChanged() {}
+            virtual void executed() {}
+            virtual void exit() {}
+    };
+
+
+    class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
+    {
+        public:
+            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
+            };
+
+            Shell(const std::string& consoleName, bool bScrollable);
+            ~Shell();
+
+            void setConfigValues();
+            void commandHistoryOffsetChanged();
+            void commandHistoryLengthChanged();
+
+            void registerListener(ShellListener* listener);
+            void unregisterListener(ShellListener* listener);
+
+            inline InputBuffer* getInputBuffer()
+                { return this->inputBuffer_; }
+
+            void setCursorPosition(unsigned int cursor);
+            inline unsigned int getCursorPosition() const
+                { return this->inputBuffer_->getCursorPosition(); }
+
+            inline const std::string& getInput() const
+                { return this->inputBuffer_->get(); }
+
+            typedef std::list<std::pair<std::string, LineType> > LineList;
+            LineList::const_iterator getNewestLineIterator() const;
+            LineList::const_iterator getEndIterator() const;
+
+            void addOutput(const std::string& text, LineType type = None);
+            void clearOutput();
+
+            inline unsigned int getNumLines() const
+                { return this->outputLines_.size(); }
+            inline unsigned int getScrollPosition() const
+                { return this->scrollPosition_; }
+
+            inline const std::string& getPromptPrefix() const { return this->promptPrefix_; }
+            void setPromptPrefix(const std::string& str);
+
+            static inline unsigned int getCacheSize()
+                { return Shell::cacheSize_s; }
+
+        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();
+
+            // InputBuffer callbacks
+            void inputChanged();
+            void execute();
+            void hintAndComplete();
+            void backspace();
+            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_;
+            std::stringstream         outputBuffer_;
+            bool                      bFinishedLastLine_;
+            LineList                  outputLines_;
+            LineList::const_iterator  scrollIterator_;
+            unsigned int              scrollPosition_;
+            unsigned int              historyPosition_;
+
+            std::string               promptPrefix_;
+            const std::string         consoleName_;
+            const bool                bScrollable_;
+
+            // Config values
+            unsigned int              maxHistoryLength_;
+            unsigned int              historyOffset_;
+            std::vector<std::string>  commandHistory_;
+            int                       softDebugLevel_;
+            static unsigned int       cacheSize_s;
+    };
+}
+
+#endif /* _Shell_H__ */
Index: code/trunk/src/libraries/core/command/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclBind.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/TclBind.cc	(revision 7284)
@@ -0,0 +1,205 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "TclBind.h"
+
+#include <exception>
+#include <string>
+#include <cpptcl/cpptcl.h>
+
+#include "SpecialConfig.h"
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "util/StringUtils.h"
+#include "core/PathConfig.h"
+#include "CommandExecutor.h"
+#include "ConsoleCommand.h"
+#include "TclThreadManager.h"
+
+namespace orxonox
+{
+    SetConsoleCommand("tcl", &TclBind::tcl);
+    SetConsoleCommand("bgerror", &TclBind::bgerror);
+
+    TclBind* TclBind::singletonPtr_s = 0;
+
+    TclBind::TclBind(const std::string& datapath)
+    {
+        this->interpreter_ = 0;
+        this->bSetTclDataPath_ = false;
+        this->setDataPath(datapath);
+    }
+
+    TclBind::~TclBind()
+    {
+        if (this->interpreter_)
+            delete this->interpreter_;
+    }
+
+    void TclBind::setDataPath(const std::string& datapath)
+    {
+        // String has POSIX slashes
+        this->tclDataPath_ = datapath + "tcl" + '/';
+        this->bSetTclDataPath_ = true;
+
+        this->initializeTclInterpreter();
+    }
+
+    void TclBind::initializeTclInterpreter()
+    {
+        if (this->bSetTclDataPath_ && !this->interpreter_)
+        {
+            this->interpreter_ = this->createTclInterpreter();
+
+            this->interpreter_->def("::orxonox::query", TclBind::tcl_query, Tcl::variadic());
+            this->interpreter_->def("::orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
+            this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
+            this->interpreter_->def("::orxonox::crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic());
+
+            try
+            {
+                this->interpreter_->eval("proc query        {args}    { ::orxonox::query $args }");
+                this->interpreter_->eval("proc crossquery   {id args} { ::orxonox::crossquery 0 $id $args }");
+                this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::crossquery 0 $id $args }");
+                this->interpreter_->eval("proc running      {}        { return 1 }");
+                this->interpreter_->eval("set id 0");
+                this->interpreter_->eval("rename exit ::tcl::exit; proc exit {} { execute exit }");
+            }
+            catch (Tcl::tcl_error const &e)
+            {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+        }
+    }
+
+    Tcl::interpreter* TclBind::createTclInterpreter()
+    {
+        Tcl::interpreter* interpreter = new Tcl::interpreter();
+        const std::string& libpath = TclBind::getTclLibraryPath();
+
+        try
+        {
+            if (!libpath.empty())
+                interpreter->eval("set tcl_library \"" + libpath + '"');
+
+            Tcl_Init(interpreter->get());
+
+            interpreter->eval("source \"" + TclBind::getInstance().tclDataPath_ + "/init.tcl\"");
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
+
+        return interpreter;
+    }
+
+    std::string TclBind::getTclLibraryPath()
+    {
+#ifdef DEPENDENCY_PACKAGE_ENABLE
+        if (PathConfig::isDevelopmentRun())
+            return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl");
+        else
+            return (PathConfig::getRootPathString() + "lib/tcl");
+#else
+        return "";
+#endif
+    }
+
+    std::string TclBind::tcl_query(Tcl::object const &args)
+    {
+        COUT(4) << "Tcl_query: " << args.get() << std::endl;
+
+        const std::string& command = stripEnclosingBraces(args.get());
+
+        int error;
+        CommandEvaluation evaluation = CommandExecutor::evaluate(command);
+        const std::string& result = evaluation.query(&error);
+        switch (error)
+        {
+            case CommandExecutor::Error:       COUT(1) << "Error: Can't execute command \"" << command << "\", command doesn't exist. (B)" << std::endl; break;
+            case CommandExecutor::Incomplete:  COUT(1) << "Error: Can't execute command \"" << command << "\", not enough arguments given. (B)" << std::endl; break;
+            case CommandExecutor::Deactivated: COUT(1) << "Error: Can't execute command \"" << command << "\", command is not active. (B)" << std::endl; break;
+            case CommandExecutor::Denied:      COUT(1) << "Error: Can't execute command \"" << command << "\", access denied. (B)" << std::endl; break;
+        }
+
+        if (error == CommandExecutor::Error)
+            COUT(3) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << std::endl;
+
+        return result;
+    }
+
+    void TclBind::tcl_execute(Tcl::object const &args)
+    {
+        COUT(4) << "Tcl_execute: " << args.get() << std::endl;
+        const std::string& command = stripEnclosingBraces(args.get());
+
+        if (CommandExecutor::execute(command, false))
+        {
+            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
+        }
+    }
+
+    std::string TclBind::tcl(const std::string& tclcode)
+    {
+        if (TclBind::getInstance().interpreter_)
+        {
+            try
+            {
+                const std::string& output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
+                if (!output.empty())
+                {
+                    COUT(0) << "tcl> " << output << std::endl;
+                }
+                return output;
+            }
+            catch (Tcl::tcl_error const &e)
+            {   COUT(1) << "tcl> Error: " << e.what() << std::endl;   }
+        }
+
+        return "";
+    }
+
+    void TclBind::bgerror(const std::string& error)
+    {
+        COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
+    }
+
+    std::string TclBind::eval(const std::string& tclcode, int* error)
+    {
+        if (error)
+            *error = CommandExecutor::Success;
+
+        try
+        {
+            return TclBind::getInstance().interpreter_->eval(tclcode);
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
+
+        if (error)
+            *error = CommandExecutor::Error;
+        return "";
+    }
+}
Index: code/trunk/src/libraries/core/command/TclBind.h
===================================================================
--- code/trunk/src/libraries/core/command/TclBind.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/TclBind.h	(revision 7284)
@@ -0,0 +1,74 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _TclBind_H__
+#define _TclBind_H__
+
+#include "core/CorePrereqs.h"
+
+#include <cassert>
+#include <string>
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    class _CoreExport TclBind : public Singleton<TclBind>
+    {
+        friend class Singleton<TclBind>;
+        public:
+            TclBind(const std::string& datapath);
+            ~TclBind();
+
+            static std::string tcl(const std::string& tclcode);
+            static void bgerror(const std::string& error);
+
+            void setDataPath(const std::string& datapath);
+            const std::string& getTclDataPath() const { return this->tclDataPath_; }
+            static std::string getTclLibraryPath();
+
+            void initializeTclInterpreter();
+            static Tcl::interpreter* createTclInterpreter();
+            Tcl::interpreter* getTclInterpreter() const { return this->interpreter_; }
+
+            static std::string tcl_query(Tcl::object const &args);
+            static void tcl_execute(Tcl::object const &args);
+
+            static std::string eval(const std::string& tclcode, int* error = 0);
+
+        private:
+            TclBind(const TclBind& other);
+
+            Tcl::interpreter* interpreter_;
+            std::string tclDataPath_;
+            bool bSetTclDataPath_;
+
+            static TclBind* singletonPtr_s;
+    };
+}
+
+#endif /* _TclBind_H__ */
Index: code/trunk/src/libraries/core/command/TclThreadList.h
===================================================================
--- code/trunk/src/libraries/core/command/TclThreadList.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/TclThreadList.h	(revision 7284)
@@ -0,0 +1,263 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _TclThreadList_H__
+#define _TclThreadList_H__
+
+#include "core/CorePrereqs.h"
+
+#include <list>
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/locks.hpp>
+
+namespace orxonox
+{
+    template <class T>
+    class TclThreadList
+    {
+        public:
+            void push_front(const T& value);
+            void push_back(const T& value);
+            template <class InputIterator> void insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end);
+
+            void wait_and_pop_front(T* value);
+            void wait_and_pop_back(T* value);
+            bool try_pop_front(T* value);
+            bool try_pop_back(T* value);
+            void clear();
+
+            size_t size() const;
+            bool empty() const;
+            bool is_in(const T& value) const;
+
+            /**
+                @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
+            */
+            inline std::list<T>& getList()
+                { return this->list_; }
+
+            /**
+                @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
+            */
+            inline const std::list<T>& getList() const
+                { return this->list_; }
+
+            /**
+                @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref begin and @ref end).
+            */
+            inline boost::shared_mutex& getMutex() const
+                { return this->mutex_; }
+
+        private:
+            std::list<T>                  list_;        ///< A standard list for type T
+            mutable boost::shared_mutex   mutex_;       ///< A mutex to grant exclusive access to the list
+            boost::condition_variable_any condition_;   ///< A condition variable to wake threads waiting for the mutex to become ready
+    };
+
+    /**
+        @brief Pushes a new element to the front of the list. A unique_lock is needed.
+    */
+    template <class T>
+    void TclThreadList<T>::push_front(const T& value)
+    {
+        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+        this->list_.push_front(value);
+        lock.unlock();                  // unlock the mutex...
+        this->condition_.notify_all();  // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+    }
+
+    /**
+        @brief Pushes a new element to the back of the list. A unique_lock is needed.
+    */
+    template <class T>
+    void TclThreadList<T>::push_back(const T& value)
+    {
+        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+        this->list_.push_back(value);
+        lock.unlock();                  // unlock the mutex...
+        this->condition_.notify_all();  // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+    }
+
+    /**
+        @brief Inserts new elements into the list. A unique_lock is needed.
+    */
+    template <class T>
+    template <class InputIterator> void TclThreadList<T>::insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end)
+    {
+        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+        this->list_.insert(position, begin, end);
+        lock.unlock();                  // unlock the mutex...
+        this->condition_.notify_all();  // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+    }
+
+    /**
+        @brief Waits until the list contains at least one element and then pops and returns the front element.
+        @param value The front value will be stored in the variable referenced by this pointer.
+    */
+    template <class T>
+    void TclThreadList<T>::wait_and_pop_front(T* value)
+    {
+        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+
+        while (this->list_.empty())       // check if there's an element in the list
+            this->condition_.wait(lock);  // wait until the condition becomes true (a notification comes from push_front, push_back or insert
+
+        *value = this->list_.front();
+        this->list_.pop_front();
+    }
+
+    /**
+        @brief Waits until the list contains at least one element and then pops and returns the back element.
+        @param value The back value will be stored in the variable referenced by this pointer.
+    */
+    template <class T>
+    void TclThreadList<T>::wait_and_pop_back(T* value)
+    {
+        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+
+        while (this->list_.empty())       // check if there's an element in the list
+            this->condition_.wait(lock);  // wait until the condition becomes true (a notification comes from push_front, push_back or insert
+
+        *value = this->list_.back();
+        this->list_.pop_back();
+    }
+
+    /**
+        @brief Pops and returns the front element if there's at least one element in the list.
+        @param value The front value will be stored in the variable referenced by this pointer.
+        @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
+
+        Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
+    */
+    template <class T>
+    bool TclThreadList<T>::try_pop_front(T* value)
+    {
+        boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
+
+        if (this->list_.empty())
+        {
+            // No elements - return immediately
+            return false;
+        }
+        else
+        {
+            // At least one element - write it into the passed variable and pop it from the list
+            boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
+            *value = this->list_.front();
+            this->list_.pop_front();
+        }
+        return true;
+    }
+
+    /**
+        @brief Pops and returns the back element if there's at least one element in the list.
+        @param value The back value will be stored in the variable referenced by this pointer.
+        @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
+
+        Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
+    */
+    template <class T>
+    bool TclThreadList<T>::try_pop_back(T* value)
+    {
+        boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
+
+        if (this->list_.empty())
+        {
+            // No elements - return immediately
+            return false;
+        }
+        else
+        {
+            // At least one element - write it into the passed variable and pop it from the list
+            boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
+            *value = this->list_.back();
+            this->list_.pop_back();
+        }
+        return true;
+    }
+
+    /**
+        @brief Clears the list. A unique_lock is needed.
+    */
+    template <class T>
+    void TclThreadList<T>::clear()
+    {
+        boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+        this->list_.clear();
+    }
+
+    /**
+        @brief Returns the size of the list. A shared_lock is needed.
+
+        Warning: Don't change the list based on the result of size(). Use an atomic function instead. Other threads may change the list
+        beween your call to size() and your further actions, so be careful and use this function only if you really want nothing else than
+        just the size of the list.
+    */
+    template <class T>
+    size_t TclThreadList<T>::size() const
+    {
+        boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+        return this->list_.size();
+    }
+
+    /**
+        @brief Returns true if the list is empty, false otherwise. A shared_lock is needed.
+
+        Warning: Don't change the list based on the result of empty(). Use an atomic function instead. Other threads may change the list
+        beween your call to empty() and your further actions, so be careful and use this function only if you really want nothing else than
+        just if the list is empty or not.
+    */
+    template <class T>
+    bool TclThreadList<T>::empty() const
+    {
+        boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+        return this->list_.empty();
+    }
+
+    /**
+        @brief Returns true if a given element is in the list, false otherwise. A shared_lock is needed.
+
+        Warning: The result of this function might be wrong just one instruction after the call. Use this function just to get information
+        about a temporary snapshot and don't change the list based on the result of this function.
+    */
+    template <class T>
+    bool TclThreadList<T>::is_in(const T& value) const
+    {
+        boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+
+        for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
+            if (*it == value)
+                return true;
+
+        return false;
+    }
+}
+
+#endif /* _TclThreadList_H__ */
Index: code/trunk/src/libraries/core/command/TclThreadManager.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclThreadManager.cc	(revision 7284)
+++ code/trunk/src/libraries/core/command/TclThreadManager.cc	(revision 7284)
@@ -0,0 +1,672 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "TclThreadManager.h"
+
+#include <boost/bind.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <OgreTimer.h>
+#include <cpptcl/cpptcl.h>
+
+#include "util/Clock.h"
+#include "util/Convert.h"
+#include "util/Exception.h"
+#include "util/StringUtils.h"
+#include "core/CoreIncludes.h"
+#include "CommandExecutor.h"
+#include "ConsoleCommand.h"
+#include "TclBind.h"
+#include "TclThreadList.h"
+
+namespace orxonox
+{
+    const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f;
+
+    SetConsoleCommand("tclexecute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand("tclquery",   &TclThreadManager::query  ).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand("TclThreadManager", "create",  &TclThreadManager::create);
+    SetConsoleCommand("TclThreadManager", "destroy", &TclThreadManager::destroy).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand("TclThreadManager", "execute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand("TclThreadManager", "query",   &TclThreadManager::query  ).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand("TclThreadManager", "source",  &TclThreadManager::source ).argumentCompleter(0, autocompletion::tclthreads());
+
+    /**
+        @brief A struct containing all information about a Tcl-interpreter
+    */
+    struct TclInterpreterBundle
+    {
+        TclInterpreterBundle()
+        {
+            this->lock_ = new boost::unique_lock<boost::mutex>(this->mutex_, boost::defer_lock);
+            this->bRunning_ = true;
+        }
+
+        ~TclInterpreterBundle()
+        {
+            delete this->lock_;
+        }
+
+        unsigned int                      id_;             ///< The id of the interpreter
+        Tcl::interpreter*                 interpreter_;    ///< The Tcl-interpreter
+        boost::mutex                      mutex_;          ///< A mutex to lock the interpreter while it's being used
+        boost::unique_lock<boost::mutex>* lock_;           ///< The corresponding lock for the mutex
+        TclThreadList<std::string>        queue_;          ///< The command queue for commands passed by execute(command)
+        TclThreadList<unsigned int>       queriers_;       ///< A list containing the id's of all other threads sending a query to this interpreter (to avoid circular queries and deadlocks)
+        bool                              bRunning_;       ///< This variable stays true until destroy() gets called
+    };
+
+    TclThreadManager* TclThreadManager::singletonPtr_s = 0;
+
+    /**
+        @brief Constructor
+        @param interpreter A pointer to the standard Tcl-interpreter (see @ref TclBind)
+    */
+    TclThreadManager::TclThreadManager(Tcl::interpreter* interpreter)
+    {
+        this->numInterpreterBundles_ = 0;
+
+        this->interpreterBundlesMutex_ = new boost::shared_mutex();
+        this->mainInterpreterMutex_ = new boost::mutex();
+        this->messageQueue_ = new TclThreadList<std::string>();
+
+        TclInterpreterBundle* newbundle = new TclInterpreterBundle();
+        newbundle->id_ = 0;
+        newbundle->interpreter_ = interpreter;
+        newbundle->lock_->lock();
+
+        {
+            boost::unique_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
+            this->interpreterBundles_[0] = newbundle;
+        }
+    }
+
+    /**
+        @brief Destructor
+    */
+    TclThreadManager::~TclThreadManager()
+    {
+        delete this->interpreterBundlesMutex_;
+//        delete this->mainInterpreterMutex_; // <-- temporary disabled to avoid crash if a thread is still actively queriyng
+        delete this->messageQueue_;
+    }
+
+    /**
+        @brief The "main loop" of the TclThreadManager. Creates new threads if needed and handles queries and queued commands for the main interpreter.
+    */
+    void TclThreadManager::preUpdate(const Clock& time)
+    {
+        // Get the bundle of the main interpreter (0)
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(0);
+        if (bundle)
+        {
+            // Unlock the mutex to allow other threads accessing the main interpreter
+            bundle->lock_->unlock();
+
+            // Lock the main interpreter mutex once to synchronize with threads that want to query the main interpreter
+            {
+                boost::unique_lock<boost::mutex> lock(*this->mainInterpreterMutex_);
+            }
+
+            // Lock the mutex again to gain exclusive access to the interpreter for the rest of the mainloop
+            bundle->lock_->lock();
+
+            // Execute commands in the queues of the threaded interpreters
+            {
+                boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
+                for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
+                {
+                    if (it->first == 0)
+                        continue; // We'll handle the default interpreter later (and without threads of course)
+
+                    TclInterpreterBundle* bundle = it->second;
+                    if (!bundle->queue_.empty())
+                    {
+                        // There are commands in the queue
+                        try
+                        {
+                            if (!bundle->lock_->owns_lock() && bundle->lock_->try_lock())
+                            {
+                                // We sucessfully obtained a lock for the interpreter
+                                std::string command;
+                                if (bundle->queue_.try_pop_front(&command))
+                                {
+                                    // Start a thread to execute the command
+                                    boost::thread(boost::bind(&tclThread, bundle, command));
+                                }
+                                else
+                                {
+                                    // Somehow the queue become empty (maybe multiple consumers) - unlock the mutex
+                                    bundle->lock_->unlock();
+                                }
+                            }
+                        }
+                        catch (...)
+                        {
+                            // A lock error occurred - this is possible if the lock gets locked between !bundle->lock_->owns_lock() and bundle->lock_->try_lock()
+                            // This isn't too bad, just continue
+                        }
+                    }
+                }
+            }
+
+            // Execute commands in the message queue
+            if (!this->messageQueue_->empty())
+            {
+                std::string command;
+                while (true)
+                {
+                    // Pop the front value from the list (break the loop if there are no elements in the list)
+                    if (!this->messageQueue_->try_pop_front(&command))
+                        break;
+
+                    // Execute the command
+                    CommandExecutor::execute(command, false);
+                }
+            }
+
+            // Execute commands in the queue of the main interpreter
+            if (!bundle->queue_.empty())
+            {
+                // Calculate the time we have until we reach the maximal cpu usage
+                unsigned long maxtime = (unsigned long)(time.getDeltaTime() * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
+
+                Ogre::Timer timer;
+                std::string command;
+
+                while (timer.getMicroseconds() < maxtime)
+                {
+                    // Pop the front value from the list (break the loop if there are no elements in the list)
+                    if (!bundle->queue_.try_pop_front(&command))
+                        break;
+
+                    // Execute the command
+                    CommandExecutor::execute(command, false);
+                }
+            }
+        }
+    }
+
+    /**
+        @brief Creates a new Tcl-interpreter.
+    */
+    unsigned int TclThreadManager::create()
+    {
+        TclThreadManager::getInstance().numInterpreterBundles_++;
+        TclThreadManager::createWithId(TclThreadManager::getInstance().numInterpreterBundles_);
+        COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().numInterpreterBundles_ << std::endl;
+        return TclThreadManager::getInstance().numInterpreterBundles_;
+    }
+
+    /**
+        @brief Creates a new Tcl-interpreter with a given id.
+
+        Use with caution - if the id collides with an already existing interpreter, this call will fail.
+        This will also be a problem, if the auto-numbered interpreters (by using create()) reach an id
+        which was previously used in this function. Use high numbers to be safe.
+    */
+    Tcl::interpreter* TclThreadManager::createWithId(unsigned int id)
+    {
+        TclInterpreterBundle* newbundle = new TclInterpreterBundle();
+        newbundle->id_ = id;
+        newbundle->interpreter_ = TclBind::createTclInterpreter();
+
+        TclThreadManager::initialize(newbundle);
+
+        {
+            // Add the new bundle to the map
+            boost::unique_lock<boost::shared_mutex> lock(*TclThreadManager::getInstance().interpreterBundlesMutex_);
+            TclThreadManager::getInstance().interpreterBundles_[id] = newbundle;
+        }
+
+        return newbundle->interpreter_;
+    }
+
+    void TclThreadManager::initialize(TclInterpreterBundle* bundle)
+    {
+        const std::string& id_string = getConvertedValue<unsigned int, std::string>(bundle->id_);
+
+        // Initialize the new interpreter
+        try
+        {
+            // Define the functions which are implemented in C++
+            bundle->interpreter_->def("::orxonox::execute",      TclThreadManager::tcl_execute,      Tcl::variadic());
+            bundle->interpreter_->def("::orxonox::crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic());
+            bundle->interpreter_->def("::orxonox::query",        TclThreadManager::tcl_query,        Tcl::variadic());
+            bundle->interpreter_->def("::orxonox::crossquery",   TclThreadManager::tcl_crossquery,   Tcl::variadic());
+            bundle->interpreter_->def("::orxonox::running",      TclThreadManager::tcl_running);
+
+            // Create threadspecific shortcuts for the functions above
+            bundle->interpreter_->def("execute",      TclThreadManager::tcl_execute,      Tcl::variadic());
+            bundle->interpreter_->def("crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic());
+            bundle->interpreter_->eval("proc query      {args}    { ::orxonox::query " + id_string + " $args }");
+            bundle->interpreter_->eval("proc crossquery {id args} { ::orxonox::crossquery " + id_string + " $id $args }");
+            bundle->interpreter_->eval("proc running    {}        { return [::orxonox::running " + id_string + "] }");
+
+            // Define a variable containing the thread id
+            bundle->interpreter_->eval("set id " + id_string);
+
+            // Use our own exit function to avoid shutting down the whole program instead of just the interpreter
+            bundle->interpreter_->eval("rename exit ::tcl::exit");
+            bundle->interpreter_->eval("proc exit {} { execute TclThreadManager destroy " + id_string + " }");
+
+            // Redefine some native functions
+            bundle->interpreter_->eval("rename while ::tcl::while");
+            bundle->interpreter_->eval("rename ::orxonox::while while");
+            bundle->interpreter_->eval("rename for ::tcl::for");
+            bundle->interpreter_->eval("rename ::orxonox::for for");
+        }
+        catch (const Tcl::tcl_error& e)
+        {   bundle->interpreter_ = 0; COUT(1) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl;   }
+    }
+
+    /**
+        @brief Stops and destroys a given Tcl-interpreter
+    */
+    void TclThreadManager::destroy(unsigned int id)
+    {
+        // TODO
+        // Not yet implemented
+        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(id);
+        if (bundle)
+        {
+            bundle->bRunning_ = false;
+        }
+    }
+
+    /**
+        @brief Sends a command to the queue of a given Tcl-interpreter
+        @param id The id of the target interpreter
+        @param command The command to be sent
+    */
+    void TclThreadManager::execute(unsigned int target_id, const std::string& command)
+    {
+        TclThreadManager::getInstance()._execute(target_id, command);
+    }
+
+    /**
+        @brief This function can be called from Tcl to execute a console command.
+
+        Commands which shall be executed are put into a queue and processed as soon as the
+        main thread feels ready to do so. The queue may also be full which results in a temporary
+        suspension of the calling thread until the queue gets ready again.
+    */
+    void TclThreadManager::tcl_execute(const Tcl::object& args)
+    {
+        TclThreadManager::getInstance()._execute(0, stripEnclosingBraces(args.get()));
+    }
+
+    /**
+        @brief This function can be called from Tcl to send a command to the queue of any interpreter.
+        @param target_id The id of the target thread
+    */
+    void TclThreadManager::tcl_crossexecute(int target_id, const Tcl::object& args)
+    {
+        TclThreadManager::getInstance()._execute(static_cast<unsigned int>(target_id), stripEnclosingBraces(args.get()));
+    }
+
+    /**
+        @brief Sends a command to the queue of a given Tcl-interpreter
+        @param id The id of the target interpreter
+        @param command The command to be sent
+    */
+    void TclThreadManager::_execute(unsigned int target_id, const std::string& command)
+    {
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(target_id);
+        if (bundle)
+            bundle->queue_.push_back(command);
+    }
+
+
+    /**
+        @brief Sends a query to a given Tcl-interpreter and waits for the result
+        @param id The id of the target interpreter
+        @param command The command to be sent
+        @return The result of the command
+    */
+    std::string TclThreadManager::query(unsigned int target_id, const std::string& command)
+    {
+        return TclThreadManager::getInstance()._query(0, target_id, command);
+    }
+
+    /**
+        @brief This function can be called from Tcl to send a query to the main thread.
+        @param source_id The id of the calling thread
+
+        A query waits for the result of the command. This means, the calling thread will be blocked until
+        the main thread answers the query. In return, the main thread sends the result of the console
+        command back to Tcl.
+    */
+    std::string TclThreadManager::tcl_query(int source_id, const Tcl::object& args)
+    {
+        return TclThreadManager::getInstance()._query(static_cast<unsigned int>(source_id), 0, stripEnclosingBraces(args.get()), true);
+    }
+
+    /**
+        @brief This function can be called from Tcl to send a query to another thread.
+        @param source_id The id of the calling thread
+        @param target_id The id of the target thread
+    */
+    std::string TclThreadManager::tcl_crossquery(int source_id, int target_id, const Tcl::object& args)
+    {
+        return TclThreadManager::getInstance()._query(static_cast<unsigned int>(source_id), static_cast<unsigned int>(target_id), stripEnclosingBraces(args.get()));
+    }
+
+    /**
+        @brief This function performs a query to any Tcl interpreter
+        @param source_id The id of the calling thread
+        @param target_id The id of the target thread
+        @param command The command to send as a query
+        @param bUseCommandExecutor Only used if the target_id is 0 (which references the main interpreter). In this case it means if the command should be passed to the CommandExecutor (true) or to the main Tcl interpreter (false). This is true when called by tcl_query and false when called by tcl_crossquery.
+    */
+    std::string TclThreadManager::_query(unsigned int source_id, unsigned int target_id, const std::string& command, bool bUseCommandExecutor)
+    {
+        TclInterpreterBundle* source_bundle = this->getInterpreterBundle(source_id);
+        TclInterpreterBundle* target_bundle = this->getInterpreterBundle(target_id);
+        std::string output;
+
+        if (source_bundle && target_bundle)
+        {
+            // At this point we assume the mutex of source_bundle to be locked (because it's executing this query right now an waits for the return value)
+            // We can safely use it's querier list (because there's no other place in the code using the list except this query - and the interpreter can't start more than one query)
+
+            if ((source_bundle->id_ == target_bundle->id_) || source_bundle->queriers_.is_in(target_bundle->id_))
+            {
+                // 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_) \
+                            + " -> " + 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_) + '.');
+            }
+            else
+            {
+                boost::unique_lock<boost::mutex> lock(target_bundle->mutex_, boost::try_to_lock);
+                boost::unique_lock<boost::mutex> mainlock(*this->mainInterpreterMutex_, boost::defer_lock);
+
+                if (!lock.owns_lock() && source_bundle->id_ != 0)
+                {
+                    // We couldn't obtain the try_lock immediately and we're not the main interpreter - wait until the lock becomes possible (note: the main interpreter won't wait and instead returns an error - see below)
+                    if (target_bundle->id_ == 0)
+                    {
+                        // We're querying the main interpreter - use the main interpreter mutex to synchronize
+                        mainlock.lock();
+                        lock.lock();
+                    }
+                    else
+                    {
+                        // We're querying a threaded interpreter - no synchronization needed
+                        lock.lock();
+                    }
+                }
+
+                if (lock.owns_lock())
+                {
+                    // Now the mutex of target_bundle is also locked an we can update the querier list
+                    target_bundle->queriers_.insert(target_bundle->queriers_.getList().begin(), source_bundle->queriers_.getList().begin(), source_bundle->queriers_.getList().end());
+                    target_bundle->queriers_.push_back(source_bundle->id_);
+
+                    // Perform the query (note: this happens in the main thread because we need the returnvalue)
+                    if (target_bundle->id_ == 0 && bUseCommandExecutor)
+                    {
+                        // It's a query to the CommandExecutor
+                        TclThreadManager::debug("TclThread_query -> CE: " + command);
+                        int error;
+                        output = CommandExecutor::query(command, &error, false);
+                        switch (error)
+                        {
+                            case CommandExecutor::Error:       TclThreadManager::error("Error: Can't execute command \"" + command + "\", command doesn't exist. (T)"); break;
+                            case CommandExecutor::Incomplete:  TclThreadManager::error("Error: Can't execute command \"" + command + "\", not enough arguments given. (T)"); break;
+                            case CommandExecutor::Deactivated: TclThreadManager::error("Error: Can't execute command \"" + command + "\", command is not active. (T)"); break;
+                            case CommandExecutor::Denied:      TclThreadManager::error("Error: Can't execute command \"" + command + "\", access denied. (T)"); break;
+                        }
+                    }
+                    else
+                    {
+                        // It's a query to a Tcl interpreter
+                        TclThreadManager::debug("TclThread_query: " + command);
+
+                        output = TclThreadManager::eval(target_bundle, command, "query");
+                    }
+
+                    // Clear the queriers list of the target
+                    target_bundle->queriers_.clear();
+
+                    // Unlock the mutex of the target_bundle
+                    lock.unlock();
+
+                    // Finally unlock the main interpreter lock if necessary
+                    if (mainlock.owns_lock())
+                        mainlock.unlock();
+                }
+                else
+                {
+                    // This happens if the main thread tries to query a busy interpreter
+                    // To avoid a lock of the main thread, we simply don't proceed with the query in this case
+                    TclThreadManager::error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target_bundle->id_) + ", interpreter is busy right now.");
+                }
+            }
+
+        }
+
+        return output;
+    }
+
+    /**
+        @brief Creates a non-interactive Tcl-interpreter which executes a file.
+    */
+    void TclThreadManager::source(const std::string& file)
+    {
+        boost::thread(boost::bind(&sourceThread, file));
+    }
+
+    /**
+        @brief This function can be called from Tcl to ask if the thread is still suposed to be running.
+        @param id The id of the thread in question
+    */
+    bool TclThreadManager::tcl_running(int id)
+    {
+        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(static_cast<unsigned int>(id));
+        if (bundle)
+            return bundle->bRunning_;
+        else
+            return false;
+    }
+
+    /**
+        @brief Returns the interpreter bundle with the given id.
+        @param id The id of the interpreter
+        @return The interpreter or 0 if the id doesn't exist
+    */
+    TclInterpreterBundle* TclThreadManager::getInterpreterBundle(unsigned int id)
+    {
+        boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
+
+        std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.find(id);
+        if (it != this->interpreterBundles_.end())
+        {
+            return it->second;
+        }
+        else
+        {
+            TclThreadManager::error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(id) + " existing.");
+            return 0;
+        }
+    }
+
+    /**
+        @brief Returns a string containing all elements of a unsigned-integer-list separated by spaces.
+    */
+    std::string TclThreadManager::dumpList(const std::list<unsigned int>& list)
+    {
+        std::string output;
+        for (std::list<unsigned int>::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            if (it != list.begin())
+                output += ' ';
+
+            output += getConvertedValue<unsigned int, std::string>(*it);
+        }
+        return output;
+    }
+
+    /**
+        @brief Returns a list with the numbers of all existing Tcl-interpreters.
+
+        This function is used by the auto completion function.
+    */
+    std::list<unsigned int> TclThreadManager::getThreadList() const
+    {
+        boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
+
+        std::list<unsigned int> threads;
+        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
+            if (it->first > 0 && it->first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters)
+                threads.push_back(it->first);
+        return threads;
+    }
+
+    /**
+        @brief A helper function to print errors in a thread safe manner.
+    */
+    void TclThreadManager::error(const std::string& error)
+    {
+        TclThreadManager::getInstance().messageQueue_->push_back("error " + error);
+    }
+
+    /**
+        @brief A helper function to print debug information in a thread safe manner.
+    */
+    void TclThreadManager::debug(const std::string& error)
+    {
+        TclThreadManager::getInstance().messageQueue_->push_back("debug " + error);
+    }
+
+    /**
+        @brief Evaluates a Tcl command without throwing exceptions (which may rise problems on certain machines).
+        @return The Tcl return value
+
+        Errors are reported through the @ref error function.
+    */
+    std::string TclThreadManager::eval(TclInterpreterBundle* bundle, const std::string& command, const std::string& action)
+    {
+        Tcl_Interp* interpreter = bundle->interpreter_->get();
+        int cc = Tcl_Eval(interpreter, command.c_str());
+
+        Tcl::details::result result(interpreter);
+
+        if (cc != TCL_OK)
+        {
+            TclThreadManager::error("Tcl error (" + action + ", ID " + getConvertedValue<unsigned int, std::string>(bundle->id_) + "): " + static_cast<std::string>(result));
+            return "";
+        }
+        else
+        {
+            return result;
+        }
+    }
+
+    ////////////////
+    // The Thread //
+    ////////////////
+
+    /**
+        @brief The main function of the thread. Executes a Tcl command.
+        @param bundle The interpreter bundle containing all necessary variables
+        @param command the Command to execute
+    */
+    void tclThread(TclInterpreterBundle* bundle, const std::string& command)
+    {
+        TclThreadManager::debug("TclThread_execute: " + command);
+
+        TclThreadManager::eval(bundle, command, "execute");
+
+        bundle->lock_->unlock();
+    }
+
+    /**
+        @brief The main function of a non-interactive source thread. Executes the file.
+        @param file The name of the file that should be executed by the non-interactive interpreter.
+    */
+    void sourceThread(const std::string& file)
+    {
+        TclThreadManager::debug("TclThread_source: " + file);
+
+        // Prepare the command-line arguments
+        const int argc = 2;
+        char* argv[argc];
+        argv[0] = const_cast<char*>("tclthread");
+        argv[1] = const_cast<char*>(file.c_str());
+
+        // Start the Tcl-command Tcl_Main with the Tcl_OrxonoxAppInit hook
+        Tcl_Main(argc, argv, Tcl_OrxonoxAppInit);
+
+//        Tcl::object object(file);
+//        int cc = Tcl_FSEvalFile(bundle->interpreter_->get(), object.get_object());
+//        Tcl::details::result result(bundle->interpreter_->get());
+//        if (cc != TCL_OK)
+//            TclThreadManager::error("Tcl error (source, ID " + getConvertedValue<unsigned int, std::string>(bundle->id_) + "): " + static_cast<std::string>(result));
+//
+//        // Unlock the mutex
+//        bundle->lock_->unlock();
+    }
+
+    /**
+        @brief A tcl-init hook to inject the non-interactive Tcl-interpreter into the TclThreadManager.
+    */
+    int Tcl_OrxonoxAppInit(Tcl_Interp* interp)
+    {
+        // Create a new interpreter bundle
+        unsigned int id = TclThreadManager::create();
+        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(id);
+
+        // Replace the default interpreter in the bundle with the non-interactive one (passed as an argument to this function)
+        if (bundle->interpreter_)
+            delete bundle->interpreter_;
+        bundle->interpreter_ = new Tcl::interpreter(interp, true);
+
+        // Initialize the non-interactive interpreter (like in @ref TclBind::createTclInterpreter but exception safe)
+        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");
+
+        // Initialize the non-interactive interpreter also with the thread-specific stuff
+        TclThreadManager::initialize(bundle);
+
+        // Lock the mutex (this will be locked until the thread finishes - no chance to interact with the interpreter)
+        bundle->lock_->lock();
+
+        // Return to Tcl_Main
+        if (!bundle->interpreter_)
+            return TCL_ERROR;
+        else
+            return cc;
+    }
+}
Index: code/trunk/src/libraries/core/command/TclThreadManager.h
===================================================================
--- code/trunk/src/libraries/core/command/TclThreadManager.h	(revision 7284)
+++ code/trunk/src/libraries/core/command/TclThreadManager.h	(revision 7284)
@@ -0,0 +1,101 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _TclThreadManager_H__
+#define _TclThreadManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <cassert>
+#include <list>
+#include <map>
+#include <string>
+
+#include "util/Singleton.h"
+
+struct Tcl_Interp;
+
+namespace orxonox
+{
+    class _CoreExport TclThreadManager : public Singleton<TclThreadManager>
+    {
+        friend class Singleton<TclThreadManager>;
+        friend class TclBind;
+        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);
+
+        public:
+            TclThreadManager(Tcl::interpreter* interpreter);
+            virtual ~TclThreadManager();
+
+            static unsigned int      create();
+            static Tcl::interpreter* createWithId(unsigned int id);
+            static void              destroy(unsigned int id);
+            static void              execute(unsigned int target_id, const std::string& command);
+            static std::string       query(unsigned int target_id, const std::string& command);
+            static void              source(const std::string& file);
+
+            static void error(const std::string& error);
+            static void debug(const std::string& error);
+
+            void preUpdate(const Clock& time);
+
+            std::list<unsigned int> getThreadList() const;
+
+        private:
+            static void tcl_execute(const Tcl::object& args);
+            static void tcl_crossexecute(int target_id, const Tcl::object& args);
+            static std::string tcl_query(int source_id, const Tcl::object& args);
+            static std::string tcl_crossquery(int source_id, int target_id, const Tcl::object& args);
+            static bool tcl_running(int id);
+
+            void _execute(unsigned int target_id, const std::string& command);
+            std::string _query(unsigned int source_id, unsigned int target_id, const std::string& command, bool bUseCommandExecutor = false);
+
+            TclInterpreterBundle* getInterpreterBundle(unsigned int id);
+            std::string dumpList(const std::list<unsigned int>& list);
+
+            static void initialize(TclInterpreterBundle* bundle);
+            static std::string eval(TclInterpreterBundle* bundle, const std::string& command, const std::string& action);
+
+            static TclThreadManager* singletonPtr_s;                            ///< Singleton pointer
+
+            unsigned int numInterpreterBundles_;                                ///< Number of created Tcl-interpreters (only used for auto-numbered interpreters, not affected by @ref createWithId)
+            std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;  ///< A map containing all Tcl-interpreters
+            boost::shared_mutex* interpreterBundlesMutex_;                      ///< A mutex used to synchronize threads when accessing @ref interpreterBundles_
+            TclThreadList<std::string>* messageQueue_;                          ///< A queue to pass messages from Tcl-threads to the main thread
+            boost::mutex* mainInterpreterMutex_;                                ///< A mutex to synchronize queries to the main interpreter
+    };
+
+    _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
+    _CoreExport void sourceThread(const std::string& file);
+    _CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
+}
+
+#endif /* _TclThreadManager_H__ */
Index: code/trunk/src/libraries/core/input/Button.cc
===================================================================
--- code/trunk/src/libraries/core/input/Button.cc	(revision 7278)
+++ code/trunk/src/libraries/core/input/Button.cc	(revision 7284)
@@ -39,7 +39,7 @@
 #include "util/StringUtils.h"
 #include "util/Debug.h"
-#include "core/ConsoleCommand.h"
-#include "core/CommandEvaluation.h"
-#include "core/CommandExecutor.h"
+#include "core/command/ConsoleCommand.h"
+#include "core/command/CommandEvaluation.h"
+#include "core/command/CommandExecutor.h"
 #include "core/ConfigFileManager.h"
 
@@ -117,5 +117,5 @@
         // separate the commands
         SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
-            '\\', false, '"', false, '(', ')', false, '\0');
+            '\\', false, '"', false, '{', '}', false, '\0');
 
         for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
@@ -124,5 +124,5 @@
             {
                 SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
-                    '\\', false, '"', false, '(', ')', false, '\0');
+                    '\\', false, '"', false, '{', '}', false, '\0');
 
                 KeybindMode::Value mode = KeybindMode::None;
@@ -175,6 +175,6 @@
 
                 // evaluate the command
-                const CommandEvaluation& eval = CommandExecutor::evaluate(commandStr);
-                if (!eval.isValid())
+                CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
+                if (!eval.isValid() || eval.evaluateParams(true))
                 {
                     parseError("Command evaluation of \"" + commandStr + "\"failed.", true);
Index: code/trunk/src/libraries/core/input/HalfAxis.cc
===================================================================
--- code/trunk/src/libraries/core/input/HalfAxis.cc	(revision 7278)
+++ code/trunk/src/libraries/core/input/HalfAxis.cc	(revision 7284)
@@ -34,5 +34,5 @@
 
 #include "HalfAxis.h"
-#include "core/CommandEvaluation.h"
+#include "core/command/CommandEvaluation.h"
 
 namespace orxonox
Index: code/trunk/src/libraries/core/input/InputCommands.h
===================================================================
--- code/trunk/src/libraries/core/input/InputCommands.h	(revision 7278)
+++ code/trunk/src/libraries/core/input/InputCommands.h	(revision 7284)
@@ -37,5 +37,5 @@
 
 #include "InputPrereqs.h"
-#include "core/CommandEvaluation.h"
+#include "core/command/CommandEvaluation.h"
 
 namespace orxonox
Index: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc	(revision 7278)
+++ code/trunk/src/libraries/core/input/InputManager.cc	(revision 7284)
@@ -47,8 +47,8 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
-#include "core/ConsoleCommand.h"
 #include "core/CommandLineParser.h"
-#include "core/Functor.h"
 #include "core/GraphicsManager.h"
+#include "core/command/ConsoleCommand.h"
+#include "core/command/Functor.h"
 
 #include "InputBuffer.h"
@@ -61,4 +61,11 @@
 {
     SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard");
+
+    static const std::string __CC_InputManager_name = "InputManager";
+    static const std::string __CC_calibrate_name = "calibrate";
+    static const std::string __CC_reload_name = "reload";
+
+    SetConsoleCommand(__CC_InputManager_name, __CC_calibrate_name, &InputManager::calibrate).addShortcut();
+    SetConsoleCommand(__CC_InputManager_name, __CC_reload_name,    &InputManager::reload   );
 
     // Abuse of this source file for the InputHandler
@@ -118,8 +125,6 @@
         this->updateActiveStates();
 
-        // calibrate console command
-        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true);
-        // reload console command
-        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false);
+        ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(this);
+        ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this);
 
         CCOUT(4) << "Construction complete." << std::endl;
@@ -287,4 +292,8 @@
         if (!(internalState_ & Bad))
             this->destroyDevices();
+
+        // Reset console commands
+        ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(0);
+        ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0);
 
         CCOUT(3) << "Destruction complete." << std::endl;
Index: code/trunk/src/libraries/core/input/InputState.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputState.cc	(revision 7278)
+++ code/trunk/src/libraries/core/input/InputState.cc	(revision 7284)
@@ -28,5 +28,5 @@
 
 #include "InputState.h"
-#include "core/Functor.h"
+#include "core/command/Functor.h"
 
 namespace orxonox
Index: code/trunk/src/libraries/core/input/InputState.h
===================================================================
--- code/trunk/src/libraries/core/input/InputState.h	(revision 7278)
+++ code/trunk/src/libraries/core/input/InputState.h	(revision 7284)
@@ -150,7 +150,7 @@
         void left();
         //! Sets a functor to be called upon activation of the state
-        void setEnterFunctor(Functor* functor) { this->enterFunctor_ = functor; }
+        void setEnterFunctor(const FunctorPtr& functor) { this->enterFunctor_ = functor; }
         //! Sets a functor to be called upon deactivation of the state
-        void setLeaveFunctor(Functor* functor) { this->leaveFunctor_ = functor; }
+        void setLeaveFunctor(const FunctorPtr& functor) { this->leaveFunctor_ = functor; }
 
     private:
@@ -172,6 +172,6 @@
         //! Handler to be used for all joy sticks (needs to be saved in case another joy stick gets attached)
         InputHandler*               joyStickHandlerAll_;
-        Functor*                    enterFunctor_;          //!< Functor to be executed on enter
-        Functor*                    leaveFunctor_;          //!< Functor to be executed on leave
+        FunctorPtr                  enterFunctor_;          //!< Functor to be executed on enter
+        FunctorPtr                  leaveFunctor_;          //!< Functor to be executed on leave
     };
 
Index: code/trunk/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.cc	(revision 7278)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.cc	(revision 7284)
@@ -31,8 +31,9 @@
 #include "util/Debug.h"
 #include "util/Exception.h"
+#include "util/ScopedSingletonManager.h"
 #include "core/ConfigValueIncludes.h"
-#include "core/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
+#include "core/LuaState.h"
+#include "core/command/ConsoleCommand.h"
 #include "InputManager.h"
 #include "KeyDetector.h"
@@ -41,4 +42,14 @@
 {
     ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false);
+
+    static const std::string __CC_keybind_name = "keybind";
+    static const std::string __CC_tkeybind_name = "tkeybind";
+    static const std::string __CC_unbind_name = "unbind";
+    static const std::string __CC_tunbind_name = "tunbind";
+
+    SetConsoleCommand(__CC_keybind_name,  &KeyBinderManager::keybind).defaultValues("").argumentCompleter(0, autocompletion::command());
+    SetConsoleCommand(__CC_tkeybind_name, &KeyBinderManager::tkeybind).defaultValues("").argumentCompleter(0, autocompletion::command());
+    SetConsoleCommand(__CC_unbind_name,   &KeyBinderManager::unbind).defaultValues("");
+    SetConsoleCommand(__CC_tunbind_name,  &KeyBinderManager::tunbind).defaultValues("");
 
     KeyBinderManager::KeyBinderManager()
@@ -51,12 +62,8 @@
 
         // keybind console commands
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::keybind,  this), "keybind" ))
-            .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("");
+        ModifyConsoleCommand(__CC_keybind_name ).setObject(this);
+        ModifyConsoleCommand(__CC_tkeybind_name).setObject(this);
+        ModifyConsoleCommand(__CC_unbind_name  ).setObject(this);
+        ModifyConsoleCommand(__CC_tunbind_name ).setObject(this);
 
         // Load default key binder
@@ -69,4 +76,10 @@
         for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
             delete it->second;
+
+        // Reset console commands
+        ModifyConsoleCommand(__CC_keybind_name ).setObject(0);
+        ModifyConsoleCommand(__CC_tkeybind_name).setObject(0);
+        ModifyConsoleCommand(__CC_unbind_name  ).setObject(0);
+        ModifyConsoleCommand(__CC_tunbind_name ).setObject(0);
     }
 
@@ -156,5 +169,5 @@
         {
             COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-            KeyDetector::getInstance().setCallback(shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));
+            KeyDetector::getInstance().setCallback(createFunctor(&KeyBinderManager::keybindKeyPressed, this));
             InputManager::getInstance().enterState("detector");
             this->command_ = command;
@@ -187,3 +200,8 @@
         // else: A key was probably pressed within the same tick, ignore it.
     }
+
+    void KeyBinderManager::registerKeybindCallback(LuaFunctor* function)
+    {
+        this->callbackFunction_ = function;
+    }
 }
Index: code/trunk/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.h	(revision 7278)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.h	(revision 7284)
@@ -99,5 +99,5 @@
         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
+        void registerKeybindCallback(LuaFunctor* function); //tolua_export
 
     private:
@@ -114,5 +114,5 @@
 
         // keybind command related
-        shared_ptr<Functor> callbackFunction_;       //! Function to be called when key was pressed after "keybind" command
+        SharedPtr<LuaFunctor> 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
Index: code/trunk/src/libraries/core/input/KeyDetector.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyDetector.cc	(revision 7278)
+++ code/trunk/src/libraries/core/input/KeyDetector.cc	(revision 7284)
@@ -29,7 +29,7 @@
 #include "KeyDetector.h"
 
-#include "core/ConsoleCommand.h"
+#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
+#include "core/command/ConsoleCommand.h"
 #include "Button.h"
 #include "InputManager.h"
@@ -38,6 +38,8 @@
 namespace orxonox
 {
-    std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
     ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false);
+
+    static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed";
+    DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string).hide();
 
     KeyDetector::KeyDetector()
@@ -46,5 +48,6 @@
         RegisterObject(KeyDetector);
 
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback,  this), callbackCommand_s));
+        ModifyConsoleCommand(__CC_KeyDetector_callback_name).setFunction(&KeyDetector::callback, this);
+
         this->assignCommands();
 
@@ -59,4 +62,5 @@
         inputState_->setHandler(NULL);
         InputManager::getInstance().destroyState("detector");
+        ModifyConsoleCommand(__CC_KeyDetector_callback_name).resetFunction();
     }
 
@@ -65,5 +69,5 @@
         // Assign every button/axis the same command, but with its name as argument
         for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
-            it->second->parse(callbackCommand_s + ' ' + it->second->groupName_ + "." + it->second->name_);
+            it->second->parse(__CC_KeyDetector_callback_name + ' ' + it->second->groupName_ + "." + it->second->name_);
     }
 
Index: code/trunk/src/libraries/core/input/KeyDetector.h
===================================================================
--- code/trunk/src/libraries/core/input/KeyDetector.h	(revision 7278)
+++ code/trunk/src/libraries/core/input/KeyDetector.h	(revision 7284)
@@ -46,5 +46,5 @@
         ~KeyDetector();
 
-        void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }
+        void setCallback(const FunctorPtr& function) { this->callbackFunction_ = function; }
 
     private:
@@ -55,7 +55,6 @@
         void assignCommands();
 
-        shared_ptr<Functor> callbackFunction_;
+        FunctorPtr callbackFunction_;
         InputState* inputState_;
-        static std::string callbackCommand_s;
         static KeyDetector* singletonPtr_s;
     };
Index: code/trunk/src/libraries/core/input/Mouse.cc
===================================================================
--- code/trunk/src/libraries/core/input/Mouse.cc	(revision 7278)
+++ code/trunk/src/libraries/core/input/Mouse.cc	(revision 7284)
@@ -30,6 +30,6 @@
 
 #include <ois/OISMouse.h>
-#include "core/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
+#include "core/command/ConsoleCommand.h"
 #include "InputState.h"
 
@@ -41,4 +41,13 @@
 namespace orxonox
 {
+#ifdef ORXONOX_PLATFORM_LINUX
+    static const std::string __CC_Mouse_name = "Mouse";
+    static const std::string __CC_grab_name = "grab";
+    static const std::string __CC_ungrab_name = "ungrab";
+
+    SetConsoleCommand(__CC_Mouse_name, __CC_grab_name,   &Mouse::grab);
+    SetConsoleCommand(__CC_Mouse_name, __CC_ungrab_name, &Mouse::ungrab);
+#endif
+
     Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager)
         : super(id, oisInputManager)
@@ -48,8 +57,14 @@
 
 #ifdef ORXONOX_PLATFORM_LINUX
-        // Mouse grab console command
-        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::grab, this), "grab"), false);
-        // Mouse ungrab console command
-        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::ungrab, this), "ungrab"), false);
+        ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject(this);
+        ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject(this);
+#endif
+    }
+
+    Mouse::~Mouse()
+    {
+#ifdef ORXONOX_PLATFORM_LINUX
+        ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject(0);
+        ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject(0);
 #endif
     }
Index: code/trunk/src/libraries/core/input/Mouse.h
===================================================================
--- code/trunk/src/libraries/core/input/Mouse.h	(revision 7278)
+++ code/trunk/src/libraries/core/input/Mouse.h	(revision 7284)
@@ -64,5 +64,5 @@
         //! Only sets the clipping size. Initialising is done in the base class.
         Mouse(unsigned int id, OIS::InputManager* oisInputManager);
-        ~Mouse() { }
+        ~Mouse();
 
 #ifdef ORXONOX_PLATFORM_LINUX
Index: code/trunk/src/libraries/network/Client.cc
===================================================================
--- code/trunk/src/libraries/network/Client.cc	(revision 7278)
+++ code/trunk/src/libraries/network/Client.cc	(revision 7284)
@@ -45,4 +45,5 @@
 #include "util/Clock.h"
 #include "util/Debug.h"
+#include "util/ScopedSingletonManager.h"
 #include "synchronisable/Synchronisable.h"
 #include "packet/Chat.h"
@@ -52,5 +53,4 @@
 #include "core/CommandLineParser.h"
 #include "core/Game.h"
-#include "core/ScopedSingletonManager.h"
 
 namespace orxonox
@@ -107,5 +107,5 @@
     return ClientConnection::closeConnection();
   }
-  
+
   void Client::setDestination(const std::string& serverAddress, unsigned int port)
   {
Index: code/trunk/src/libraries/network/ClientConnection.cc
===================================================================
--- code/trunk/src/libraries/network/ClientConnection.cc	(revision 7278)
+++ code/trunk/src/libraries/network/ClientConnection.cc	(revision 7284)
@@ -149,6 +149,8 @@
   uint32_t ClientConnection::getRTT()
   {
-    assert(server_);
-    return server_->roundTripTime;
+    if (server_)
+        return server_->roundTripTime;
+    else
+        return 0;
   }
 
Index: code/trunk/src/libraries/network/GamestateManager.cc
===================================================================
--- code/trunk/src/libraries/network/GamestateManager.cc	(revision 7278)
+++ code/trunk/src/libraries/network/GamestateManager.cc	(revision 7284)
@@ -47,6 +47,6 @@
 
 #include "util/Debug.h"
-#include "core/Executor.h"
 #include "core/ThreadPool.h"
+#include "core/command/Executor.h"
 #include "ClientInformation.h"
 #include "packet/Acknowledgement.h"
Index: code/trunk/src/libraries/network/Host.cc
===================================================================
--- code/trunk/src/libraries/network/Host.cc	(revision 7278)
+++ code/trunk/src/libraries/network/Host.cc	(revision 7284)
@@ -32,11 +32,14 @@
 #include <string>
 
-#include "core/ConsoleCommand.h"
 #include "core/ObjectList.h"
+#include "core/command/ConsoleCommand.h"
 #include "ChatListener.h"
 
 namespace orxonox {
 
-  SetConsoleCommandShortcut(Host, Chat);
+  static const std::string __CC_printRTT_name = "printRTT";
+
+  SetConsoleCommand("chat", &Host::Chat);
+  SetConsoleCommand(__CC_printRTT_name, &Host::printRTT);
 
   // Host*               Host::instance_=0;
@@ -52,6 +55,5 @@
   //   assert(instance_==0);
     instances_s.push_back(this);
-    this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" );
-    CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ );
+    ModifyConsoleCommand(__CC_printRTT_name).setObject(this);
     this->bIsActive_ = false;
   }
@@ -65,6 +67,5 @@
     assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
     instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
-    if( this->printRTTCC_ )
-      delete this->printRTTCC_;
+    ModifyConsoleCommand(__CC_printRTT_name).setObject(0);
   }
 
@@ -89,5 +90,5 @@
   }
 
-  bool Host::Chat(const std::string& message)
+  void Host::Chat(const std::string& message)
   {
     if(instances_s.size()==0)
@@ -95,5 +96,5 @@
       for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
         it->incomingChat(message, 0);
-      return true;
+//      return true;
     }
     else
@@ -108,5 +109,5 @@
         }
       }
-      return result;
+//      return result;
     }
   }
@@ -139,5 +140,5 @@
     for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
       it->incomingChat(message, playerID);
-    
+
     bool result = true;
     for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
Index: code/trunk/src/libraries/network/Host.h
===================================================================
--- code/trunk/src/libraries/network/Host.h	(revision 7278)
+++ code/trunk/src/libraries/network/Host.h	(revision 7284)
@@ -79,5 +79,5 @@
     static void setShipID(unsigned int id){ shipID_s = id; }
     static bool isServer();
-    static bool Chat(const std::string& message);
+    static void Chat(const std::string& message);
     static bool Broadcast(const std::string& message);
     static bool incomingChat(const std::string& message, unsigned int playerID);
@@ -85,5 +85,4 @@
     bool isActive(){ return bIsActive_; }
   private:
-    ConsoleCommand* printRTTCC_;
     static uint32_t clientID_s;
     static uint32_t shipID_s;
Index: code/trunk/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/LANDiscovery.cc	(revision 7278)
+++ code/trunk/src/libraries/network/LANDiscovery.cc	(revision 7284)
@@ -32,12 +32,12 @@
 #include <cstring>
 
+#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
 
 
 namespace orxonox
-{ 
+{
   ManageScopedSingleton(LANDiscovery, ScopeID::Root, true);
-  
+
   LANDiscovery::LANDiscovery()
   {
@@ -49,5 +49,5 @@
     enet_host_destroy(this->host_);
   }
-  
+
   void LANDiscovery::discover()
   {
@@ -56,8 +56,8 @@
     enet_address_set_host(&address, "255.255.255.255");
     address.port = LAN_DISCOVERY_PORT;
-    
+
     ENetPeer* peer;
     peer = enet_host_connect(this->host_, &address, 0);
-    
+
     ENetEvent event;
     while( enet_host_service(this->host_, &event, 1000 ) )
@@ -93,5 +93,5 @@
     }
   }
-  
+
   std::string LANDiscovery::getServerListItemName(unsigned int index)
   {
@@ -101,5 +101,5 @@
       return this->servers_[index].getServerName();
   }
-  
+
   std::string LANDiscovery::getServerListItemIP(unsigned int index)
   {
@@ -109,5 +109,5 @@
       return this->servers_[index].getServerIP();
   }
-  
-  
+
+
 } // namespace orxonox
Index: code/trunk/src/libraries/network/NetworkFunction.cc
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.cc	(revision 7278)
+++ code/trunk/src/libraries/network/NetworkFunction.cc	(revision 7284)
@@ -68,5 +68,5 @@
 
 
-  NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p):
+  NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
     NetworkFunctionBase(name)
   {
@@ -76,9 +76,4 @@
     NetworkFunctionStatic::getFunctorMap()[p] = this;
     NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
-  }
-
-  NetworkFunctionStatic::~NetworkFunctionStatic()
-  {
-    delete this->functor_;
   }
 
Index: code/trunk/src/libraries/network/NetworkFunction.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.h	(revision 7278)
+++ code/trunk/src/libraries/network/NetworkFunction.h	(revision 7284)
@@ -39,6 +39,6 @@
 #include <boost/static_assert.hpp>
 
-#include "core/Functor.h"
 #include "core/Identifier.h"
+#include "core/command/Functor.h"
 #include "FunctionCallManager.h"
 #include "synchronisable/Synchronisable.h"
@@ -102,6 +102,5 @@
 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
   public:
-    NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p);
-    ~NetworkFunctionStatic();
+    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p);
 
     inline void call(){ (*this->functor_)(); }
@@ -124,5 +123,5 @@
     static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
     static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
-    FunctorStatic* functor_;
+    FunctorStaticPtr functor_;
 
 };
@@ -155,6 +154,5 @@
 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
   public:
-    NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p);
-    ~NetworkMemberFunction();
+    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
 
     inline void call(uint32_t objectID)
@@ -190,14 +188,10 @@
 
   private:
-    FunctorMember<T>* functor_;
-};
-
-template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p):
+    FunctorMemberPtr<T> functor_;
+};
+
+template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):
     NetworkMemberFunctionBase(name, p), functor_(functor)
 {
-}
-template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()
-{
-  delete this->functor_;
 }
 
Index: code/trunk/src/libraries/network/Server.cc
===================================================================
--- code/trunk/src/libraries/network/Server.cc	(revision 7278)
+++ code/trunk/src/libraries/network/Server.cc	(revision 7284)
@@ -49,5 +49,5 @@
 #include "util/Debug.h"
 #include "core/ObjectList.h"
-#include "core/Executor.h"
+#include "core/command/Executor.h"
 #include "packet/Chat.h"
 #include "packet/ClassID.h"
Index: code/trunk/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 7278)
+++ code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 7284)
@@ -42,10 +42,11 @@
 #include "core/CorePrereqs.h"
 #include "core/CoreIncludes.h"
-#include "core/SmartPtr.h"
+#include "core/BaseObject.h" // remove this if circular dependencies in BaseObject/SmartPtr are fixed
+//#include "core/SmartPtr.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 )
@@ -53,5 +54,5 @@
       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 )
@@ -60,5 +61,5 @@
         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 )
@@ -70,5 +71,5 @@
         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 )
@@ -79,7 +80,7 @@
             return variable == variable->getSynchronisable(*(uint32_t*)(mem));
     }
-    
+
     // These functions implement loading / saving / etc. for SmartPtr<T>
-    
+
     /** @brief returns the size of the objectID needed to synchronise the pointer */
     template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable )
@@ -87,5 +88,5 @@
         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( const SmartPtr<T>& variable, uint8_t*& mem )
@@ -95,5 +96,5 @@
         mem += returnSize( variable );
     }
-    
+
     /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
     template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
@@ -105,5 +106,5 @@
         mem += returnSize( variable );
     }
-    
+
     /** @brief checks whether the objectID of the variable is the same as in the bytestream */
     template <class T> inline  bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
@@ -114,7 +115,7 @@
             return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
     }
-    
+
     // These functions implement loading / saving / etc. for WeakPtr<T>
-    
+
     /** @brief returns the size of the objectID needed to synchronise the pointer */
     template <class T> inline uint32_t returnSize( const WeakPtr<T>& variable )
@@ -122,5 +123,5 @@
         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( const WeakPtr<T>& variable, uint8_t*& mem )
@@ -130,5 +131,5 @@
         mem += returnSize( variable );
     }
-    
+
     /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
     template <class T> inline void saveAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
@@ -140,5 +141,5 @@
         mem += returnSize( variable );
     }
-    
+
     /** @brief checks whether the objectID of the variable is the same as in the bytestream */
     template <class T> inline  bool checkEquality( const WeakPtr<T>& variable, uint8_t* mem )
Index: code/trunk/src/libraries/tools/Timer.cc
===================================================================
--- code/trunk/src/libraries/tools/Timer.cc	(revision 7278)
+++ code/trunk/src/libraries/tools/Timer.cc	(revision 7284)
@@ -33,12 +33,12 @@
 #include "util/Clock.h"
 #include "core/CoreIncludes.h"
-#include "core/ConsoleCommand.h"
-#include "core/CommandExecutor.h"
-#include "core/Functor.h"
+#include "core/command/ConsoleCommand.h"
+#include "core/command/CommandExecutor.h"
+#include "core/command/Functor.h"
 
 namespace orxonox
 {
-    SetConsoleCommandShortcutExtern(delay);
-    SetConsoleCommandShortcutExtern(killdelays);
+    SetConsoleCommand("delay", &delay).argumentCompleter(1, autocompletion::command());
+    SetConsoleCommand("killdelays", &killdelays);
 
     static std::set<Timer*> delaytimerset;
@@ -54,5 +54,5 @@
         delaytimerset.insert(delaytimer);
 
-        ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
+        const ExecutorStaticPtr& delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
         delayexecutor->setDefaultValues(delaytimer, command);
         delaytimer->setTimer(delay, false, delayexecutor);
@@ -97,5 +97,5 @@
         @param exeuctor A executor of the function to call
     */
-    Timer::Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall)
+    Timer::Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall)
     {
         this->init();
@@ -103,12 +103,4 @@
 
         this->setTimer(interval, bLoop, executor, bKillAfterCall);
-    }
-
-    /**
-        @brief Deletes the executor.
-    */
-    Timer::~Timer()
-    {
-        this->deleteExecutor();
     }
 
@@ -138,13 +130,4 @@
         if (temp)
             this->destroy();
-    }
-
-    /**
-        @brief Deletes the executor.
-    */
-    void Timer::deleteExecutor()
-    {
-      if (this->executor_)
-          delete this->executor_;
     }
 
Index: code/trunk/src/libraries/tools/Timer.h
===================================================================
--- code/trunk/src/libraries/tools/Timer.h	(revision 7278)
+++ code/trunk/src/libraries/tools/Timer.h	(revision 7284)
@@ -44,5 +44,5 @@
 
     source.cc:
-        include "core/Executor.h"
+        #include "core/command/Executor.h"
 
         ClassName::ClassName()
@@ -63,6 +63,6 @@
 #include "tools/ToolsPrereqs.h"
 
-#include "core/Executor.h"
 #include "core/OrxonoxClass.h"
+#include "core/command/Executor.h"
 #include "tools/interfaces/TimeFactorListener.h"
 
@@ -78,7 +78,6 @@
         public:
             Timer();
-            ~Timer();
 
-            Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false);
+            Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false);
 
             /**
@@ -89,8 +88,6 @@
                 @param executor A executor of the function to call
             */
-            void setTimer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false)
+            void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false)
             {
-                this->deleteExecutor();
-
                 this->setInterval(interval);
                 this->bLoop_ = bLoop;
@@ -103,5 +100,4 @@
 
             void run();
-            void deleteExecutor();
 
             /** @brief Starts the Timer: Function-call after 'interval' seconds. */
@@ -141,12 +137,12 @@
             void init();
 
-            Executor* executor_;  //!< The executor of the function that should be called when the time expires
+            ExecutorPtr executor_;  //!< The executor of the function that should be called when the time expires
 
-            long long interval_;  //!< The time-interval in micro seconds
-            bool bLoop_;          //!< If true, the function gets called every 'interval' seconds
-            bool bActive_;        //!< If true, the Timer ticks and calls the function if the time's up
-            bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function
+            long long interval_;    //!< The time-interval in micro seconds
+            bool bLoop_;            //!< If true, the function gets called every 'interval' seconds
+            bool bActive_;          //!< If true, the Timer ticks and calls the function if the time's up
+            bool bKillAfterCall_;   //!< If true the timer gets deleted after it called the function
 
-            long long time_;      //!< Internal variable, counting the time till the next function-call
+            long long time_;        //!< Internal variable, counting the time till the next function-call
     };
 }
Index: code/trunk/src/libraries/util/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/util/CMakeLists.txt	(revision 7278)
+++ code/trunk/src/libraries/util/CMakeLists.txt	(revision 7284)
@@ -31,6 +31,9 @@
   CRC32.cc
   OutputHandler.cc
+  ScopedSingletonManager.cc
+  SharedPtr.cc
   SignalHandler.cc
   Sleep.cc
+  SmallObjectAllocator.cc
   SubString.cc
 COMPILATION_END
Index: code/trunk/src/libraries/util/Convert.h
===================================================================
--- code/trunk/src/libraries/util/Convert.h	(revision 7278)
+++ code/trunk/src/libraries/util/Convert.h	(revision 7284)
@@ -109,4 +109,32 @@
         }
     };
+
+    ////////////
+    // upcast //
+    ////////////
+    namespace detail
+    {
+        // perform a static cast if ToType is a base of FromType
+        template<class ToType, class FromType>
+        FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<true>)
+        {
+            return static_cast<ToType>(input);
+        }
+
+        // return zero if ToType is not a base of FromType
+        template<class ToType, class FromType>
+        FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<false>)
+        {
+            return 0;
+        }
+    }
+
+    // performs an upcast if ToType is a base of FromType, returns zero otherwise
+    template <class ToType, class FromType>
+    FORCEINLINE ToType upcast(FromType input)
+    {
+        enum { probe = ImplicitConversion<FromType, ToType>::exists };
+        return detail::upcast<ToType, FromType>(input, Loki::Int2Type<probe>());
+    }
 }
 
Index: code/trunk/src/libraries/util/Math.cc
===================================================================
--- code/trunk/src/libraries/util/Math.cc	(revision 7278)
+++ code/trunk/src/libraries/util/Math.cc	(revision 7284)
@@ -234,6 +234,6 @@
     bool ConverterFallback<std::string, orxonox::Vector2>::convert(orxonox::Vector2* output, const std::string& input)
     {
-        size_t opening_parenthesis, closing_parenthesis = input.find(')');
-        if ((opening_parenthesis = input.find('(')) == std::string::npos)
+        size_t opening_parenthesis, closing_parenthesis = input.find('}');
+        if ((opening_parenthesis = input.find('{')) == std::string::npos)
             opening_parenthesis = 0;
         else
@@ -257,6 +257,6 @@
     bool ConverterFallback<std::string, orxonox::Vector3>::convert(orxonox::Vector3* output, const std::string& input)
     {
-        size_t opening_parenthesis, closing_parenthesis = input.find(')');
-        if ((opening_parenthesis = input.find('(')) == std::string::npos)
+        size_t opening_parenthesis, closing_parenthesis = input.find('}');
+        if ((opening_parenthesis = input.find('{')) == std::string::npos)
             opening_parenthesis = 0;
         else
@@ -282,6 +282,6 @@
     bool ConverterFallback<std::string, orxonox::Vector4>::convert(orxonox::Vector4* output, const std::string& input)
     {
-        size_t opening_parenthesis, closing_parenthesis = input.find(')');
-        if ((opening_parenthesis = input.find('(')) == std::string::npos)
+        size_t opening_parenthesis, closing_parenthesis = input.find('}');
+        if ((opening_parenthesis = input.find('{')) == std::string::npos)
             opening_parenthesis = 0;
         else
@@ -309,6 +309,9 @@
     bool ConverterFallback<std::string, orxonox::Quaternion>::convert(orxonox::Quaternion* output, const std::string& input)
     {
-        size_t opening_parenthesis, closing_parenthesis = input.find(')');
-        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+        size_t opening_parenthesis, closing_parenthesis = input.find('}');
+        if ((opening_parenthesis = input.find('{')) == std::string::npos)
+            opening_parenthesis = 0;
+        else
+            opening_parenthesis++;
 
         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
@@ -332,6 +335,9 @@
     bool ConverterFallback<std::string, orxonox::ColourValue>::convert(orxonox::ColourValue* output, const std::string& input)
     {
-        size_t opening_parenthesis, closing_parenthesis = input.find(')');
-        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+        size_t opening_parenthesis, closing_parenthesis = input.find('}');
+        if ((opening_parenthesis = input.find('{')) == std::string::npos)
+            opening_parenthesis = 0;
+        else
+            opening_parenthesis++;
 
         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
Index: code/trunk/src/libraries/util/MultiType.h
===================================================================
--- code/trunk/src/libraries/util/MultiType.h	(revision 7278)
+++ code/trunk/src/libraries/util/MultiType.h	(revision 7284)
@@ -77,4 +77,5 @@
 #include <OgreColourValue.h>
 #include <loki/TypeTraits.h>
+#include "mbool.h"
 
 namespace orxonox
@@ -265,4 +266,5 @@
             inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
             inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+            inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     /** @brief Constructor: Assigns the given mbool and converts it to bool. */
             inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */
             inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
@@ -318,5 +320,5 @@
             inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
 
-            template <typename T> inline bool convert()                       { return this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */
+            template <typename T> inline bool convert()                       { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this));  } /** @brief Converts the current value to type T. */
             inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
             bool                              convert(MT_Type::Value type);
@@ -350,5 +352,8 @@
 
             /** @brief Checks whether the value is a default one. */
-            bool                              hasDefaultValue()         const { return this->value_->hasDefaultValue(); }
+            bool                              hasDefaultValue() const { return this->value_->hasDefaultValue(); }
+
+            /** @brief Checks if the MT contains no value. */
+            bool                              null() const { return (!this->value_); }
 
             operator char()                  const;
@@ -487,4 +492,6 @@
     template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_Type::Degree);           } /** @brief Returns true if the current type equals the given type. */
 
+    template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */
+
     // Specialization to avoid ambiguities with the conversion operator
     template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */
Index: code/trunk/src/libraries/util/OutputHandler.h
===================================================================
--- code/trunk/src/libraries/util/OutputHandler.h	(revision 7278)
+++ code/trunk/src/libraries/util/OutputHandler.h	(revision 7284)
@@ -104,22 +104,22 @@
 
             //! Writes to all output devices
-            static inline const std::string& log(const std::string& text)
-                { OutputHandler::getOutStream(0).output(text) << std::endl; return text; }
+            static inline void log(const std::string& text)
+                { OutputHandler::getOutStream(0).output(text) << std::endl; }
 
             //! Writes an error message to the output
-            static inline const std::string& error(const std::string& text)
-                { OutputHandler::getOutStream(1).output(text) << std::endl; return text; }
+            static inline void error(const std::string& text)
+                { OutputHandler::getOutStream(1).output(text) << std::endl; }
 
             //! Writes a warning message to the output
-            static inline const std::string& warning(const std::string& text)
-                { OutputHandler::getOutStream(2).output(text) << std::endl; return text; }
+            static inline void warning(const std::string& text)
+                { OutputHandler::getOutStream(2).output(text) << std::endl; }
 
             //! Writes an informational message to the output
-            static inline const std::string& info(const std::string& text)
-                { OutputHandler::getOutStream(3).output(text) << std::endl; return text; }
+            static inline void info(const std::string& text)
+                { OutputHandler::getOutStream(3).output(text) << std::endl; }
 
             //! Writes a debug message to the output
-            static inline const std::string& debug(const std::string& text)
-                { OutputHandler::getOutStream(4).output(text) << std::endl; return text; }
+            static inline void debug(const std::string& text)
+                { OutputHandler::getOutStream(4).output(text) << std::endl; }
 
             //! Registers an object that receives output via a provided std::ostream
Index: code/trunk/src/libraries/util/ScopedSingletonManager.cc
===================================================================
--- code/trunk/src/libraries/util/ScopedSingletonManager.cc	(revision 7284)
+++ code/trunk/src/libraries/util/ScopedSingletonManager.cc	(revision 7284)
@@ -0,0 +1,49 @@
+/*
+ *   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 "ScopedSingletonManager.h"
+
+namespace orxonox
+{
+    /*static*/ std::map<std::string, ScopedSingletonManager*>& ScopedSingletonManager::getManagers()
+    {
+        static std::map<std::string, ScopedSingletonManager*> managers;
+        return managers;
+    }
+    /*static*/ ScopedSingletonManager::ManagerMultiMap& ScopedSingletonManager::getManagersByScope()
+    {
+        static ManagerMultiMap managers;
+        return managers;
+    }
+
+    /*static*/ void ScopedSingletonManager::addManager(ScopedSingletonManager* manager)
+    {
+        getManagers()[manager->className_] = manager;
+        getManagersByScope().insert(std::make_pair(manager->scope_, manager));
+    }
+}
Index: code/trunk/src/libraries/util/ScopedSingletonManager.h
===================================================================
--- code/trunk/src/libraries/util/ScopedSingletonManager.h	(revision 7284)
+++ code/trunk/src/libraries/util/ScopedSingletonManager.h	(revision 7284)
@@ -0,0 +1,214 @@
+/*
+ *   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 __ScopedSingletonManager_H__
+#define __ScopedSingletonManager_H__
+
+#include "UtilPrereqs.h"
+
+#include <cassert>
+#include <map>
+#include "util/Exception.h"
+#include "util/Scope.h"
+#include "util/Singleton.h"
+
+#define ManageScopedSingleton(className, scope, allowedToFail) \
+    className* className::singletonPtr_s = NULL; \
+    static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
+
+namespace orxonox
+{
+    class OrxonoxClass;
+
+    class _UtilExport ScopedSingletonManager
+    {
+        public:
+            ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
+                : className_(className)
+                , scope_(scope)
+            { }
+            virtual ~ScopedSingletonManager() { }
+            static void addManager(ScopedSingletonManager* manager);
+
+            template<ScopeID::Value scope>
+            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->preUpdate(time);
+            }
+            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();
+            typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap;
+            static ManagerMultiMap& getManagersByScope();
+
+        protected:
+            const std::string className_;
+            const ScopeID::Value scope_;
+    };
+
+    template <class T, ScopeID::Value scope, bool allowedToFail>
+    class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
+    {
+    public:
+        ClassScopedSingletonManager(const std::string& className)
+            : ScopedSingletonManager(className, scope)
+            , ScopeListener(scope)
+            , singletonPtr_(NULL)
+        {
+            ScopedSingletonManager::addManager(this);
+        }
+
+        ~ClassScopedSingletonManager()
+        {
+        }
+
+        //! Called if the Scope of the Singleton gets active (creates the instance)
+        void activated()
+        {
+            assert(singletonPtr_ == NULL);
+            singletonPtr_ = new T();
+        }
+
+        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
+        void deactivated()
+        {
+            assert(singletonPtr_ != NULL);
+            this->destroy(singletonPtr_);
+            singletonPtr_ = NULL;
+        }
+
+        void destroy(OrxonoxClass*)
+        {
+            singletonPtr_->destroy();
+        }
+        void destroy(void*)
+        {
+            delete singletonPtr_;
+        }
+
+        //! Called every frame by the ScopedSingletonManager
+        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);
+        }
+
+    private:
+        T* singletonPtr_;
+    };
+
+    template <class T, ScopeID::Value scope>
+    class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
+    {
+    public:
+        ClassScopedSingletonManager(const std::string& className)
+            : ScopedSingletonManager(className, scope)
+            , ScopeListener(scope)
+            , singletonPtr_(NULL)
+        {
+            ScopedSingletonManager::addManager(this);
+        }
+
+        ~ClassScopedSingletonManager()
+        {
+        }
+
+        //! Called if the Scope of the Singleton gets active (creates the instance)
+        void activated()
+        {
+            assert(singletonPtr_ == NULL);
+            try
+                { singletonPtr_ = new T(); }
+            catch (const InitialisationAbortedException& ex)
+                { COUT(3) << ex.getDescription() << std::endl; }
+            catch (...)
+                { COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }
+        }
+
+        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
+        void deactivated()
+        {
+            if (singletonPtr_ != NULL)
+            {
+                this->destroy(singletonPtr_);
+                singletonPtr_ = NULL;
+            }
+        }
+
+        void destroy(OrxonoxClass* ptr)
+        {
+            singletonPtr_->destroy();
+        }
+        void destroy(void* ptr)
+        {
+            delete singletonPtr_;
+        }
+
+        //! Called every frame by the ScopedSingletonManager
+        void preUpdate(const Clock& time)
+        {
+            assert(Scope<scope>::isActive());
+            // assuming T inherits Singleton<T>
+            if (singletonPtr_ != NULL)
+                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);
+        }
+
+    private:
+        T* singletonPtr_;
+    };
+}
+
+#endif /* __ScopedSingletonManager_H__ */
Index: code/trunk/src/libraries/util/SharedPtr.cc
===================================================================
--- code/trunk/src/libraries/util/SharedPtr.cc	(revision 7284)
+++ code/trunk/src/libraries/util/SharedPtr.cc	(revision 7284)
@@ -0,0 +1,38 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "SharedPtr.h"
+
+namespace orxonox
+{
+    SmallObjectAllocator& createSharedCounterPool()
+    {
+        static SmallObjectAllocator instance(sizeof(SharedCounterImpl<void>));
+        return instance;
+    }
+}
Index: code/trunk/src/libraries/util/SharedPtr.h
===================================================================
--- code/trunk/src/libraries/util/SharedPtr.h	(revision 7284)
+++ code/trunk/src/libraries/util/SharedPtr.h	(revision 7284)
@@ -0,0 +1,193 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _SharedPtr_H__
+#define _SharedPtr_H__
+
+#include "UtilPrereqs.h"
+
+#include <algorithm>
+#include <cassert>
+
+#include "SmallObjectAllocator.h"
+
+namespace orxonox
+{
+    class SharedCounter
+    {
+        public:
+            SharedCounter() : count_(1) {}
+            virtual void destroy() = 0;
+
+            int count_;
+    };
+
+    template <class T>
+    class SharedCounterImpl : public SharedCounter
+    {
+        public:
+            SharedCounterImpl(T* pointer) : pointer_(pointer) {}
+
+            void destroy()
+            {
+                delete this->pointer_;
+            }
+
+        private:
+            T* pointer_;
+    };
+
+    _UtilExport SmallObjectAllocator& createSharedCounterPool();
+
+    FORCEINLINE SmallObjectAllocator& getSharedCounterPool()
+    {
+        static SmallObjectAllocator& instance = createSharedCounterPool();
+        return instance;
+    }
+
+    template <class T>
+    class SharedPtr
+    {
+        template <class O>
+        friend class SharedPtr;
+
+        public:
+            inline SharedPtr() : pointer_(0), counter_(0)
+            {
+            }
+
+            inline SharedPtr(T* pointer) : pointer_(pointer), counter_(0)
+            {
+                if (this->pointer_)
+                {
+                    void* chunk = getSharedCounterPool().alloc();
+                    this->counter_ = new (chunk) SharedCounterImpl<T>(this->pointer_);
+                }
+            }
+
+            inline SharedPtr(const SharedPtr& other) : pointer_(other.pointer_), counter_(other.counter_)
+            {
+                if (this->pointer_)
+                    ++this->counter_->count_;
+            }
+
+            template <class O>
+            inline SharedPtr(const SharedPtr<O>& other) : pointer_(other.pointer_), counter_(other.counter_)
+            {
+                if (this->pointer_)
+                    ++this->counter_->count_;
+            }
+
+            inline ~SharedPtr()
+            {
+                if (this->pointer_)
+                {
+                    --this->counter_->count_;
+
+                    if (this->counter_->count_ == 0)
+                    {
+                        this->counter_->destroy();
+                        getSharedCounterPool().free(this->counter_);
+                    }
+                }
+            }
+
+            inline SharedPtr& operator=(const SharedPtr& other)
+            {
+                SharedPtr(other).swap(*this);
+                return *this;
+            }
+
+            template <class O>
+            inline SharedPtr& operator=(const SharedPtr<O>& other)
+            {
+                SharedPtr(other).swap(*this);
+                return *this;
+            }
+
+            template <class O>
+            inline SharedPtr<O> cast() const
+            {
+                O* temp = static_cast<O*>(this->pointer_); // temp value for prettier compiler error in case of an invalid static_cast
+                return SharedPtr<O>(temp, this->counter_);
+            }
+
+            inline T* operator->() const
+            {
+                assert(this->pointer_ != 0);
+                return this->pointer_;
+            }
+
+            inline T& operator*() const
+            {
+                assert(this->pointer_ != 0);
+                return *this->pointer_;
+            }
+
+            inline T* get() const
+            {
+                return this->pointer_;
+            }
+
+            inline operator bool() const
+            {
+                return (this->pointer_ != 0);
+            }
+
+            inline void swap(SharedPtr& other)
+            {
+                std::swap(this->pointer_, other.pointer_);
+                std::swap(this->counter_, other.counter_);
+            }
+
+        private:
+            inline SharedPtr(T* pointer, SharedCounter* counter) : pointer_(pointer), counter_(counter)
+            {
+                if (this->pointer_)
+                    ++this->counter_->count_;
+            }
+
+            T* pointer_;
+            SharedCounter* counter_;
+    };
+
+    template <class T, class Parent>
+    class SharedChildPtr : public Parent
+    {
+        public:
+            inline SharedChildPtr() : Parent() {}
+            inline SharedChildPtr(T* pointer) : Parent(pointer) {}
+            inline SharedChildPtr(const SharedPtr<T>& other) : Parent(other) {}
+
+            inline T* operator->() const { return static_cast<T*>(Parent::operator->()); }
+            inline T& operator*() const { return *static_cast<T*>(Parent::operator->()); }
+    };
+
+}
+
+#endif /* _SharedPtr_H__ */
Index: code/trunk/src/libraries/util/SmallObjectAllocator.cc
===================================================================
--- code/trunk/src/libraries/util/SmallObjectAllocator.cc	(revision 7284)
+++ code/trunk/src/libraries/util/SmallObjectAllocator.cc	(revision 7284)
@@ -0,0 +1,87 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "SmallObjectAllocator.h"
+
+namespace orxonox
+{
+    SmallObjectAllocator::SmallObjectAllocator(size_t objectSize, size_t numObjects)
+    {
+        this->objectSize_ = std::max(objectSize, sizeof(Chunk));
+        this->numObjects_ = numObjects;
+        this->first_ = 0;
+    }
+
+    SmallObjectAllocator::~SmallObjectAllocator()
+    {
+        for (std::vector<char*>::iterator it = this->blocks_.begin(); it != this->blocks_.end(); ++it)
+            delete[] *it;
+    }
+
+    /* static */ void SmallObjectAllocator::setNext(void* chunk, void* next)
+    {
+        static_cast<Chunk*>(chunk)->next_ = static_cast<Chunk*>(next);
+    }
+
+    /* static */ void* SmallObjectAllocator::getNext(void* chunk)
+    {
+        return static_cast<Chunk*>(chunk)->next_;
+    }
+
+    void* SmallObjectAllocator::alloc()
+    {
+        void* chunk = this->first_;
+
+        if (chunk)
+        {
+            this->first_ = getNext(chunk);
+        }
+        else
+        {
+            char* block = new char[this->objectSize_ * this->numObjects_];
+            this->blocks_.push_back(block);
+
+            for (size_t i = 1; i < this->numObjects_ - 1; ++i)
+                setNext(block + i * this->objectSize_, block + (i + 1) * this->objectSize_);
+
+            setNext(block + (this->numObjects_ - 1) * this->objectSize_, 0);
+
+            this->first_ = block + this->objectSize_;
+
+            chunk = block;
+        }
+
+        return chunk;
+    }
+
+    void SmallObjectAllocator::free(void* chunk)
+    {
+        setNext(chunk, this->first_);
+        this->first_ = chunk;
+    }
+}
Index: code/trunk/src/libraries/util/SmallObjectAllocator.h
===================================================================
--- code/trunk/src/libraries/util/SmallObjectAllocator.h	(revision 7284)
+++ code/trunk/src/libraries/util/SmallObjectAllocator.h	(revision 7284)
@@ -0,0 +1,63 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _SmallObjectAllocator_H__
+#define _SmallObjectAllocator_H__
+
+#include "UtilPrereqs.h"
+#include <vector>
+
+namespace orxonox
+{
+    class _UtilExport SmallObjectAllocator
+    {
+        struct Chunk
+        {
+            Chunk* next_;
+        };
+
+        public:
+            SmallObjectAllocator(size_t objectSize, size_t numObjects = 64);
+            ~SmallObjectAllocator();
+
+            void* alloc();
+            void free(void* chunk);
+
+        private:
+            static void setNext(void* chunk, void* next);
+            static void* getNext(void* chunk);
+
+            void* first_;
+            size_t objectSize_;
+            size_t numObjects_;
+
+            std::vector<char*> blocks_;
+    };
+}
+
+#endif /* _SmallObjectAllocator_H__ */
Index: code/trunk/src/libraries/util/StringUtils.cc
===================================================================
--- code/trunk/src/libraries/util/StringUtils.cc	(revision 7278)
+++ code/trunk/src/libraries/util/StringUtils.cc	(revision 7284)
@@ -35,4 +35,5 @@
 
 #include <cctype>
+#include <boost/scoped_array.hpp>
 #include "Convert.h"
 #include "Math.h"
@@ -514,5 +515,5 @@
         @return Number of replacements
     */
-    _UtilExport size_t replaceCharacters(std::string& str, char target, char replacement)
+    size_t replaceCharacters(std::string& str, char target, char replacement)
     {
         size_t j = 0;
@@ -527,3 +528,37 @@
         return j;
     }
+
+    /**
+        @brief Calculates the Levenshtein distance between two strings.
+
+        The Levenshtein distance is defined by the number of transformations needed to convert str1
+        into str2. Possible transformations are substituted, added, or removed characters.
+    */
+    unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2)
+    {
+        size_t cols = str1.size() + 1;
+        size_t rows = str2.size() + 1;
+        boost::scoped_array<int> matrix(new int[rows * cols]);
+
+        for (size_t r = 0; r < rows; ++r)
+            for (size_t c = 0; c < cols; ++c)
+                matrix[r*cols + c] = 0;
+
+        for (size_t i = 1; i < cols; ++i)
+            matrix[0*cols + i] = i;
+        for (size_t i = 1; i < rows; ++i)
+            matrix[i*cols + 0] = i;
+
+        for (size_t r = 1; r < rows; ++r)
+            for (size_t c = 1; c < cols; ++c)
+                matrix[r*cols + c] = (str1[c-1] != str2[r-1]);
+
+        for (size_t r = 1; r < rows; ++r)
+            for (size_t c = 1; c < cols; ++c)
+                matrix[r*cols + c] = std::min(std::min(matrix[(r-1)*cols + c] + 1,
+                                                       matrix[r*cols + c-1] + 1),
+                                              matrix[(r-1)*cols + c-1] + (str1[c-1] != str2[r-1]));
+
+        return matrix[(rows-1)*cols + cols-1];
+    }
 }
Index: code/trunk/src/libraries/util/StringUtils.h
===================================================================
--- code/trunk/src/libraries/util/StringUtils.h	(revision 7278)
+++ code/trunk/src/libraries/util/StringUtils.h	(revision 7284)
@@ -43,40 +43,42 @@
     _UtilExport std::string getUniqueNumberString();
 
-    _UtilExport void        strip(std::string* str);
-    _UtilExport std::string getStripped(const std::string& str);
+    _UtilExport void         strip(std::string* str);
+    _UtilExport std::string  getStripped(const std::string& str);
 
-    _UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+    _UtilExport std::string  removeTrailingWhitespaces(const std::string& str);
 
-    _UtilExport size_t      getNextQuote(const std::string& str, size_t start);
-    _UtilExport bool        isBetweenQuotes(const std::string& str, size_t pos);
+    _UtilExport size_t       getNextQuote(const std::string& str, size_t start);
+    _UtilExport bool         isBetweenQuotes(const std::string& str, size_t pos);
 
-    _UtilExport bool        hasStringBetweenQuotes(const std::string& str);
-    _UtilExport std::string getStringBetweenQuotes(const std::string& str);
+    _UtilExport bool         hasStringBetweenQuotes(const std::string& str);
+    _UtilExport std::string  getStringBetweenQuotes(const std::string& str);
 
-    _UtilExport std::string stripEnclosingQuotes(const std::string& str);
-    _UtilExport std::string stripEnclosingBraces(const std::string& str);
+    _UtilExport std::string  stripEnclosingQuotes(const std::string& str);
+    _UtilExport std::string  stripEnclosingBraces(const std::string& str);
 
-    _UtilExport bool        isEmpty(const std::string& str);
-    _UtilExport bool        isComment(const std::string& str);
-    _UtilExport bool        isNumeric(const std::string& str);
+    _UtilExport bool         isEmpty(const std::string& str);
+    _UtilExport bool         isComment(const std::string& str);
+    _UtilExport bool         isNumeric(const std::string& str);
 
-    _UtilExport std::string addSlashes(const std::string& str);
-    _UtilExport std::string removeSlashes(const std::string& str);
+    _UtilExport std::string  addSlashes(const std::string& str);
+    _UtilExport std::string  removeSlashes(const std::string& str);
 
-    _UtilExport void        lowercase(std::string* str);
-    _UtilExport std::string getLowercase(const std::string& str);
+    _UtilExport void         lowercase(std::string* str);
+    _UtilExport std::string  getLowercase(const std::string& str);
 
-    _UtilExport void        uppercase(std::string* str);
-    _UtilExport std::string getUppercase(const std::string& str);
+    _UtilExport void         uppercase(std::string* str);
+    _UtilExport std::string  getUppercase(const std::string& str);
 
-    _UtilExport int         nocaseCmp(const std::string& s1, const std::string& s2);
-    _UtilExport int         nocaseCmp(const std::string& s1, const std::string& s2, size_t len);
+    _UtilExport int          nocaseCmp(const std::string& s1, const std::string& s2);
+    _UtilExport int          nocaseCmp(const std::string& s1, const std::string& s2, size_t len);
 
-    _UtilExport bool        hasComment(const std::string& str);
-    _UtilExport std::string getComment(const std::string& str);
-    _UtilExport size_t      getCommentPosition(const std::string& str);
-    _UtilExport size_t      getNextCommentPosition(const std::string& str, size_t start = 0);
+    _UtilExport bool         hasComment(const std::string& str);
+    _UtilExport std::string  getComment(const std::string& str);
+    _UtilExport size_t       getCommentPosition(const std::string& str);
+    _UtilExport size_t       getNextCommentPosition(const std::string& str, size_t start = 0);
 
-    _UtilExport size_t      replaceCharacters(std::string& str, char target, char replacement);
+    _UtilExport size_t       replaceCharacters(std::string& str, char target, char replacement);
+
+    _UtilExport unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2);
 }
 
Index: code/trunk/src/libraries/util/SubString.cc
===================================================================
--- code/trunk/src/libraries/util/SubString.cc	(revision 7278)
+++ code/trunk/src/libraries/util/SubString.cc	(revision 7284)
@@ -309,5 +309,5 @@
      * @param line the inputLine to split
      * @param delimiters a String of Delimiters (here the input will be splitted)
-     * @param delimiterNeighbours Naighbours to the Delimitter, that will be removed if they are to the left or the right of a Delimiter.
+     * @param delimiterNeighbours Neighbours to the Delimiter, that will be removed if they are to the left or the right of a Delimiter.
      * @param emptyEntries: if empty Strings are added to the List of Strings.
      * @param escape_char: Escape carater (escapes splitters)
Index: code/trunk/src/libraries/util/SubString.h
===================================================================
--- code/trunk/src/libraries/util/SubString.h	(revision 7278)
+++ code/trunk/src/libraries/util/SubString.h	(revision 7284)
@@ -81,5 +81,5 @@
             SL_SAFEESCAPE,        //!< In safe mode with the internal escape character, that escapes even the savemode character.
             SL_COMMENT,           //!< In Comment mode.
-            SL_PARENTHESES,       //!< Between parentheses (usually '(' and ')')
+            SL_PARENTHESES,       //!< Between parentheses (usually '{' and '}')
             SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character.
         } SPLIT_LINE_STATE;
@@ -92,5 +92,5 @@
                   const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false,
                   char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
-                  char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
+                  char openparenthesis_char = '{', char closeparenthesis_char = '}',  bool removeParenthesisChars = true, char comment_char = '\0');
         SubString(unsigned int argc, const char** argv);
         /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
@@ -116,5 +116,5 @@
                            const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false,
                            char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
-                           char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
+                           char openparenthesis_char = '{', char closeparenthesis_char = '}',  bool removeParenthesisChars = true, char comment_char = '\0');
         std::string join(const std::string& delimiter = " ") const;
         ////////////////////////////////////////
@@ -155,6 +155,6 @@
                                           char safemode_char = '"',
                                           bool removeSafemodeChar = true,
-                                          char openparenthesis_char = '(',
-                                          char closeparenthesis_char = ')',
+                                          char openparenthesis_char = '{',
+                                          char closeparenthesis_char = '}',
                                           bool removeParenthesisChars = true,
                                           char comment_char = '\0',
Index: code/trunk/src/libraries/util/VA_NARGS.h
===================================================================
--- code/trunk/src/libraries/util/VA_NARGS.h	(revision 7284)
+++ code/trunk/src/libraries/util/VA_NARGS.h	(revision 7284)
@@ -0,0 +1,61 @@
+/*
+ *   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 ORXONOX_VA_NARGS macro which returns the number of arguments passed to a variadic macro.
+*/
+
+#include <boost/preprocessor/facilities/expand.hpp>
+
+/**
+    @brief Returns the number of arguments passed to a variadic macro. Important: The number of arguments must be greater than zero (ORXONOX_VA_NARGS() returns 1).
+*/
+#define ORXONOX_VA_NARGS(...) \
+    ORXONOX_VA_NARGS_CONCAT(__VA_ARGS__, ORXONOX_VA_NARGS_NUMBERS)
+
+
+// some helper macros //
+
+#define ORXONOX_VA_NARGS_CONCAT(...) \
+    BOOST_PP_EXPAND(ORXONOX_VA_NARGS_INTERN(__VA_ARGS__))
+
+#define ORXONOX_VA_NARGS_INTERN( \
+    arg1,  arg2,  arg3,  arg4,  arg5,  arg6,  arg7,  arg8,  arg9,  arg10, \
+    arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, \
+    arg21, arg22, arg23, arg24, arg25, arg26, arg27, arg28, arg29, arg30, \
+    arg31, arg32, arg33, arg34, arg35, arg36, arg37, arg38, arg39, arg40, \
+    arg41, arg42, arg43, arg44, arg45, arg46, arg47, arg48, arg49, arg50, \
+    arg51, arg52, arg53, arg54, arg55, arg56, arg57, arg58, arg59, arg60, \
+    arg61, arg62, arg63, argn, ...) argn
+
+#define ORXONOX_VA_NARGS_NUMBERS \
+    63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, \
+    47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, \
+    31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, \
+    15, 14, 13, 12, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0
