Index: /code/branches/core2/src/orxonox/core/ConfigFileManager.cc
===================================================================
--- /code/branches/core2/src/orxonox/core/ConfigFileManager.cc	(revision 1026)
+++ /code/branches/core2/src/orxonox/core/ConfigFileManager.cc	(revision 1027)
@@ -38,5 +38,4 @@
 {
     ConsoleCommandShortcutExtern(reloadConfig, AccessLevel::None);
-    ConsoleCommandShortcutExtern(saveConfig, AccessLevel::None);
     ConsoleCommandShortcutExtern(cleanConfig, AccessLevel::None);
     ConsoleCommandShortcutExtern(loadSettings, AccessLevel::None);
@@ -48,9 +47,4 @@
     }
 
-    void saveConfig()
-    {
-        ConfigFileManager::getSingleton()->save();
-    }
-
     void cleanConfig()
     {
@@ -60,5 +54,5 @@
     void loadSettings(const std::string& filename)
     {
-        ConfigFileManager::getSingleton()->setFile(CFT_Settings, filename);
+        ConfigFileManager::getSingleton()->setFile(CFT_Settings, filename, false);
     }
 
@@ -145,10 +139,13 @@
     }
 
-    void ConfigFile::load()
-    {
-        // This creates the file if it's not existing
-        std::ofstream createFile;
-        createFile.open(this->filename_.c_str(), std::fstream::app);
-        createFile.close();
+    void ConfigFile::load(bool bCreateIfNotExisting)
+    {
+        if (bCreateIfNotExisting)
+        {
+            // This creates the default config file if it's not existing
+            std::ofstream createFile;
+            createFile.open(this->filename_.c_str(), std::fstream::app);
+            createFile.close();
+        }
 
         // Open the file
@@ -289,4 +286,39 @@
     void ConfigFile::clean()
     {
+        for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
+        {
+            std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getIdentifierMap().find((*it1)->getName());
+            if (it2 != Identifier::getIdentifierMapEnd() && (*it2).second->hasConfigValues())
+            {
+                // The section exists, delete comment
+                (*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
+                        (*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();
     }
 
@@ -343,5 +375,5 @@
     }
 
-    void ConfigFileManager::setFile(ConfigFileType type, const std::string& filename)
+    void ConfigFileManager::setFile(ConfigFileType type, const std::string& filename, bool bCreateIfNotExisting)
     {
         std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
@@ -351,11 +383,11 @@
 
         this->configFiles_[type] = new ConfigFile(this->getFilePath(filename));
-        this->load(type);
-    }
-
-    void ConfigFileManager::load()
+        this->load(type, bCreateIfNotExisting);
+    }
+
+    void ConfigFileManager::load(bool bCreateIfNotExisting)
     {
         for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
-            (*it).second->load();
+            (*it).second->load(bCreateIfNotExisting);
 
         this->updateConfigValues();
@@ -374,7 +406,7 @@
     }
 
-    void ConfigFileManager::load(ConfigFileType type)
-    {
-        this->getFile(type)->load();
+    void ConfigFileManager::load(ConfigFileType type, bool bCreateIfNotExisting)
+    {
+        this->getFile(type)->load(bCreateIfNotExisting);
         this->updateConfigValues(type);
     }
Index: /code/branches/core2/src/orxonox/core/ConfigFileManager.h
===================================================================
--- /code/branches/core2/src/orxonox/core/ConfigFileManager.h	(revision 1026)
+++ /code/branches/core2/src/orxonox/core/ConfigFileManager.h	(revision 1027)
@@ -65,4 +65,5 @@
             virtual const std::string& getValue() const = 0;
             virtual const std::string& getName() const = 0;
+            virtual void setComment(const std::string& comment) = 0;
             virtual unsigned int getIndex() const { return 0; }
             virtual std::string getFileEntry() const = 0;
@@ -81,4 +82,7 @@
             inline virtual const std::string& getName() const
                 { return this->name_; }
+
+            inline virtual void setComment(const std::string& comment)
+                { this->additionalComment_ = comment; }
 
             inline virtual void setValue(const std::string& value)
@@ -133,4 +137,7 @@
                 { return this->comment_; }
 
+            inline virtual void setComment(const std::string& comment)
+                { this->comment_ = comment; }
+
             inline virtual void setValue(const std::string& value)
                 {}
@@ -159,4 +166,7 @@
             inline const std::string& getName() const
                 { return this->name_; }
+
+            inline void setComment(const std::string& comment)
+                { this->additionalComment_ = comment; }
 
             inline void setValue(const std::string& name, const std::string& value)
@@ -204,5 +214,5 @@
             ~ConfigFile();
 
-            void load();
+            void load(bool bCreateIfNotExisting = true);
             void save() const;
             void clean();
@@ -236,11 +246,11 @@
             static ConfigFileManager* getSingleton();
 
-            void setFile(ConfigFileType type, const std::string& filename);
-
-            void load();
+            void setFile(ConfigFileType type, const std::string& filename, bool bCreateIfNotExisting = true);
+
+            void load(bool bCreateIfNotExisting = true);
             void save();
             void clean();
 
-            void load(ConfigFileType type);
+            void load(ConfigFileType type, bool bCreateIfNotExisting = true);
             void save(ConfigFileType type);
             void clean(ConfigFileType type);
