Index: code/branches/gamestate/data/lua/LuaStateInit.lua
===================================================================
--- code/branches/gamestate/data/lua/LuaStateInit.lua	(revision 6431)
+++ code/branches/gamestate/data/lua/LuaStateInit.lua	(revision 6432)
@@ -58,2 +58,13 @@
   orxonox.CommandExecutor:execute(command)
 end
+
+-- Convenience function for config values
+orxonox.getConfig = function(section, entry)
+  return orxonox.SettingsConfigFile:getInstance():getConfig(section, entry)
+end
+orxonox.config = function(section, entry, value)
+  return orxonox.SettingsConfigFile:getInstance():config(section, entry, value)
+end
+orxonox.tconfig = function(section, entry, value)
+  return orxonox.SettingsConfigFile:getInstance():tconfig(section, entry, value)
+end
Index: code/branches/gamestate/src/libraries/core/ArgumentCompletionFunctions.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/ArgumentCompletionFunctions.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/ArgumentCompletionFunctions.cc	(revision 6432)
@@ -36,4 +36,5 @@
 #include "util/StringUtils.h"
 #include "Identifier.h"
+#include "ConfigFileManager.h"
 #include "ConfigValueContainer.h"
 #include "TclThreadManager.h"
@@ -96,43 +97,46 @@
         }
 
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalueclasses)()
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingssections)()
         {
-            ArgumentCompletionList classlist;
+            ArgumentCompletionList sectionList;
 
-            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
-                if (it->second->hasConfigValues())
-                    classlist.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
+            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 classlist;
+            return sectionList;
         }
 
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname)
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsentries)(const std::string& fragment, const std::string& section)
         {
-            ArgumentCompletionList configvalues;
-            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
+            ArgumentCompletionList entryList;
+            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
+            const std::string& sectionLC = getLowercase(section);
 
-            if (identifier != Identifier::getLowercaseStringIdentifierMapEnd() && identifier->second->hasConfigValues())
+            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)
             {
-                for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->second->getConfigValueMapBegin(); it != identifier->second->getConfigValueMapEnd(); ++it)
-                    configvalues.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
+                if (it->second.first == entryLC)
+                {
+                    const std::string& valuestring = it->second.second->toString();
+                    oldValue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
+                }
             }
 
-            return configvalues;
-        }
-
-        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname)
-        {
-            ArgumentCompletionList oldvalue;
-            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
-            if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
-            {
-                std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
-                if (variable != identifier->second->getLowercaseConfigValueMapEnd())
-                {
-                    const std::string& valuestring = variable->second->toString();
-                    oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
-                }
-            }
-            return oldvalue;
+            return oldValue;
         }
 
Index: code/branches/gamestate/src/libraries/core/ArgumentCompletionFunctions.h
===================================================================
--- code/branches/gamestate/src/libraries/core/ArgumentCompletionFunctions.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/ArgumentCompletionFunctions.h	(revision 6432)
@@ -54,7 +54,7 @@
         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalueclasses)();
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalues)(const std::string& fragment, const std::string& classname);
-        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname);
+        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)();
     }
Index: code/branches/gamestate/src/libraries/core/ConfigFileManager.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/ConfigFileManager.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/ConfigFileManager.cc	(revision 6432)
@@ -40,54 +40,4 @@
 namespace orxonox
 {
-    SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
-    SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
-    SetConsoleCommandShortcutExtern(reloadConfig);
-    SetConsoleCommandShortcutExtern(cleanConfig);
-    SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files());
-
-    bool config(const std::string& classname, const std::string& varname, const std::string& value)
-    {
-        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
-        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
-        {
-            std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
-            if (variable != identifier->second->getLowercaseConfigValueMapEnd())
-                return variable->second->set(value);
-        }
-        return false;
-    }
-
-    const std::string& getConfig(const std::string& classname, const std::string& varname)
-    {
-        return ConfigFileManager::getInstance().getValue(ConfigFileType::Settings, classname, varname, "", true);
-    }
-
-    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
-    {
-        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
-        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
-        {
-            std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
-            if (variable != identifier->second->getLowercaseConfigValueMapEnd())
-                return variable->second->tset(value);
-        }
-        return false;
-    }
-
-    void reloadConfig()
-    {
-        ConfigFileManager::getInstance().load();
-    }
-
-    void cleanConfig()
-    {
-        ConfigFileManager::getInstance().clean(false);
-    }
-
-    void loadSettings(const std::string& filename)
-    {
-        ConfigFileManager::getInstance().setFilename(ConfigFileType::Settings, filename);
-    }
-
     //////////////////////////
     // ConfigFileEntryValue //
@@ -101,5 +51,5 @@
         // Assemble the entry line
         this->fileEntry_ = this->getKeyString() + " = ";
-        if (this->bString_)
+        if (this->bString_ && !this->value_.empty())
             this->fileEntry_ += '"' + addSlashes(this->value_) + '"';
         else
@@ -145,5 +95,5 @@
     }
 
-    unsigned int ConfigFileSection::getVectorSize(const std::string& name)
+    unsigned int ConfigFileSection::getVectorSize(const std::string& name) const
     {
         unsigned int size = 0;
@@ -166,5 +116,15 @@
     }
 
-    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, const std::string& fallback, bool bString)
+    std::list<ConfigFileEntry*>::const_iterator ConfigFileSection::getEntryIterator(const std::string& name) const
+    {
+        for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+        {
+            if ((*it)->getName() == name)
+                return it;
+        }
+        return this->entries_.end();
+    }
+
+    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString)
     {
         for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
@@ -179,8 +139,18 @@
         this->bUpdated_ = true;
 
-        return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryValue(name, fallback, bString)));
-    }
-
-    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+        return this->entries_.insert(this->entries_.end(), new ConfigFileEntryValue(name, fallback, bString));
+    }
+
+    std::list<ConfigFileEntry*>::const_iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index) const
+    {
+        for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+        {
+            if (((*it)->getName() == name) && ((*it)->getIndex() == index))
+                return it;
+        }
+        return this->entries_.end();
+    }
+
+    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     {
         for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
@@ -196,7 +166,7 @@
 
         if (index == 0)
-            return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+            return this->entries_.insert(this->entries_.end(), new ConfigFileEntryVectorValue(name, index, fallback, bString));
         else
-            return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+            return this->entries_.insert(++this->getOrCreateEntryIterator(name, index - 1, "", bString), new ConfigFileEntryVectorValue(name, index, fallback, bString));
     }
 
@@ -205,4 +175,10 @@
     // ConfigFile //
     ////////////////
+    ConfigFile::ConfigFile(const std::string& filename)
+        : filename_(filename)
+        , bUpdated_(false)
+    {
+    }
+
     ConfigFile::~ConfigFile()
     {
@@ -210,5 +186,5 @@
     }
 
-    void ConfigFile::load(bool bCreateIfNotExisting)
+    void ConfigFile::load()
     {
         // Be sure we start from new in the memory
@@ -300,5 +276,5 @@
                                 {
                                     // New array
-                                    std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
+                                    std::list<ConfigFileEntry*>::iterator it = newsection->getOrCreateEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
                                     (*it)->setValue(value);
                                     (*it)->setComment(comment);
@@ -319,9 +295,6 @@
             COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
 
-            // Save the file in case something changed (like stripped whitespaces)
+            // Save the file in case something changed (like stripped white space)
             this->save();
-
-            // Update all ConfigValueContainers
-            this->updateConfigValues();
         } // end file.is_open()
     }
@@ -329,6 +302,11 @@
     void ConfigFile::save() const
     {
+        this->saveAs(this->filename_);
+    }
+
+    void ConfigFile::saveAs(const std::string& filename) const
+    {
         std::ofstream file;
-        file.open((PathConfig::getConfigPathString() + filename_).c_str(), std::fstream::out);
+        file.open((PathConfig::getConfigPathString() + filename).c_str(), std::fstream::out);
         file.setf(std::ios::fixed, std::ios::floatfield);
         file.precision(6);
@@ -336,6 +314,5 @@
         if (!file.is_open())
         {
-            COUT(1) << "An error occurred in ConfigFileManager.cc:" << std::endl;
-            COUT(1) << "Error: Couldn't open config-file \"" << this->filename_ << "\"." << std::endl;
+            COUT(1) << "Error: Couldn't open config-file \"" << filename << "\"." << std::endl;
             return;
         }
@@ -346,7 +323,5 @@
 
             for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)
-            {
                 file << (*it_entries)->getFileEntry() << std::endl;
-            }
 
             file << std::endl;
@@ -355,54 +330,5 @@
         file.close();
 
-        COUT(4) << "Saved config file \"" << this->filename_ << "\"." << std::endl;
-    }
-
-    void ConfigFile::saveAs(const std::string& filename)
-    {
-        std::string temp = this->filename_;
-        this->filename_ = filename;
-        this->save();
-        this->filename_ = temp;
-    }
-
-    void ConfigFile::clean(bool bCleanComments)
-    {
-        for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
-        {
-            std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName());
-            if (it2 != Identifier::getStringIdentifierMapEnd() && it2->second->hasConfigValues())
-            {
-                // The section exists, delete comment
-                if (bCleanComments)
-                    (*it1)->setComment("");
-                for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); )
-                {
-                    std::map<std::string, ConfigValueContainer*>::const_iterator it4 = it2->second->getConfigValueMap().find((*it3)->getName());
-                    if (it4 != it2->second->getConfigValueMapEnd())
-                    {
-                        // The config-value exists, delete comment
-                        if (bCleanComments)
-                            (*it3)->setComment("");
-                        ++it3;
-                    }
-                    else
-                    {
-                        // The config-value doesn't exist
-                        delete (*it3);
-                        (*it1)->entries_.erase(it3++);
-                    }
-                }
-                ++it1;
-            }
-            else
-            {
-                // The section doesn't exist
-                delete (*it1);
-                this->sections_.erase(it1++);
-            }
-        }
-
-        // Save the file
-        this->save();
+        COUT(4) << "Saved config file \"" << filename << "\"." << std::endl;
     }
 
@@ -414,5 +340,36 @@
     }
 
-    ConfigFileSection* ConfigFile::getSection(const std::string& section)
+    const std::string& ConfigFile::getOrCreateValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
+    {
+        const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, fallback, bString);
+        this->saveIfUpdated();
+        return output;
+    }
+
+    const std::string& ConfigFile::getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+    {
+        const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, index, fallback, bString);
+        this->saveIfUpdated();
+        return output;
+    }
+
+    void ConfigFile::deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex)
+    {
+        if (ConfigFileSection* sectionPtr = this->getSection(section))
+        {
+            sectionPtr->deleteVectorEntries(name, startindex);
+            this->save();
+        }
+    }
+
+    ConfigFileSection* ConfigFile::getSection(const std::string& section) const
+    {
+        for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+            if ((*it)->getName() == section)
+                return (*it);
+        return NULL;
+    }
+
+    ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& section)
     {
         for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
@@ -445,19 +402,169 @@
     }
 
-    void ConfigFile::updateConfigValues()
-    {
-        if (this->type_ == ConfigFileType::Settings)
-        {
-            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
-            {
-                if (it->second->hasConfigValues())
+
+    ////////////////////////
+    // SettingsConfigFile //
+    ////////////////////////
+
+    SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0;
+
+    SettingsConfigFile::SettingsConfigFile(const std::string& filename)
+        : 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());
+    }
+
+    SettingsConfigFile::~SettingsConfigFile()
+    {
+    }
+
+    void SettingsConfigFile::load()
+    {
+        ConfigFile::load();
+        this->updateConfigValues();
+    }
+
+    void SettingsConfigFile::setFilename(const std::string& filename)
+    {
+        ConfigFileManager::getInstance().setFilename(ConfigFileType::Settings, filename);
+    }
+
+    void SettingsConfigFile::addConfigValueContainer(ConfigValueContainer* container)
+    {
+        if (container == NULL)
+            return;
+        std::pair<std::string, ConfigValueContainer*> second(getLowercase(container->getName()), container);
+        this->containers_.insert(std::make_pair(getLowercase(container->getSectionName()), second));
+        this->sectionNames_.insert(container->getSectionName());
+    }
+
+    void SettingsConfigFile::removeConfigValueContainer(ConfigValueContainer* container)
+    {
+        if (container == NULL)
+            return;
+        const std::string& sectionLC = getLowercase(container->getSectionName());
+        ContainerMap::iterator upper = this->containers_.upper_bound(sectionLC);
+        for (ContainerMap::iterator it = this->containers_.lower_bound(sectionLC); it != upper; ++it)
+        {
+            if (it->second.second == container)
+            {
+                // Remove entry from section name set this was the last container for that section
+                if (upper == this->containers_.lower_bound(sectionLC))
+                    this->sectionNames_.erase(container->getSectionName());
+                this->containers_.erase(it);
+                break;
+            }
+        }
+    }
+
+    void SettingsConfigFile::updateConfigValues()
+    {
+        for (ContainerMap::const_iterator it = this->containers_.begin(); it != this->containers_.end(); ++it)
+        {
+            it->second.second->update();
+            it->second.second->getIdentifier()->updateConfigValues();
+        }
+    }
+
+    void SettingsConfigFile::clean(bool bCleanComments)
+    {
+        for (std::list<ConfigFileSection*>::iterator itSection = this->sections_.begin(); itSection != this->sections_.end(); )
+        {
+            const std::string& sectionLC = getLowercase((*itSection)->getName());
+            ContainerMap::const_iterator lower = this->containers_.lower_bound(sectionLC);
+            ContainerMap::const_iterator upper = this->containers_.upper_bound(sectionLC);
+            if (lower != upper)
+            {
+                // The section exists, delete comment
+                if (bCleanComments)
+                    (*itSection)->setComment("");
+                for (std::list<ConfigFileEntry*>::iterator itEntry = (*itSection)->entries_.begin(); itEntry != (*itSection)->entries_.end(); )
                 {
-                    for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = it->second->getConfigValueMapBegin(); it2 != it->second->getConfigValueMapEnd(); ++it2)
-                        it2->second->update();
-
-                    it->second->updateConfigValues();
+                    const std::string& entryLC = getLowercase((*itEntry)->getName());
+                    bool bFound = false;
+                    for (ContainerMap::const_iterator itContainer = lower; itContainer != upper; ++itContainer)
+                    {
+                        if (itContainer->second.first == entryLC)
+                        {
+                            // The config-value exists, delete comment
+                            if (bCleanComments)
+                                (*itEntry)->setComment("");
+                            ++itEntry;
+                            bFound = true;
+                            break;
+                        }
+                    }
+                    if (!bFound)
+                    {
+                        // The config-value doesn't exist
+                        delete (*itEntry);
+                        (*itSection)->entries_.erase(itEntry++);
+                    }
                 }
-            }
-        }
+                ++itSection;
+            }
+            else
+            {
+                // The section doesn't exist
+                delete (*itSection);
+                this->sections_.erase(itSection++);
+            }
+        }
+
+        // Save the file
+        this->save();
+    }
+
+    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);
+    }
+
+    bool SettingsConfigFile::configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&))
+    {
+        const std::string& sectionLC = getLowercase(section);
+        const std::string& entryLC = getLowercase(entry);
+        ContainerMap::iterator upper = this->containers_.upper_bound(sectionLC);
+        for (ContainerMap::iterator it = this->containers_.lower_bound(sectionLC); it != upper; ++it)
+        {
+            // Note: Config value vectors cannot be supported
+            if (it->second.first == entryLC && !it->second.second->isVector())
+            {
+                return (it->second.second->*function)(value);
+            }
+        }
+        return false;
+    }
+
+    std::string SettingsConfigFile::getConfig(const std::string& section, const std::string& entry)
+    {
+        const std::string& sectionLC = getLowercase(section);
+        const std::string& entryLC = getLowercase(entry);
+        ContainerMap::iterator upper = this->containers_.upper_bound(sectionLC);
+        for (ContainerMap::iterator it = this->containers_.lower_bound(sectionLC); it != upper; ++it)
+        {
+            // Note: Config value vectors cannot be supported
+            if (it->second.first == entryLC && ! it->second.second->isVector())
+            {
+                std::string value;
+                it->second.second->getValue<std::string, OrxonoxClass>(&value, NULL);
+                return value;
+            }
+        }
+        return "";
     }
 
@@ -469,99 +576,32 @@
     ConfigFileManager* ConfigFileManager::singletonPtr_s = 0;
 
-    std::string ConfigFileManager::DEFAULT_CONFIG_FILE = "default.ini";
-
     ConfigFileManager::ConfigFileManager()
-         : mininmalFreeType_(ConfigFileType::numberOfReservedTypes)
-    {
+    {
+        this->configFiles_.assign(NULL);
     }
 
     ConfigFileManager::~ConfigFileManager()
     {
-        for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); )
-            delete (it++)->second;
-    }
-
-    void ConfigFileManager::setFilename(ConfigFileType type, const std::string& filename)
-    {
-        std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
-        if (it != this->configFiles_.end())
-        {
-            assert(it->second);
-            delete it->second;
-        }
-        this->configFiles_[type] = new ConfigFile(filename, type);
-        this->load(type);
-    }
-
-    void ConfigFileManager::load()
-    {
-        for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
-            it->second->load();
-    }
-
-    void ConfigFileManager::save()
-    {
-        for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
-            it->second->save();
-    }
-
-    void ConfigFileManager::clean(bool bCleanComments)
-    {
-        for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
-            this->clean(it->first, bCleanComments);
-    }
-
-    void ConfigFileManager::load(ConfigFileType type)
-    {
-        this->getFile(type)->load();
-    }
-
-    void ConfigFileManager::save(ConfigFileType type)
-    {
-        this->getFile(type)->save();
-    }
-
-    void ConfigFileManager::saveAs(ConfigFileType type, const std::string& saveFilename)
-    {
-        this->getFile(type)->saveAs(saveFilename);
-    }
-
-    void ConfigFileManager::clean(ConfigFileType type, bool bCleanComments)
-    {
-        this->getFile(type)->clean(bCleanComments);
-    }
-
-    void ConfigFileManager::updateConfigValues()
-    {
-        for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
-            it->second->updateConfigValues();
-    }
-
-    void ConfigFileManager::updateConfigValues(ConfigFileType type)
-    {
-        this->getFile(type)->updateConfigValues();
-    }
-
-    const std::string& ConfigFileManager::getFilename(ConfigFileType type)
-    {
-        std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
-        if (it != this->configFiles_.end())
-            return it->second->getFilename();
-        else
-            return BLANKSTRING;
-    }
-
-    ConfigFile* ConfigFileManager::getFile(ConfigFileType type)
-    {
-        std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
-        if (it != this->configFiles_.end())
-            return it->second;
-        else
-        {
-            COUT(1) << "ConfigFileManager: Can't find a config file for type with ID " << static_cast<int>(type) << std::endl;
-            COUT(1) << "Using " << DEFAULT_CONFIG_FILE << " file." << std::endl;
-            this->setFilename(type, DEFAULT_CONFIG_FILE);
-            return getFile(type);
-        }
+        for (boost::array<ConfigFile*, 3>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            if (*it)
+                delete (*it);
+    }
+
+    void ConfigFileManager::setFilename(ConfigFileType::Value type, const std::string& filename)
+    {
+        if (this->getConfigFile(type))
+            delete this->configFiles_[type];
+        // Create and load config file
+        switch (type)
+        {
+        case ConfigFileType::Settings:
+            this->configFiles_[type] = new SettingsConfigFile(filename);
+            break;
+        case ConfigFileType::JoyStickCalibration:
+        case ConfigFileType::CommandHistory:
+            this->configFiles_[type] = new ConfigFile(filename);
+            break;
+        }
+        this->configFiles_[type]->load();
     }
 }
Index: code/branches/gamestate/src/libraries/core/ConfigFileManager.h
===================================================================
--- code/branches/gamestate/src/libraries/core/ConfigFileManager.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/ConfigFileManager.h	(revision 6432)
@@ -32,37 +32,14 @@
 #include "CorePrereqs.h"
 
-#include <cassert>
-#include <string>
 #include <list>
 #include <map>
-
-#include "util/OrxEnum.h"
+#include <set>
+#include <string>
+#include <boost/array.hpp>
+
 #include "util/Singleton.h"
 
-// tolua_begin
-namespace orxonox
-{
-    // tolua_end
-    // Use int as config file type to have an arbitrary number of files
-    struct ConfigFileType : OrxEnum<ConfigFileType>
-    {
-        OrxEnumConstructors(ConfigFileType);
-
-        static const int NoType              = 0;
-        static const int Settings            = 1;
-        static const int JoyStickCalibration = 2;
-        static const int CommandHistory      = 3;
-
-        static const int numberOfReservedTypes = 1024;
-    };
-
-    _CoreExport bool config(const std::string& classname, const std::string& varname, const std::string& value); // tolua_export
-    _CoreExport const std::string& getConfig(const std::string& classname, const std::string& varname); // tolua_export
-    _CoreExport bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
-    _CoreExport void reloadConfig();
-    _CoreExport void saveConfig();
-    _CoreExport void cleanConfig();
-    _CoreExport void loadSettings(const std::string& filename);
-
+namespace orxonox // tolua_export
+{ // tolua_export
 
     /////////////////////
@@ -196,4 +173,5 @@
     {
         friend class ConfigFile;
+        friend class SettingsConfigFile;
 
         public:
@@ -212,15 +190,25 @@
 
             inline void setValue(const std::string& name, const std::string& value, bool bString)
-                { this->getEntry(name, value, bString)->setValue(value); }
-            inline const std::string& getValue(const std::string& name, const std::string& fallback, bool bString)
-                { return this->getEntry(name, fallback, bString)->getValue(); }
+                { this->getOrCreateEntry(name, value, bString)->setValue(value); }
+            inline const std::string& getValue(const std::string& name, const std::string& fallback, bool bString) const
+            {
+                ConfigFileEntry* entry = this->getEntry(name);
+                return (entry ? entry->getValue() : BLANKSTRING);
+            }
+            inline const std::string& getOrCreateValue(const std::string& name, const std::string& fallback, bool bString)
+                { return this->getOrCreateEntry(name, fallback, bString)->getValue(); }
 
             inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString)
-                { this->getEntry(name, index, value, bString)->setValue(value); }
-            inline const std::string& getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
-                { return this->getEntry(name, index, fallback, bString)->getValue(); }
+                { this->getOrCreateEntry(name, index, value, bString)->setValue(value); }
+            inline const std::string& getValue(const std::string& name, unsigned int index) const
+            {
+                ConfigFileEntry* entry = this->getEntry(name, index);
+                return (entry ? entry->getValue() : BLANKSTRING);
+            }
+            inline const std::string& getOrCreateValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return this->getOrCreateEntry(name, index, fallback, bString)->getValue(); }
 
             void deleteVectorEntries(const std::string& name, unsigned int startindex = 0);
-            unsigned int getVectorSize(const std::string& name);
+            unsigned int getVectorSize(const std::string& name) const;
 
             std::string getFileEntry() const;
@@ -234,11 +222,17 @@
                 { return this->entries_.end(); }
 
-            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback, bool bString);
-            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
-
-            inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback, bool bString)
-                { return (*this->getEntryIterator(name, fallback, bString)); }
-            inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
-                { return (*this->getEntryIterator(name, index, fallback, bString)); }
+            std::list<ConfigFileEntry*>::const_iterator getEntryIterator(const std::string& name) const;
+            std::list<ConfigFileEntry*>::iterator       getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString);
+            std::list<ConfigFileEntry*>::const_iterator getEntryIterator(const std::string& name, unsigned int index) const;
+            std::list<ConfigFileEntry*>::iterator       getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
+
+            inline ConfigFileEntry* getEntry(const std::string& name) const
+                { return (*this->getEntryIterator(name)); }
+            inline ConfigFileEntry* getOrCreateEntry(const std::string& name, const std::string& fallback, bool bString)
+                { return (*this->getOrCreateEntryIterator(name, fallback, bString)); }
+            inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index) const
+                { return (*this->getEntryIterator(name, index)); }
+            inline ConfigFileEntry* getOrCreateEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return (*this->getOrCreateEntryIterator(name, index, fallback, bString)); }
 
             std::string name_;
@@ -255,45 +249,101 @@
     {
         public:
-            inline ConfigFile(const std::string& filename, ConfigFileType type)
-                : filename_(filename)
-                , type_(type)
-                , bUpdated_(false)
-            { }
-            ~ConfigFile();
-
-            void load(bool bCreateIfNotExisting = true);
-            void save() const;
-            void saveAs(const std::string& filename);
-            void clean(bool bCleanComments = false);
-            void clear();
-
-            const std::string& getFilename() { return this->filename_; }
+            ConfigFile(const std::string& filename);
+            virtual ~ConfigFile();
+
+            virtual void load();
+            virtual void save() const;
+            virtual void saveAs(const std::string& filename) const;
+            virtual void clear();
+
+            inline const std::string& getFilename()
+                { return this->filename_; }
 
             inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString)
-                { this->getSection(section)->setValue(name, value, bString); this->save(); }
-            inline const std::string& getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
-                { const std::string& output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
+            {
+                this->getOrCreateSection(section)->setValue(name, value, bString);
+                this->save();
+            }
+            inline const std::string& getValue(const std::string& section, const std::string& name, bool bString) const
+            {
+                ConfigFileSection* sectionPtr = this->getSection(section);
+                return (sectionPtr ? sectionPtr->getValue(name, bString) : BLANKSTRING);
+            }
+            const std::string& getOrCreateValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString);
 
             inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
-                { this->getSection(section)->setValue(name, index, value, bString); this->save(); }
-            inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
-                { const std::string& output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
-
-            inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
-                { this->getSection(section)->deleteVectorEntries(name, startindex); }
-            inline unsigned int getVectorSize(const std::string& section, const std::string& name)
-                { return this->getSection(section)->getVectorSize(name); }
-
+            {
+                this->getSection(section)->setValue(name, index, value, bString);
+                this->save();
+            }
+            inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index) const
+            {
+                ConfigFileSection* sectionPtr = this->getSection(section);
+                return (sectionPtr ? sectionPtr->getValue(name, index) : BLANKSTRING);
+            }
+            const std::string& getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString);
+
+            void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0);
+            inline unsigned int getVectorSize(const std::string& section, const std::string& name) const
+            {
+                ConfigFileSection* sectionPtr = this->getSection(section);
+                return (sectionPtr ? sectionPtr->getVectorSize(name) : 0);
+            }
+
+        protected:
+            ConfigFileSection* getSection(const std::string& section) const;
+            ConfigFileSection* getOrCreateSection(const std::string& section);
+
+            std::list<ConfigFileSection*> sections_;
+
+        private:
+            void saveIfUpdated();
+            const std::string filename_;
+            bool bUpdated_;
+    };
+
+
+    ////////////////////////
+    // SettingsConfigFile //
+    ////////////////////////
+    class _CoreExport SettingsConfigFile // tolua_export
+        : public ConfigFile, public Singleton<SettingsConfigFile>
+    { // tolua_export
+        friend class Singleton<SettingsConfigFile>;
+
+        public:
+            typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*> > ContainerMap;
+
+            SettingsConfigFile(const std::string& filename);
+            ~SettingsConfigFile();
+
+            void load(); // tolua_export
+            void setFilename(const std::string& filename); // tolua_export
+            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
+            std::string getConfig(const std::string& section, const std::string& entry); // tolua_export
+
+            void addConfigValueContainer(ConfigValueContainer* container);
+            void removeConfigValueContainer(ConfigValueContainer* container);
+
+            inline const std::set<std::string>& getSectionNames()
+                { return this->sectionNames_; }
+            inline ContainerMap::const_iterator getContainerLowerBound(const std::string section)
+                { return this->containers_.lower_bound(section); }
+            inline ContainerMap::const_iterator getContainerUpperBound(const std::string section)
+                { return this->containers_.upper_bound(section); }
+
+            static SettingsConfigFile& getInstance() { return Singleton<SettingsConfigFile>::getInstance(); } // tolua_export
+
+        private:
             void updateConfigValues();
-
-        private:
-            ConfigFileSection* getSection(const std::string& section);
-            void saveIfUpdated();
-
-            std::string filename_;
-            ConfigFileType type_;
-            std::list<ConfigFileSection*> sections_;
-            bool bUpdated_;
-    };
+            bool configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&));
+
+            ContainerMap containers_;
+            std::set<std::string> sectionNames_;
+            static SettingsConfigFile* singletonPtr_s;
+    }; // tolua_export
 
 
@@ -308,46 +358,16 @@
             ~ConfigFileManager();
 
-            void load();
-            void save();
-            void clean(bool bCleanComments = false);
-
-            void setFilename(ConfigFileType type, const std::string& filename);
-            const std::string& getFilename(ConfigFileType type);
-
-            ConfigFileType getNewConfigFileType() { return mininmalFreeType_++; }
-
-            void load(ConfigFileType type);
-            void save(ConfigFileType type);
-            void saveAs(ConfigFileType type, const std::string& saveFilename);
-            void clean(ConfigFileType type, bool bCleanComments = false);
-
-            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value, bool bString)
-                { this->getFile(type)->setValue(section, name, value, bString); }
-            inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString)
-                { return this->getFile(type)->getValue(section, name, fallback, bString); }
-
-            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
-                { this->getFile(type)->setValue(section, name, index, value, bString); }
-            inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
-                { return this->getFile(type)->getValue(section, name, index, fallback, bString); }
-
-            inline void deleteVectorEntries(ConfigFileType type, const std::string& section, const std::string& name, unsigned int startindex = 0)
-                { this->getFile(type)->deleteVectorEntries(section, name, startindex); }
-            inline unsigned int getVectorSize(ConfigFileType type, const std::string& section, const std::string& name)
-                { return this->getFile(type)->getVectorSize(section, name); }
-
-            void updateConfigValues();
-            void updateConfigValues(ConfigFileType type);
-
-            static std::string DEFAULT_CONFIG_FILE;
+            void setFilename(ConfigFileType::Value type, const std::string& filename);
+
+            inline ConfigFile* getConfigFile(ConfigFileType::Value type)
+            {
+                // Check array bounds
+                return configFiles_.at(type);
+            }
 
         private:
             ConfigFileManager(const ConfigFileManager&);
 
-            ConfigFile* getFile(ConfigFileType type);
-
-            std::map<ConfigFileType, ConfigFile*> configFiles_;
-            unsigned int mininmalFreeType_;
-
+            boost::array<ConfigFile*, 3> configFiles_;
             static ConfigFileManager* singletonPtr_s;
     };
Index: code/branches/gamestate/src/libraries/core/ConfigValueContainer.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/ConfigValueContainer.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/ConfigValueContainer.cc	(revision 6432)
@@ -36,4 +36,5 @@
 #include "util/Convert.h"
 #include "util/SubString.h"
+#include "ConfigFileManager.h"
 #include "Language.h"
 
@@ -43,7 +44,7 @@
 
     /**
-        @brief Initializes the ConfigValueContainer with defaultvalues.
-    */
-    void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname)
+        @brief Initializes the ConfigValueContainer with default values.
+    */
+    void ConfigValueContainer::init(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname)
     {
         this->type_ = type;
@@ -55,4 +56,8 @@
         this->bDoInitialCallback_ = false;
         this->bAddedDescription_ = false;
+
+        // Register containers for general settings
+        if (this->type_ == ConfigFileType::Settings)
+            SettingsConfigFile::getInstance().addConfigValueContainer(this);
     }
 
@@ -78,5 +83,5 @@
         for (unsigned int i = 0; i < this->valueVector_.size(); i++)
         {
-            ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
+            ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
             this->defvalueStringVector_.push_back(this->valueVector_[i]);
         }
@@ -92,4 +97,8 @@
         if (this->callback_)
             delete this->callback_;
+
+        // Unregister general settings containers
+        if (this->type_ == ConfigFileType::Settings && SettingsConfigFile::exists())
+            SettingsConfigFile::getInstance().removeConfigValueContainer(this);
     }
 
@@ -109,5 +118,5 @@
             if (this->tset(input))
             {
-                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
+                ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
                 return true;
             }
@@ -128,5 +137,5 @@
             if (this->tset(index, input))
             {
-                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
+                ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
                 return true;
             }
@@ -228,6 +237,6 @@
                 this->valueVector_.erase(this->valueVector_.begin() + index);
                 for (unsigned int i = index; i < this->valueVector_.size(); i++)
-                    ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
-                ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
+                    ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
+                ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->valueVector_.size());
 
                 return true;
@@ -253,5 +262,5 @@
                 if (!this->set(i, this->defvalueStringVector_[i]))
                     success = false;
-            ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size());
+            ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->defvalueStringVector_.size());
             return success;
         }
@@ -264,18 +273,18 @@
     {
         if (!this->bIsVector_)
-            this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
+            this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
         else
         {
             this->valueVector_.clear();
-            unsigned int vectorSize = ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_);
+            unsigned int vectorSize = ConfigFileManager::getInstance().getConfigFile(this->type_)->getVectorSize(this->sectionname_, this->varname_);
             for (unsigned int i = 0; i < vectorSize; i++)
             {
                 if (i < this->defvalueStringVector_.size())
                 {
-                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
+                    this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
                 }
                 else
                 {
-                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
+                    this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
                 }
 
Index: code/branches/gamestate/src/libraries/core/ConfigValueContainer.h
===================================================================
--- code/branches/gamestate/src/libraries/core/ConfigValueContainer.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/ConfigValueContainer.h	(revision 6432)
@@ -50,5 +50,4 @@
 
 #include "util/MultiType.h"
-#include "ConfigFileManager.h"
 #include "Identifier.h"
 
@@ -108,5 +107,5 @@
             */
             template <class D, class V>
-            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const D& defvalue, const V& value)
+            ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const D& defvalue, const V& value)
             {
                 this->init(type, identifier, sectionname, varname);
@@ -122,5 +121,5 @@
             */
             template <class D, class V>
-            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>& value)
+            ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>& value)
             {
                 this->init(type, identifier, sectionname, varname);
@@ -217,7 +216,10 @@
             inline const std::string& getName() const
                 { return this->varname_; }
-            /** @brief Retuns the name of the section this config value is in. */
+            /** @brief Returns the name of the section this config value is in. */
             inline const std::string& getSectionName() const
                 { return this->sectionname_; }
+            /** @brief Returns the associated identifier (can be NULL). */
+            inline Identifier* getIdentifier() const
+                { return this->identifier_; }
             /** @brief Returns true if this config-value is a vector */
             inline bool isVector() const
@@ -271,5 +273,5 @@
 
         private:
-            void init(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname);
+            void init(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname);
             void initValue(const MultiType& defvalue);
             void initVector();
@@ -278,5 +280,5 @@
             bool                       bIsVector_;                  //!< True if the container contains a std::vector
 
-            ConfigFileType             type_;                       //!< The type of the corresponding config-file
+            ConfigFileType::Value      type_;                       //!< The type of the corresponding config-file
             Identifier*                identifier_;                 //!< The identifier of the class
             std::string                sectionname_;                //!< The name of the class the variable belongs to
Index: code/branches/gamestate/src/libraries/core/ConfigValueIncludes.h
===================================================================
--- code/branches/gamestate/src/libraries/core/ConfigValueIncludes.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/ConfigValueIncludes.h	(revision 6432)
@@ -40,5 +40,4 @@
 #include "Identifier.h"
 #include "ConfigValueContainer.h"
-#include "ConfigFileManager.h"
 
 namespace orxonox
@@ -61,5 +60,5 @@
     */
     template <class T, class D, class V>
-    inline ConfigValueContainer& setConfigValueGeneric(T* object, V* variable, ConfigFileType type, const std::string& sectionName, const std::string& entryName, const D& defaultValue)
+    inline ConfigValueContainer& setConfigValueGeneric(T* object, V* variable, ConfigFileType::Value type, const std::string& sectionName, const std::string& entryName, const D& defaultValue)
     {
         ConfigValueContainer* container = ClassIdentifier<T>::getIdentifier()->getConfigValueContainer(entryName);
Index: code/branches/gamestate/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/gamestate/src/libraries/core/CorePrereqs.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/CorePrereqs.h	(revision 6432)
@@ -84,4 +84,15 @@
     }
 
+    namespace ConfigFileType
+    {
+        enum Value
+        {
+            Settings,
+            JoyStickCalibration,
+            CommandHistory
+            // Don't forget to adjust the array size in the ConfigFileManager when adding a new entry here!
+        };
+    }
+
     namespace KeybindMode
     {
@@ -124,5 +135,4 @@
     class ConfigFileManager;
     class ConfigFileSection;
-    struct ConfigFileType;
     class ConfigValueContainer;
     class ConsoleCommand;
@@ -172,4 +182,5 @@
     class PathConfig;
     struct ResourceInfo;
+    class SettingsConfigFile;
     class Shell;
     class ShellListener;
Index: code/branches/gamestate/src/libraries/core/Identifier.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/Identifier.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/Identifier.cc	(revision 6432)
@@ -416,5 +416,4 @@
         this->bHasConfigValues_ = true;
         this->configValues_[varname] = container;
-        this->configValues_LC_[getLowercase(varname)] = container;
     }
 
@@ -428,18 +427,4 @@
         std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname);
         if (it != configValues_.end())
-            return it->second;
-        else
-            return 0;
-    }
-
-    /**
-        @brief Returns the ConfigValueContainer of a variable, given by the string of its name in lowercase.
-        @param varname The name of the variable in lowercase
-        @return The ConfigValueContainer
-    */
-    ConfigValueContainer* Identifier::getLowercaseConfigValueContainer(const std::string& varname)
-    {
-        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname);
-        if (it != configValues_LC_.end())
             return it->second;
         else
Index: code/branches/gamestate/src/libraries/core/Identifier.h
===================================================================
--- code/branches/gamestate/src/libraries/core/Identifier.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/Identifier.h	(revision 6432)
@@ -200,21 +200,6 @@
             inline bool hasConfigValues() const { return this->bHasConfigValues_; }
 
-            /** @brief Returns the map that stores all config values. @return The const_iterator */
-            inline const std::map<std::string, ConfigValueContainer*>& getConfigValueMap() const { return this->configValues_; }
-            /** @brief Returns a const_iterator to the beginning of the map that stores all config values. @return The const_iterator */
-            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapBegin() const { return this->configValues_.begin(); }
-            /** @brief Returns a const_iterator to the end of the map that stores all config values. @return The const_iterator */
-            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapEnd() const { return this->configValues_.end(); }
-
-            /** @brief Returns the map that stores all config values with their names in lowercase. @return The const_iterator */
-            inline const std::map<std::string, ConfigValueContainer*>& getLowercaseConfigValueMap() const { return this->configValues_LC_; }
-            /** @brief Returns a const_iterator to the beginning of the map that stores all config values with their names in lowercase. @return The const_iterator */
-            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapBegin() const { return this->configValues_LC_.begin(); }
-            /** @brief Returns a const_iterator to the end of the map that stores all config values with their names in lowercase. @return The const_iterator */
-            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); }
-
             void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
             ConfigValueContainer* getConfigValueContainer(const std::string& varname);
-            ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
 
 
@@ -320,5 +305,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
-            std::map<std::string, ConfigValueContainer*> configValues_LC_; //!< 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
Index: code/branches/gamestate/src/libraries/core/Shell.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/Shell.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/Shell.cc	(revision 6432)
@@ -34,4 +34,5 @@
 #include "CommandExecutor.h"
 #include "CoreIncludes.h"
+#include "ConfigFileManager.h"
 #include "ConfigValueIncludes.h"
 #include "ConsoleCommand.h"
Index: code/branches/gamestate/src/libraries/core/Shell.h
===================================================================
--- code/branches/gamestate/src/libraries/core/Shell.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/Shell.h	(revision 6432)
@@ -39,5 +39,4 @@
 #include "util/OutputHandler.h"
 #include "OrxonoxClass.h"
-#include "ConfigFileManager.h"
 #include "input/InputBuffer.h"
 
Index: code/branches/gamestate/src/libraries/core/input/Button.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/input/Button.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/input/Button.cc	(revision 6432)
@@ -42,4 +42,5 @@
 #include "core/CommandEvaluation.h"
 #include "core/CommandExecutor.h"
+#include "core/ConfigFileManager.h"
 
 namespace orxonox
@@ -81,14 +82,14 @@
     }
 
-    void Button::readBinding(ConfigFileType type)
-    {
-        const std::string& binding = ConfigFileManager::getInstance().getValue(type, groupName_, name_, "", true);
+    void Button::readBinding(ConfigFile* configFile)
+    {
+        const std::string& binding = configFile->getOrCreateValue(groupName_, name_, "", true);
         this->parse(binding);
     }
 
-    void Button::setBinding(ConfigFileType type, const std::string& binding, bool bTemporary)
+    void Button::setBinding(ConfigFile* configFile, const std::string& binding, bool bTemporary)
     {
         if (!bTemporary)
-            ConfigFileManager::getInstance().setValue(type, groupName_, name_, binding, true);
+            configFile->setValue(groupName_, name_, binding, true);
         this->parse(binding);
     }
Index: code/branches/gamestate/src/libraries/core/input/Button.h
===================================================================
--- code/branches/gamestate/src/libraries/core/input/Button.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/input/Button.h	(revision 6432)
@@ -41,5 +41,4 @@
 #include <vector>
 #include "InputCommands.h"
-#include "core/ConfigFileManager.h"
 
 namespace orxonox
@@ -53,6 +52,6 @@
         virtual bool addParamCommand(ParamCommand* command) { return false; }
         void parse(const std::string& binding);
-        void readBinding(ConfigFileType type);
-        void setBinding(ConfigFileType type, const std::string& binding, bool bTemporary);
+        void readBinding(ConfigFile* configFile);
+        void setBinding(ConfigFile* configFile, const std::string& binding, bool bTemporary);
         bool execute(KeybindMode::Value mode, float abs = 1.0f, float rel = 1.0f);
 
Index: code/branches/gamestate/src/libraries/core/input/JoyStick.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/input/JoyStick.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/input/JoyStick.cc	(revision 6432)
@@ -106,5 +106,5 @@
     {
         list.resize(size);
-        unsigned int configValueVectorSize = ConfigFileManager::getInstance().getVectorSize(ConfigFileType::JoyStickCalibration, sectionName, valueName);
+        unsigned int configValueVectorSize = ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)->getVectorSize(sectionName, valueName);
         if (configValueVectorSize > size)
             configValueVectorSize = size;
@@ -112,6 +112,6 @@
         for (unsigned int i = 0; i < configValueVectorSize; ++i)
         {
-            list[i] = multi_cast<int>(ConfigFileManager::getInstance().getValue(
-                ConfigFileType::JoyStickCalibration, sectionName, valueName, i, multi_cast<std::string>(defaultValue), false));
+            list[i] = multi_cast<int>(ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
+                ->getOrCreateValue(sectionName, valueName, i, multi_cast<std::string>(defaultValue), false));
         }
 
@@ -153,16 +153,16 @@
             if (configMinValues_[i] == INT_MAX)
                 configMinValues_[i] = -32768;
-            ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
-                deviceName_, "MinValue", i, multi_cast<std::string>(configMinValues_[i]), false);
+            ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
+                ->getOrCreateValue(deviceName_, "MinValue", i, multi_cast<std::string>(configMinValues_[i]), false);
 
             // Maximum values
             if (configMaxValues_[i] == INT_MIN)
                 configMaxValues_[i] = 32767;
-            ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
-                deviceName_, "MaxValue", i, multi_cast<std::string>(configMaxValues_[i]), false);
+            ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
+                ->getOrCreateValue(deviceName_, "MaxValue", i, multi_cast<std::string>(configMaxValues_[i]), false);
 
             // Middle values
-            ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
-                deviceName_, "ZeroValue", i, multi_cast<std::string>(configZeroValues_[i]), false);
+            ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
+                ->getOrCreateValue(deviceName_, "ZeroValue", i, multi_cast<std::string>(configZeroValues_[i]), false);
         }
 
Index: code/branches/gamestate/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/input/KeyBinder.cc	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/input/KeyBinder.cc	(revision 6432)
@@ -49,4 +49,5 @@
         : deriveTime_(0.0f)
         , filename_(filename)
+        , configFile_(NULL)
     {
         mouseRelative_[0] = 0;
@@ -93,7 +94,4 @@
             mouseAxes_[i].groupName_ = "MouseAxes";
         }
-
-        // We might not even load any bindings at all (KeyDetector for instance)
-        this->configFile_ = ConfigFileType::NoType;
 
         // initialise joy sticks separatly to allow for reloading
@@ -163,5 +161,5 @@
 
         // load the bindings if required
-        if (configFile_ != ConfigFileType::NoType)
+        if (configFile_ != NULL)
         {
             for (unsigned int iDev = oldValue; iDev < joySticks_.size(); ++iDev)
@@ -249,8 +247,6 @@
         COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
 
-        // Get a new ConfigFileType from the ConfigFileManager
-        this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
-
-        ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_);
+        this->configFile_ = new ConfigFile(this->filename_);
+        this->configFile_->load();
 
         // Parse bindings and create the ConfigValueContainers if necessary
Index: code/branches/gamestate/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/branches/gamestate/src/libraries/core/input/KeyBinder.h	(revision 6431)
+++ code/branches/gamestate/src/libraries/core/input/KeyBinder.h	(revision 6432)
@@ -38,5 +38,4 @@
 #include <boost/shared_ptr.hpp>
 
-#include "core/ConfigFileManager.h"
 #include "InputHandler.h"
 #include "Button.h"
@@ -157,6 +156,6 @@
         //! Name of the file used in this KeyBinder (constant!)
         const std::string filename_;
-        //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
-        ConfigFileType configFile_;
+        //! Config file used. NULL in case of KeyDetector. Also indicates whether we've already loaded.
+        ConfigFile* configFile_;
 
     private:
