Index: code/branches/console/src/core/CommandEvaluation.cc
===================================================================
--- code/branches/console/src/core/CommandEvaluation.cc	(revision 1417)
+++ code/branches/console/src/core/CommandEvaluation.cc	(revision 1424)
@@ -42,5 +42,5 @@
     {
         this->bNewCommand_ = true;
-
+        this->bCommandChanged_ = false;
         this->originalCommand_ = command;
         this->command_ = command;
@@ -79,102 +79,49 @@
         }
 
-        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_));
-    }
-
-    std::string CommandEvaluation::complete() const
-    {
-        switch (this->state_)
-        {
-            case CS_Uninitialized:
-std::cout << "complete: state: CS_Uninitialized" << std::endl;
-            case CS_Empty:
-std::cout << "complete: state: CS_Empty" << std::endl;
-            case CS_ShortcutOrIdentifier:
-std::cout << "complete: state: CS_ShortcutOrIdentifier" << std::endl;
-                {
-                    std::list<std::pair<const std::string*, const std::string*> > temp;
-                    temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end());
-                    temp.insert(temp.end(), this->listOfPossibleIdentifiers_.begin(), this->listOfPossibleIdentifiers_.end());
-                    if (temp.size() > 0)
-                    {
-std::cout << "complete: temp > 0" << std::endl;
-                        return (CommandEvaluation::getCommonBegin(temp));
-                    }
-                }
-                break;
-            case CS_Shortcut_Params:
-std::cout << "complete: state: CS_Shortcut_Params" << std::endl;
-                if (this->function_)
-                {
-std::cout << "complete: function != 0" << std::endl;
-                    if (this->commandTokens_.size() > 1)
-                    {
-                        if ((this->commandTokens_.size() - 1) >= this->function_->getParamCount())
-                            return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size()).join());
-                        else
-                            return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size()).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_));
-                    }
-                    else
-                        return (this->function_->getName() + " ");
-                }
-                break;
-            case CS_Shortcut_Finished:
-std::cout << "complete: state: CS_Shortcut_Finished" << std::endl;
-                if (this->function_)
-                {
-std::cout << "complete: function != 0" << std::endl;
-                    if (this->commandTokens_.size() > 1)
-                        return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size()).join());
-                    else
-                        return (this->function_->getName());
-                }
-                break;
-            case CS_Function:
-std::cout << "complete: state: CS_Function" << std::endl;
-                if (this->functionclass_)
-                {
-std::cout << "complete: functionclass != 0" << std::endl;
-                    return (this->functionclass_->getName() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleFunctions_));
-                }
-                break;
-            case CS_Function_Params:
-std::cout << "complete: state: CS_Function_Params" << std::endl;
-                if (this->functionclass_ && this->function_)
-                {
-std::cout << "complete: function und functionclass != 0" << std::endl;
-                    if (this->commandTokens_.size() > 2)
-                    {
-                        if ((this->commandTokens_.size() - 2) >= this->function_->getParamCount())
-                            return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join());
-                        else
-                            return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_));
-                    }
-                    else
-                        return (this->functionclass_->getName() + " " + this->function_->getName() + " ");
-                }
-                break;
-            case CS_Function_Finished:
-std::cout << "complete: state: CS_Function_Finished" << std::endl;
-                if (this->functionclass_ && this->function_)
-                {
-std::cout << "complete: function und functionclass != 0" << std::endl;
-                    if (this->commandTokens_.size() > 2)
-                        return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join());
-                    else
-                        return (this->functionclass_->getName() + " " + this->function_->getName());
-                }
-               break;
-            case CS_Error:
-std::cout << "complete: state: CS_Error" << std::endl;
-                break;
-        }
-
-        return this->originalCommand_;
+        if (!this->bCommandChanged_)
+        {
+            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;
+    }
+
+    std::string CommandEvaluation::complete()
+    {
+        if (!this->bNewCommand_)
+        {
+std::cout << "ASDF" << std::endl;
+            switch (this->state_)
+            {
+                case CS_Uninitialized:
+                    break;
+                case CS_Empty:
+                    break;
+                case CS_ShortcutOrIdentifier:
+                    if (this->function_)
+                        return CommandExecutor::complete(this->function_->getName() + " ");
+                    else if (this->functionclass_)
+                        return CommandExecutor::complete(this->functionclass_->getName() + " ");
+                    break;
+                case CS_Function:
+                    if (this->function_)
+                        return CommandExecutor::complete(this->functionclass_->getName() + " " + this->function_->getName() + " ");
+                    break;
+                case CS_Params:
+                    break;
+                case CS_Finished:
+                    break;
+                case CS_Error:
+                    break;
+            }
+        }
+        this->bNewCommand_ = false;
+        return this->command_;
     }
 
@@ -197,12 +144,10 @@
                 return CommandEvaluation::dump(this->listOfPossibleFunctions_);
                 break;
-            case CS_Shortcut_Params:
-            case CS_Function_Params:
+            case CS_Params:
                 if (this->listOfPossibleArguments_.size() > 0)
                     return CommandEvaluation::dump(this->listOfPossibleArguments_);
                 else
                     return CommandEvaluation::dump(this->function_);
-            case CS_Shortcut_Finished:
-            case CS_Function_Finished:
+            case CS_Finished:
                 if (this->function_)
                     return CommandEvaluation::dump(this->function_);
@@ -273,53 +218,12 @@
     unsigned int CommandEvaluation::getStartindex() const
     {
-        if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
+        if (this->functionclass_ && this->function_)
+            return 2;
+        else if (this->function_)
             return 1;
-        else if (this->state_ == CS_Function || this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
-            return 2;
         else
             return 0;
     }
 
-    std::string CommandEvaluation::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 CommandEvaluation::dump(const std::list<std::pair<const std::string*, const std::string*> >& list)
     {
@@ -337,5 +241,5 @@
     std::string CommandEvaluation::dump(const ConsoleCommand* command)
     {
-        std::string output = "";
+        std::string output = command->getName() + ": ";
         for (unsigned int i = 0; i < command->getParamCount(); i++)
         {
Index: code/branches/console/src/core/CommandEvaluation.h
===================================================================
--- code/branches/console/src/core/CommandEvaluation.h	(revision 1417)
+++ code/branches/console/src/core/CommandEvaluation.h	(revision 1424)
@@ -45,9 +45,7 @@
         CS_Empty,
         CS_ShortcutOrIdentifier,
-        CS_Shortcut_Params,
-        CS_Shortcut_Finished,
         CS_Function,
-        CS_Function_Params,
-        CS_Function_Finished,
+        CS_Params,
+        CS_Finished,
         CS_Error
     };
@@ -63,5 +61,5 @@
 
             bool execute() const;
-            std::string complete() const;
+            std::string complete();
             std::string hint() const;
             void evaluateParams();
@@ -82,5 +80,4 @@
         private:
             unsigned int getStartindex() const;
-            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
             static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
             static std::string dump(const ConsoleCommand* command);
@@ -88,4 +85,5 @@
 
             bool bNewCommand_;
+            bool bCommandChanged_;
 
             std::string originalCommand_;
Index: code/branches/console/src/core/CommandExecutor.cc
===================================================================
--- code/branches/console/src/core/CommandExecutor.cc	(revision 1417)
+++ code/branches/console/src/core/CommandExecutor.cc	(revision 1424)
@@ -108,10 +108,4 @@
     {
         CommandExecutor::parseIfNeeded(command);
-
-        if (!CommandExecutor::getEvaluation().bNewCommand_)
-            CommandExecutor::parse(CommandExecutor::getEvaluation().command_, false);
-        else
-            CommandExecutor::getEvaluation().bNewCommand_ = false;
-
         return CommandExecutor::getEvaluation().complete();
     }
@@ -132,6 +126,20 @@
     void CommandExecutor::parseIfNeeded(const std::string& command)
     {
-        if ((CommandExecutor::getEvaluation().originalCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
+        if (CommandExecutor::getEvaluation().state_ == CS_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);
+            }
+        }
     }
 
@@ -149,5 +157,4 @@
             case CS_Uninitialized:
             {
-std::cout << "parse: state: CS_Uninitialized" << std::endl;
                 // Impossible
                 break;
@@ -155,216 +162,192 @@
             case CS_Empty:
             {
-std::cout << "parse: state: CS_Empty" << std::endl;
-                CommandExecutor::createListOfPossibleIdentifiers(CommandExecutor::getArgument(0));
-                CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0));
-
-                if (CommandExecutor::argumentsGiven() > 0)
+                if (CommandExecutor::argumentsGiven() == 0)
+                {
+                    CommandExecutor::createListOfPossibleFunctions("");
+                    CommandExecutor::createListOfPossibleIdentifiers("");
+                    break;
+                }
+                else
                 {
                     CommandExecutor::getEvaluation().state_ = CS_ShortcutOrIdentifier;
-                    CommandExecutor::parse(command, false);
-                    return;
-                }
+                    // Move on to next case
+                }
+            }
+            case CS_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_ = CS_Params;
+                        CommandExecutor::getEvaluation().functionclass_ = 0;
+                        // Move on to next case
+                    }
+                    else if (CommandExecutor::getEvaluation().functionclass_)
+                    {
+                        // It's a functionname
+                        CommandExecutor::getEvaluation().state_ = CS_Function;
+                        CommandExecutor::getEvaluation().function_ = 0;
+                        // Move on to next case
+                    }
+                    else
+                    {
+                        // The first argument is bad
+                        CommandExecutor::getEvaluation().state_ = CS_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
+                        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_ = CS_Params;
+                        CommandExecutor::getEvaluation().functionclass_ = 0;
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
+                        if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
+                            CommandExecutor::getEvaluation().command_ += " ";
+                        // Move on to next case
+                    }
+                    else if (num_identifiers == 1 && num_functions == 0)
+                    {
+                        // It's a classname
+                        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_ = CS_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_ = CS_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));
+                        return;
+                    }
+                }
+            }
+            case CS_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_ = CS_Params;
+                            // Move on to next case
+                        }
+                        else
+                        {
+                            // The second argument is bad
+                            CommandExecutor::getEvaluation().state_ = CS_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
+                            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_ = CS_Params;
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
+                            if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
+                                CommandExecutor::getEvaluation().command_ += " ";
+                            // Move on to next case
+                        }
+                        else if (num_functions == 0)
+                        {
+                            // No possibilities
+                            CommandExecutor::getEvaluation().state_ = CS_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_);
+                            return;
+                        }
+                    }
+                }
+                else
+                {
+                    // There is no classname - move on to CS_Shortcut_Params
+                }
+            }
+std::cout << "Waiting for arguments" << std::endl;
+            case CS_Params:
+            {
+            }
+            case CS_Finished:
+            {
+                // Nothing more to do
                 break;
             }
-            case CS_ShortcutOrIdentifier:
-            {
-std::cout << "parse: state: CS_ShortcutOrIdentifier" << std::endl;
-                if (CommandExecutor::argumentsFinished() > 0 || !CommandExecutor::getEvaluation().bNewCommand_)
-                {
-                    // There's already a finished first argument - check if it's function or a classname
-                    CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
-                    CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
-
-                    if (CommandExecutor::getEvaluation().function_)
-                    {
-                        // It's a shortcut - continue parsing
-                        CommandExecutor::getEvaluation().state_ = CS_Shortcut_Params;
-                        if (CommandExecutor::argumentsFinished() > 0 )
-                            CommandExecutor::parse(command, false);
-                        else
-                            CommandExecutor::parse(command + " ", false);
-                        return;
-                    }
-                    else if (CommandExecutor::getEvaluation().functionclass_)
-                    {
-                        // It's a classname - continue parsing
-                        CommandExecutor::getEvaluation().state_ = CS_Function;
-                        if (CommandExecutor::argumentsFinished() > 0 )
-                            CommandExecutor::parse(command, false);
-                        else
-                            CommandExecutor::parse(command + " ", false);
-                        return;
-                    }
-                }
-
-                unsigned int numIdentifiers = CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.size();
-                unsigned int numCommands = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
-
-                if (CommandExecutor::argumentsFinished() == 0)
-                {
-                    // There is no finished first argument
-                    if (numCommands == 1 && numIdentifiers == 0)
-                    {
-                        // It must be this command
-                        const std::string* possibleCommand = (*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).second;
-                        CommandExecutor::getEvaluation().state_ = CS_Shortcut_Params;
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(*possibleCommand);
-                        CommandExecutor::parse(*possibleCommand + " ", false);
-                        return;
-                    }
-                    else if (numIdentifiers == 1 && numCommands == 0)
-                    {
-                        // It must be this classname
-                        const std::string* possibleIdentifier = (*CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()).second;
-                        CommandExecutor::getEvaluation().state_ = CS_Function;
-                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(*possibleIdentifier);
-                        CommandExecutor::parse(*possibleIdentifier + " ", false);
-                        return;
-                    }
-                }
-
-                if (numCommands == 0 && numIdentifiers == 0)
-                {
-                    // It's not a shortcut nor a classname
-                    CommandExecutor::getEvaluation().state_ = CS_Error;
-                    AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
-                    CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
-                }
+            case CS_Error:
+            {
+                // Bad, very bad
                 break;
             }
-            case CS_Function:
-std::cout << "parse: state: CS_Function" << std::endl;
-            {
-                if (CommandExecutor::getEvaluation().functionclass_ && CommandExecutor::argumentsGiven() > 0)
-                {
-                    if (CommandExecutor::argumentsFinished() > 1 || !CommandExecutor::getEvaluation().bNewCommand_)
-                    {
-                        // There is already a second argument - check if it's a valid function
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
-
-                        if (CommandExecutor::getEvaluation().function_)
-                        {
-                            // It's a shortcut - continue parsing
-                            CommandExecutor::getEvaluation().state_ = CS_Function_Params;
-                            if (CommandExecutor::argumentsFinished() > 1 )
-                                CommandExecutor::parse(command, false);
-                            else
-                                CommandExecutor::parse(command + " ", false);
-                            return;
-                        }
-                        else if (CommandExecutor::argumentsFinished() > 1)
-                        {
-                            // It's not a function
-                            AddLanguageEntry("commandexecutorunknowncommand", "is not a valid commandname");
-                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknowncommand") + ".";
-                            CommandExecutor::getEvaluation().state_ = CS_Error;
-                        }
-                    }
-
-                    CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
-
-                    if (CommandExecutor::argumentsFinished() <= 1)
-                    {
-                        // There is no finished second argument
-                        unsigned int numFunctions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
-
-                        if (numFunctions == 1)
-                        {
-                            // It must be this command
-                            const std::string* possibleCommand = (*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).second;
-                            CommandExecutor::getEvaluation().state_ = CS_Function_Params;
-                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(*possibleCommand, CommandExecutor::getEvaluation().functionclass_);
-                            CommandExecutor::parse(CommandExecutor::getArgument(0) + " " + *possibleCommand + " ", false);
-                            return;
-                        }
-                        else if (numFunctions == 0)
-                        {
-                            // It's not a function
-                            AddLanguageEntry("commandexecutorunknowncommand", "is not a valid commandname");
-                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknowncommand") + ".";
-                            CommandExecutor::getEvaluation().state_ = CS_Error;
-                        }
-                    }
-
-                    // It's ambiguous
-                    return;
-                }
-
-                // Bad state
-                CommandExecutor::getEvaluation().state_ = CS_Error;
-                break;
-            }
-            case CS_Shortcut_Params:
-std::cout << "parse: state: CS_Shortcut_Params" << std::endl;
-            case CS_Function_Params:
-            {
-std::cout << "parse: state: CS_Function_Params" << std::endl;
-                if (CommandExecutor::getEvaluation().function_)
-                {
-                    unsigned int startindex = 0;
-                    if (CommandExecutor::getEvaluation().state_ == CS_Shortcut_Params)
-                        startindex = 1;
-                    else if (CommandExecutor::getEvaluation().state_ == CS_Function_Params)
-                        startindex = 2;
-
-                    if (CommandExecutor::argumentsGiven() >= startindex)
-                    {
-                        if ((CommandExecutor::argumentsGiven() == CommandExecutor::argumentsFinished() || !CommandExecutor::getEvaluation().bNewCommand_) && CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))
-                        {
-                            if (CommandExecutor::getEvaluation().state_ == CS_Shortcut_Params)
-                                CommandExecutor::getEvaluation().state_ = CS_Shortcut_Finished;
-                            else if (CommandExecutor::getEvaluation().state_ == CS_Function_Params)
-                                CommandExecutor::getEvaluation().state_ = CS_Function_Finished;
-
-                            return;
-                        }
-                        else
-                        {
-                            CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, CommandExecutor::getEvaluation().commandTokens_.size() - startindex);
-                            unsigned int numArguments = CommandExecutor::getEvaluation().listOfPossibleArguments_.size();
-
-                            if (numArguments == 1)
-                            {
-                                // There is exactly one possible argument
-                                const std::string* possibleArgument = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).second;
-                                if (CommandExecutor::argumentsGiven() > CommandExecutor::argumentsFinished())
-                                    CommandExecutor::parse(CommandExecutor::getEvaluation().commandTokens_.subSet(0, CommandExecutor::getEvaluation().commandTokens_.size() - 1).join() + " " + (*possibleArgument) + " ", false);
-                                else
-                                    CommandExecutor::parse(CommandExecutor::getEvaluation().commandTokens_.subSet(0, CommandExecutor::getEvaluation().commandTokens_.size()).join() + " " + (*possibleArgument) + " ", false);
-
-                                return;
-                            }
-
-                            if ((CommandExecutor::argumentsGiven() > CommandExecutor::argumentsFinished()) && (!CommandExecutor::getEvaluation().bNewCommand_))
-                            {
-                                // There is more than one argument, but the user wants to use this - check if there is a perfect match
-                                const std::string* possibleArgument = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, CommandExecutor::getEvaluation().commandTokens_.size() - startindex);
-                                if (possibleArgument)
-                                {
-                                    // There is such an argument - use it
-                                    CommandExecutor::parse(command + " ", false);
-                                    return;
-                                }
-                            }
-                        }
-
-                        // Nothing to do
-                        return;
-                    }
-                }
-
-                // Bad state
-                CommandExecutor::getEvaluation().state_ = CS_Error;
-                break;
-            }
-            case CS_Shortcut_Finished:
-std::cout << "parse: state: CS_Shortcut_Finished" << std::endl;
-                break;
-            case CS_Function_Finished:
-std::cout << "parse: state: CS_Function_Finished" << std::endl;
-                break;
-            case CS_Error:
-std::cout << "parse: state: CS_Error" << std::endl;
-                break;
         }
     }
@@ -372,17 +355,17 @@
     unsigned int CommandExecutor::argumentsFinished()
     {
-        if (CommandExecutor::getEvaluation().command_.size() > 0)
-        {
-            if (CommandExecutor::getEvaluation().command_[CommandExecutor::getEvaluation().command_.size() - 1] == ' ')
-                return CommandExecutor::getEvaluation().commandTokens_.size();
-            else if (CommandExecutor::getEvaluation().commandTokens_.size() > 0)
-                return CommandExecutor::getEvaluation().commandTokens_.size() - 1;
-        }
-        return 0;
+        unsigned int argumentsGiven = CommandExecutor::argumentsGiven();
+        if (argumentsGiven > 0)
+            return argumentsGiven - 1;
+        else
+            return 0;
     }
 
     unsigned int CommandExecutor::argumentsGiven()
     {
-        return CommandExecutor::getEvaluation().commandTokens_.size();
+        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();
     }
 
@@ -390,12 +373,12 @@
     {
         if (CommandExecutor::getEvaluation().functionclass_)
-            return (CommandExecutor::argumentsGiven() >= (2 + command->getParamCount()));
-        else
-            return (CommandExecutor::argumentsGiven() >= (1 + command->getParamCount()));
+            return (CommandExecutor::getEvaluation().commandTokens_.size() >= (2 + command->getParamCount()));
+        else
+            return (CommandExecutor::getEvaluation().commandTokens_.size() >= (1 + command->getParamCount()));
     }
 
     std::string CommandExecutor::getArgument(unsigned int index)
     {
-        if ((index >= 0) && index < (CommandExecutor::getEvaluation().commandTokens_.size()))
+        if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
             return CommandExecutor::getEvaluation().commandTokens_[index];
         else
@@ -405,9 +388,5 @@
     std::string CommandExecutor::getLastArgument()
     {
-        if (CommandExecutor::getEvaluation().commandTokens_.size() > 0)
-            if (CommandExecutor::getEvaluation().commandTokens_.size() > 0 && CommandExecutor::getEvaluation().command_[CommandExecutor::getEvaluation().command_.size() - 1] != ' ')
-                return CommandExecutor::getEvaluation().commandTokens_[CommandExecutor::getEvaluation().commandTokens_.size() - 1];
-
-        return "";
+        return CommandExecutor::getArgument(CommandExecutor::argumentsGiven());
     }
 
@@ -493,4 +472,45 @@
     }
 
+    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;
+        }
+    }
+
     bool CommandExecutor::compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second)
     {
Index: code/branches/console/src/core/CommandExecutor.h
===================================================================
--- code/branches/console/src/core/CommandExecutor.h	(revision 1417)
+++ code/branches/console/src/core/CommandExecutor.h	(revision 1424)
@@ -93,4 +93,5 @@
             static const std::string* getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
 
+            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
             static bool compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second);
 
Index: code/branches/console/src/core/OutputBuffer.h
===================================================================
--- code/branches/console/src/core/OutputBuffer.h	(revision 1417)
+++ code/branches/console/src/core/OutputBuffer.h	(revision 1424)
@@ -42,5 +42,9 @@
         friend class OutputBuffer;
 
-        virtual void outputChanged() = 0;
+        public:
+            virtual ~OutputBufferListener() {}
+
+        private:
+            virtual void outputChanged() = 0;
     };
 
Index: code/branches/console/src/core/Shell.cc
===================================================================
--- code/branches/console/src/core/Shell.cc	(revision 1417)
+++ code/branches/console/src/core/Shell.cc	(revision 1424)
@@ -32,4 +32,5 @@
 #include "ConfigValueIncludes.h"
 #include "CoreSettings.h"
+#include "ConsoleCommand.h"
 
 #define SHELL_UPDATE_LISTENERS(function) \
@@ -39,4 +40,7 @@
 namespace orxonox
 {
+    SetConsoleCommand(Shell, clearShell, true);
+    SetConsoleCommand(Shell, history, true);
+
     Shell::Shell()
     {
@@ -104,4 +108,19 @@
     }
 
+    void Shell::clearShell()
+    {
+        Shell::getInstance().clearLines();
+    }
+
+    void Shell::history()
+    {
+        Shell& instance = Shell::getInstance();
+
+        for (int i = instance.historyOffset_; i < (int)instance.commandHistory_.size(); ++i)
+            instance.addLine(instance.commandHistory_[i], -1);
+        for (int i =  0; i < (int)instance.historyOffset_; ++i)
+            instance.addLine(instance.commandHistory_[i], -1);
+    }
+
     void Shell::registerListener(ShellListener* listener)
     {
@@ -243,6 +262,6 @@
     void Shell::hintandcomplete()
     {
+        this->inputBuffer_.set(CommandExecutor::complete(this->inputBuffer_.get()));
         this->addLine(CommandExecutor::hint(this->inputBuffer_.get()), -1);
-        this->inputBuffer_.set(CommandExecutor::complete(this->inputBuffer_.get()));
 
         this->inputChanged();
Index: code/branches/console/src/core/Shell.h
===================================================================
--- code/branches/console/src/core/Shell.h	(revision 1417)
+++ code/branches/console/src/core/Shell.h	(revision 1424)
@@ -45,10 +45,14 @@
         friend class Shell;
 
-        virtual void linesChanged() {}
-        virtual void onlyLastLineChanged() {}
-        virtual void lineAdded() {}
-        virtual void inputChanged() {}
-        virtual void cursorChanged() {}
-        virtual void exit() {}
+        public:
+            virtual ~ShellListener() {}
+
+        private:
+            virtual void linesChanged() {}
+            virtual void onlyLastLineChanged() {}
+            virtual void lineAdded() {}
+            virtual void inputChanged() {}
+            virtual void cursorChanged() {}
+            virtual void exit() {}
     };
 
@@ -58,4 +62,7 @@
             static Shell& getInstance();
             static Shell& createShell();
+
+            static void clearShell();
+            static void history();
 
             virtual void setConfigValues();
@@ -83,5 +90,5 @@
             std::list<std::string>::const_iterator getEndIterator() const;
 
-            void addLine(const std::string& line, int level);
+            void addLine(const std::string& line, int level = 0);
             void clearLines();
 
Index: code/branches/console/src/core/TclThreadManager.cc
===================================================================
--- code/branches/console/src/core/TclThreadManager.cc	(revision 1417)
+++ code/branches/console/src/core/TclThreadManager.cc	(revision 1424)
@@ -223,5 +223,5 @@
         else
         {
-            if (bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID))
+            if ((bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID)))
             {
                 COUT(0) << "Queue dump of Tcl-thread " << threadID << ":" << std::endl;
