Index: /code/branches/console/src/core/ArgumentCompletionFunctions.cc
===================================================================
--- /code/branches/console/src/core/ArgumentCompletionFunctions.cc	(revision 1401)
+++ /code/branches/console/src/core/ArgumentCompletionFunctions.cc	(revision 1402)
@@ -27,4 +27,6 @@
  */
 
+#include <iostream>
+
 #include "ArgumentCompletionFunctions.h"
 
@@ -35,5 +37,7 @@
         const std::list<std::pair<std::string, std::string> >& fallback()
         {
+std::cout << "5_1\n";
             static std::list<std::pair<std::string, std::string> > list;
+std::cout << "5_2\n";
             return list;
         }
Index: /code/branches/console/src/core/CommandEvaluation.cc
===================================================================
--- /code/branches/console/src/core/CommandEvaluation.cc	(revision 1401)
+++ /code/branches/console/src/core/CommandEvaluation.cc	(revision 1402)
@@ -45,5 +45,4 @@
         this->originalCommand_ = command;
         this->command_ = command;
-        this->originalCommandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
         this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
 
@@ -79,9 +78,9 @@
         }
 
-        COUT(4) << "CE_execute: " << this->originalCommand_ << "\n";
+        COUT(4) << "CE_execute: " << this->command_ << "\n";
 
         unsigned int startindex = this->getStartindex();
-        if (this->originalCommandTokens_.size() > startindex)
-            return this->function_->parse(removeSlashes(this->originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));
+        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_));
@@ -93,72 +92,94 @@
         {
             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)
+                        return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).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() - 1).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)
+                        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_;
+    }
+
+    std::string CommandEvaluation::hint() const
+    {
+        switch (this->state_)
+        {
+            case CS_Uninitialized:
+                break;
             case CS_Empty:
             case CS_ShortcutOrIdentifier:
-                {
-                    std::list<std::pair<const std::string*, const std::string*> > temp;
-                    if (this->state_ == CS_Empty)
-                    {
-                        temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end());
-                        temp.insert(temp.end(), this->listOfPossibleIdentifiers_.begin(), this->listOfPossibleIdentifiers_.end());
-                    }
-                    return (CommandEvaluation::getCommonBegin(temp));
-                }
-                break;
-            case CS_Shortcut_Params:
-                if (this->function_)
-                {
-                    if (this->commandTokens_.size() > 1)
-                        return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_));
-                    else
-                        return (this->function_->getName() + " ");
-                }
-                break;
-            case CS_Shortcut_Finished:
-                if (this->function_)
-                {
-                    if (this->commandTokens_.size() > 1)
-                        return (this->function_->getName() + " " + this->originalCommandTokens_.subSet(1, this->originalCommandTokens_.size() - 1).join());
-                    else
-                        return (this->function_->getName());
-                }
-                break;
-            case CS_Function:
-                if (this->functionclass_)
-                    return (this->functionclass_->getName() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleFunctions_));
-                break;
-            case CS_Function_Params:
-                if (this->functionclass_ && this->function_)
-                {
-                    if (this->commandTokens_.size() > 2)
-                        return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_));
-                    else
-                        return (this->functionclass_->getName() + " " + this->function_->getName() + " ");
-                }
-                break;
-            case CS_Function_Finished:
-                if (this->functionclass_ && this->function_)
-                {
-                    if (this->commandTokens_.size() > 2)
-                        return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->originalCommandTokens_.subSet(2, this->originalCommandTokens_.size() - 1).join());
-                    else
-                        return (this->functionclass_->getName() + " " + this->function_->getName());
-                }
-               break;
-            case CS_Error:
-                break;
-        }
-
-        return this->originalCommand_;
-    }
-
-    std::string CommandEvaluation::hint() const
-    {
-        switch (this->state_)
-        {
-            case CS_Uninitialized:
-                break;
-            case CS_Empty:
-            case CS_ShortcutOrIdentifier:
-                return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
+                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 CS_Function:
@@ -167,5 +188,8 @@
             case CS_Shortcut_Params:
             case CS_Function_Params:
-                return CommandEvaluation::dump(this->listOfPossibleArguments_);
+                if (this->listOfPossibleArguments_.size() > 0)
+                    return CommandEvaluation::dump(this->listOfPossibleArguments_);
+                else
+                    return CommandEvaluation::dump(this->function_);
             case CS_Shortcut_Finished:
             case CS_Function_Finished:
@@ -193,12 +217,12 @@
         unsigned int startindex = this->getStartindex();
 
-        if (this->originalCommandTokens_.size() <= startindex)
+        if (this->commandTokens_.size() <= startindex)
         {
             if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " "))
                 this->bEvaluatedParams_ = true;
         }
-        else if (this->originalCommandTokens_.size() > startindex)
-        {
-            if (this->function_->evaluate(this->originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))
+        else if (this->commandTokens_.size() > startindex)
+        {
+            if (this->function_->evaluate(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))
                 this->bEvaluatedParams_ = true;
         }
Index: /code/branches/console/src/core/CommandEvaluation.h
===================================================================
--- /code/branches/console/src/core/CommandEvaluation.h	(revision 1401)
+++ /code/branches/console/src/core/CommandEvaluation.h	(revision 1402)
@@ -86,6 +86,4 @@
             inline void setState(CommandState state)
                 { this->state_ = state; }
-            inline SubString& getOriginalTokens()
-                { return this->originalCommandTokens_; }
             inline SubString& getTokens()
                 { return this->commandTokens_; }
@@ -130,5 +128,4 @@
             std::string originalCommand_;
             std::string command_;
-            SubString originalCommandTokens_;
             SubString commandTokens_;
             std::string additionalParameter_;
Index: /code/branches/console/src/core/CommandExecutor.cc
===================================================================
--- /code/branches/console/src/core/CommandExecutor.cc	(revision 1401)
+++ /code/branches/console/src/core/CommandExecutor.cc	(revision 1402)
@@ -101,7 +101,5 @@
             return TclBind::eval(command);
 
-        if ((CommandExecutor::getEvaluation().getCommand() != command) || (CommandExecutor::getEvaluation().getState() == CS_Uninitialized))
-            CommandExecutor::parse(command);
-
+        CommandExecutor::parseIfNeeded(command);
         return CommandExecutor::getEvaluation().execute();
     }
@@ -109,7 +107,5 @@
     std::string CommandExecutor::complete(const std::string& command)
     {
-        if ((CommandExecutor::getEvaluation().getCommand() != command) || (CommandExecutor::getEvaluation().getState() == CS_Uninitialized))
-            CommandExecutor::parse(command);
-
+        CommandExecutor::parseIfNeeded(command);
         return CommandExecutor::getEvaluation().complete();
     }
@@ -117,7 +113,5 @@
     std::string CommandExecutor::hint(const std::string& command)
     {
-        if ((CommandExecutor::getEvaluation().getCommand() != command) || (CommandExecutor::getEvaluation().getState() == CS_Uninitialized))
-            CommandExecutor::parse(command);
-
+        CommandExecutor::parseIfNeeded(command);
         return CommandExecutor::getEvaluation().hint();
     }
@@ -130,12 +124,22 @@
     }
 
+    void CommandExecutor::parseIfNeeded(const std::string& command)
+    {
+        if ((CommandExecutor::getEvaluation().getCommand() != command) || (CommandExecutor::getEvaluation().getState() == CS_Uninitialized))
+            CommandExecutor::parse(command);
+        else if (!CommandExecutor::getEvaluation().isValid())
+        {
+            CommandExecutor::getEvaluation().setNewCommand(false);
+            CommandExecutor::parse(command, false);
+        }
+    }
+
     void CommandExecutor::parse(const std::string& command, bool bInitialize)
     {
+std::cout << "parse: command: >" << command << "<" << std::endl;
         if (bInitialize)
             CommandExecutor::getEvaluation().initialize(command);
-        else
-            CommandExecutor::getEvaluation().setNewCommand(false);
-
-        CommandExecutor::getEvaluation().setTokens(command + COMMAND_EXECUTOR_CURSOR);
+
+        CommandExecutor::getEvaluation().setTokens(command);
         CommandExecutor::getEvaluation().setCommand(command);
 
@@ -143,7 +147,12 @@
         {
             case CS_Uninitialized:
+            {
+std::cout << "parse: state: CS_Uninitialized" << std::endl;
                 // Impossible
                 break;
+            }
             case CS_Empty:
+            {
+std::cout << "parse: state: CS_Empty" << std::endl;
                 CommandExecutor::createListOfPossibleIdentifiers(CommandExecutor::getArgument(0));
                 CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0));
@@ -156,5 +165,8 @@
                 }
                 break;
+            }
             case CS_ShortcutOrIdentifier:
+            {
+std::cout << "parse: state: CS_ShortcutOrIdentifier" << std::endl;
                 if (CommandExecutor::argumentsFinished() > 0 || !CommandExecutor::getEvaluation().isNewCommand())
                 {
@@ -185,10 +197,10 @@
                 }
 
+                unsigned int numIdentifiers = CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().size();
+                unsigned int numCommands = CommandExecutor::getEvaluation().getListOfPossibleFunctions().size();
+
                 if (CommandExecutor::argumentsFinished() == 0)
                 {
                     // There is no finished first argument
-                    unsigned int numIdentifiers = CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().size();
-                    unsigned int numCommands = CommandExecutor::getEvaluation().getListOfPossibleFunctions().size();
-
                     if (numCommands == 1 && numIdentifiers == 0)
                     {
@@ -211,11 +223,17 @@
                 }
 
-                // It's not a shortcut nor a classname
-                CommandExecutor::getEvaluation().setState(CS_Error);
-                AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
-                CommandExecutor::getEvaluation().setError("Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".");
-                break;
+                if (numCommands == 0 && numIdentifiers == 0)
+                {
+                    // It's not a shortcut nor a classname
+                    CommandExecutor::getEvaluation().setState(CS_Error);
+                    AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
+                    CommandExecutor::getEvaluation().setError("Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".");
+                }
+                break;
+            }
             case CS_Function:
-                if (CommandExecutor::getEvaluation().getIdentifier() && CommandExecutor::argumentsGiven() > 1)
+std::cout << "parse: state: CS_Function" << std::endl;
+            {
+                if (CommandExecutor::getEvaluation().getIdentifier() && CommandExecutor::argumentsGiven() > 0)
                 {
                     if (CommandExecutor::argumentsFinished() > 1 || !CommandExecutor::getEvaluation().isNewCommand())
@@ -234,10 +252,18 @@
                             return;
                         }
-                    }
+                        else if (CommandExecutor::argumentsFinished() > 1)
+                        {
+                            // It's not a function
+                            AddLanguageEntry("commandexecutorunknowncommand", "is not a valid commandname");
+                            CommandExecutor::getEvaluation().setError("Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknowncommand") + ".");
+                            CommandExecutor::getEvaluation().setState(CS_Error);
+                        }
+                    }
+
+                    CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().getIdentifier());
 
                     if (CommandExecutor::argumentsFinished() <= 1)
                     {
                         // There is no finished second argument
-                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0), CommandExecutor::getEvaluation().getIdentifier());
                         unsigned int numFunctions = CommandExecutor::getEvaluation().getListOfPossibleFunctions().size();
 
@@ -247,13 +273,19 @@
                             const std::string* possibleCommand = (*CommandExecutor::getEvaluation().getListOfPossibleFunctions().begin()).second;
                             CommandExecutor::getEvaluation().setState(CS_Function_Params);
-                            CommandExecutor::getEvaluation().setFunction(CommandExecutor::getPossibleCommand(*possibleCommand));
-                            CommandExecutor::parse(*possibleCommand + " ", false);
+                            CommandExecutor::getEvaluation().setFunction(CommandExecutor::getPossibleCommand(*possibleCommand, CommandExecutor::getEvaluation().getIdentifier()));
+                            CommandExecutor::parse(CommandExecutor::getArgument(0) + " " + *possibleCommand + " ", false);
                             return;
                         }
-                    }
-
-                    // It's not a function
-                    AddLanguageEntry("commandexecutorunknowncommand", "is not a valid commandname");
-                    CommandExecutor::getEvaluation().setError("Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknowncommand") + ".");
+                        else if (numFunctions == 0)
+                        {
+                            // It's not a function
+                            AddLanguageEntry("commandexecutorunknowncommand", "is not a valid commandname");
+                            CommandExecutor::getEvaluation().setError("Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknowncommand") + ".");
+                            CommandExecutor::getEvaluation().setState(CS_Error);
+                        }
+                    }
+
+                    // It's ambiguous
+                    return;
                 }
 
@@ -261,8 +293,13 @@
                 CommandExecutor::getEvaluation().setState(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().getFunction())
                 {
+std::cout << "1\n";
                     unsigned int startindex = 0;
                     if (CommandExecutor::getEvaluation().getState() == CS_Shortcut_Params)
@@ -270,22 +307,33 @@
                     else if (CommandExecutor::getEvaluation().getState() == CS_Function_Params)
                         startindex = 2;
+std::cout << "2\n";
 
                     if (CommandExecutor::argumentsGiven() >= startindex)
                     {
+std::cout << "3\n";
                         if (CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().getFunction()))
                         {
+std::cout << "4\n";
                             if (CommandExecutor::getEvaluation().getState() == CS_Shortcut_Params)
                                 CommandExecutor::getEvaluation().setState(CS_Shortcut_Finished);
                             else if (CommandExecutor::getEvaluation().getState() == CS_Function_Params)
                                 CommandExecutor::getEvaluation().setState(CS_Function_Finished);
+
                             return;
                         }
                         else
                         {
-                            CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().getFunction(), CommandExecutor::getEvaluation().getOriginalTokens().size() - startindex);
+std::cout << "5\n";
+std::cout << "last argument: " << CommandExecutor::getLastArgument() << std::endl;
+std::cout << "function: " << CommandExecutor::getEvaluation().getFunction() << std::endl;
+std::cout << "functionname: " << CommandExecutor::getEvaluation().getFunction()->getName() << std::endl;
+std::cout << "param nr: " << CommandExecutor::getEvaluation().getTokens().size() - startindex << std::endl;
+                            CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().getFunction(), CommandExecutor::getEvaluation().getTokens().size() - startindex);
+std::cout << "6\n";
                             unsigned int numArguments = CommandExecutor::getEvaluation().getListOfPossibleArguments().size();
 
                             if (numArguments == 1)
                             {
+std::cout << "7\n";
                                 // There is exactly one possible argument
                                 const std::string* possibleArgument = (*CommandExecutor::getEvaluation().getListOfPossibleArguments().begin()).second;
@@ -294,16 +342,25 @@
                             }
 
-                            if (!CommandExecutor::getEvaluation().isNewCommand())
+std::cout << "8\n";
+                            if ((CommandExecutor::argumentsGiven() > CommandExecutor::argumentsFinished()) && (!CommandExecutor::getEvaluation().isNewCommand()))
                             {
+std::cout << "9\n";
                                 // 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().getFunction(), CommandExecutor::getEvaluation().getOriginalTokens().size() - startindex);
+                                const std::string* possibleArgument = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().getFunction(), CommandExecutor::getEvaluation().getTokens().size() - startindex);
                                 if (possibleArgument)
                                 {
+std::cout << "10\n";
                                     // There is such an argument - use it
                                     CommandExecutor::parse(command + " ", false);
                                     return;
                                 }
+std::cout << "11\n";
                             }
+std::cout << "12\n";
                         }
+std::cout << "13\n";
+
+                        // Nothing to do
+                        return;
                     }
                 }
@@ -312,7 +369,13 @@
                 CommandExecutor::getEvaluation().setState(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;
         }
@@ -321,14 +384,17 @@
     unsigned int CommandExecutor::argumentsFinished()
     {
-        // Because we added a cursor we have +1 arguments
-        if (CommandExecutor::getEvaluation().getTokens().size() >= 1)
-            return (CommandExecutor::getEvaluation().getTokens().size() - 1);
-        else
-            return 0;
+        if (CommandExecutor::getEvaluation().getCommand().size() > 0)
+        {
+            if (CommandExecutor::getEvaluation().getCommand()[CommandExecutor::getEvaluation().getCommand().size() - 1] == ' ')
+                return CommandExecutor::getEvaluation().getTokens().size();
+            else if (CommandExecutor::getEvaluation().getTokens().size() > 0)
+                return CommandExecutor::getEvaluation().getTokens().size() - 1;
+        }
+        return 0;
     }
 
     unsigned int CommandExecutor::argumentsGiven()
     {
-        return CommandExecutor::getEvaluation().getOriginalTokens().size();
+        return CommandExecutor::getEvaluation().getTokens().size();
     }
 
@@ -343,6 +409,6 @@
     std::string CommandExecutor::getArgument(unsigned int index)
     {
-        if ((index >= 0) && index < (CommandExecutor::getEvaluation().getOriginalTokens().size()))
-            return CommandExecutor::getEvaluation().getOriginalTokens()[index];
+        if ((index >= 0) && index < (CommandExecutor::getEvaluation().getTokens().size()))
+            return CommandExecutor::getEvaluation().getTokens()[index];
         else
             return "";
@@ -351,15 +417,17 @@
     std::string CommandExecutor::getLastArgument()
     {
-        if (CommandExecutor::getEvaluation().getOriginalTokens().size() > 0)
-            return CommandExecutor::getEvaluation().getOriginalTokens()[0];
-        else
-            return "";
+        if (CommandExecutor::getEvaluation().getTokens().size() > 0)
+            if (CommandExecutor::getEvaluation().getCommand().size() > 0 && CommandExecutor::getEvaluation().getCommand()[CommandExecutor::getEvaluation().getCommand().size() - 1] != ' ')
+                return CommandExecutor::getEvaluation().getTokens()[CommandExecutor::getEvaluation().getTokens().size() - 1];
+
+        return "";
     }
 
     void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment)
     {
+        std::string lowercase = getLowercase(fragment);
         for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)
             if ((*it).second->hasConsoleCommands())
-                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
                     CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
 
@@ -369,8 +437,9 @@
     void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier)
     {
+        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(getLowercase(fragment)) == 0 || fragment == "")
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
                     CommandExecutor::getEvaluation().getListOfPossibleFunctions().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
         }
@@ -378,7 +447,8 @@
         {
             for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
-                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
                     CommandExecutor::getEvaluation().getListOfPossibleFunctions().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
         }
+
         CommandExecutor::getEvaluation().getListOfPossibleFunctions().sort(CommandExecutor::compareStringsInList);
     }
@@ -386,15 +456,27 @@
     void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param)
     {
+std::cout << "2_1\n";
+        std::string lowercase = getLowercase(fragment);
+std::cout << "2_2\n";
         for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(param); it != command->getArgumentCompletionListEnd(param); ++it)
-            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
+        {
+std::cout << "2_3\n";
+            if ((*it).first.find(lowercase) == 0 || fragment == "")
+            {
+std::cout << "2_4\n";
                 CommandExecutor::getEvaluation().getListOfPossibleArguments().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second));
-
-        CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().sort(CommandExecutor::compareStringsInList);
-
+std::cout << "2_5\n";
+            }
+        }
+
+std::cout << "2_6\n";
+        CommandExecutor::getEvaluation().getListOfPossibleArguments().sort(CommandExecutor::compareStringsInList);
+std::cout << "2_7\n";
     }
 
     Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
     {
-        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMap().find(getLowercase(name));
+        std::string lowercase = getLowercase(name);
+        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMap().find(lowercase);
         if ((it != Identifier::getLowercaseIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
             return (*it).second;
@@ -405,7 +487,8 @@
     ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
     {
+        std::string lowercase = getLowercase(name);
         if (!identifier)
         {
-            std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(getLowercase(name));
+            std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);
             if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd())
                 return (*it).second;
@@ -413,5 +496,5 @@
         else
         {
-            std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(getLowercase(name));
+            std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
             if (it != identifier->getLowercaseConsoleCommandMapEnd())
                 return (*it).second;
@@ -422,7 +505,7 @@
     const std::string* CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
     {
-        std::string lowercasename = getLowercase(name);
+        std::string lowercase = getLowercase(name);
         for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(param); it != command->getArgumentCompletionListEnd(param); ++it)
-            if ((*it).first == lowercasename)
+            if ((*it).first == lowercase)
                 return &(*it).second;
 
Index: /code/branches/console/src/core/CommandExecutor.h
===================================================================
--- /code/branches/console/src/core/CommandExecutor.h	(revision 1401)
+++ /code/branches/console/src/core/CommandExecutor.h	(revision 1402)
@@ -76,4 +76,5 @@
             static CommandEvaluation& getEvaluation();
 
+            static void parseIfNeeded(const std::string& command);
             static void parse(const std::string& command, bool bInitialize = true);
 
Index: /code/branches/console/src/core/ConsoleCommand.cc
===================================================================
--- /code/branches/console/src/core/ConsoleCommand.cc	(revision 1401)
+++ /code/branches/console/src/core/ConsoleCommand.cc	(revision 1402)
@@ -43,5 +43,5 @@
     ConsoleCommand& ConsoleCommand::setArgumentCompletionList(unsigned int param, const std::list<std::pair<std::string, std::string> >& (*function) (void))
     {
-        if (param >= 0 && param < 5)
+        if (param < 5)
             this->autocompletionFunction_[param] = function;
         else
@@ -54,5 +54,5 @@
     const std::list<std::pair<std::string, std::string> >& ConsoleCommand::getArgumentCompletionList(unsigned int param) const
     {
-        if (param >= 0 && param < 5)
+        if (param < 5)
             return (*this->autocompletionFunction_[param])();
         else
@@ -62,16 +62,30 @@
     std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListBegin(unsigned int param) const
     {
-        if (param >= 0 && param < 5)
+std::cout << "3_1: param: " << param << "\n";
+        if (param < 5)
+        {
+std::cout << "3_2: >" << this->autocompletionFunction_[param] << "<\n";
             return (*this->autocompletionFunction_[param])().begin();
+        }
         else
+        {
+std::cout << "3_3\n";
             return autocompletion::fallback().begin();
+        }
     }
 
     std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListEnd(unsigned int param) const
     {
-        if (param >= 0 && param < 5)
+std::cout << "4_1: param: " << param << "\n";
+        if (param < 5)
+        {
+std::cout << "4_2: >" << this->autocompletionFunction_[param] << "<\n";
             return (*this->autocompletionFunction_[param])().end();
+        }
         else
+        {
+std::cout << "4_3\n";
             return autocompletion::fallback().end();
+        }
     }
 }
