Index: code/branches/buildsystem3/src/CMakeLists.txt
===================================================================
--- code/branches/buildsystem3/src/CMakeLists.txt	(revision 2688)
+++ code/branches/buildsystem3/src/CMakeLists.txt	(revision 2690)
@@ -69,5 +69,5 @@
 # which one we have to define the macros separately for each configuration
 ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=Debug"          Debug)
-ADD_COMPILER_FLAGS("-DCMAKE_BIULD_TYPE=Release"        Release)
+ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=Release"        Release)
 ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=RelWithDebInfo" RelWithDebInfo)
 ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=MinSizeRel"     MinSizeRel)
Index: code/branches/buildsystem3/src/core/CMakeLists.txt
===================================================================
--- code/branches/buildsystem3/src/core/CMakeLists.txt	(revision 2688)
+++ code/branches/buildsystem3/src/core/CMakeLists.txt	(revision 2690)
@@ -68,16 +68,4 @@
 GENERATE_TOLUA_BINDINGS(Core CORE_FILES INPUTFILES LuaBind.h CommandExecutor.h)
 
-IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
-  # Get around displaying a few hundred lines of warning code
-  SET_SOURCE_FILES_PROPERTIES(
-    ArgumentCompletionFunctions.cc
-    CommandLine.cc
-    ConfigFileManager.cc
-    Language.cc
-    LuaBind.cc
-    input/KeyBinder.cc
-    PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
-ENDIF()
-
 ADD_LIBRARY(core SHARED ${CORE_FILES})
 
Index: code/branches/buildsystem3/src/core/ConfigFileManager.cc
===================================================================
--- code/branches/buildsystem3/src/core/ConfigFileManager.cc	(revision 2688)
+++ code/branches/buildsystem3/src/core/ConfigFileManager.cc	(revision 2690)
@@ -223,124 +223,128 @@
     void ConfigFile::load(bool bCreateIfNotExisting)
     {
-        // Be sure we start from new
+        // Be sure we start from new in the memory
         this->clear();
 
-        boost::filesystem::path filepath(Core::getConfigPath() + "/" + this->filename_);
-
-        // This creates the config file if it's not existing
-        std::ofstream createFile;
-        createFile.open(filepath.file_string().c_str(), std::fstream::app);
-        createFile.close();
+        // Get default file if necessary and available
+        boost::filesystem::path filepath(Core::getConfigPath());
+        filepath /= this->filename_;
+        if (!boost::filesystem::exists(filepath))
+        {
+            // Try to get default one from the media folder
+            boost::filesystem::path defaultFilepath(Core::getMediaPath());
+            defaultFilepath = defaultFilepath / "defaultConfig" / this->filename_;
+            if (boost::filesystem::exists(defaultFilepath))
+            {
+                boost::filesystem::copy_file(defaultFilepath, filepath);
+            }
+        }
 
         // Open the file
         std::ifstream file;
         file.open(filepath.file_string().c_str(), std::fstream::in);
-
-        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;
-            return;
-        }
-
-        char linearray[CONFIG_FILE_MAX_LINELENGHT];
-
-        ConfigFileSection* newsection = 0;
-
-        while (file.good() && !file.eof())
-        {
-            file.getline(linearray, CONFIG_FILE_MAX_LINELENGHT);
-
-            std::string line = std::string(linearray);
-
-            std::string temp = getStripped(line);
-            if (!isEmpty(temp) && !isComment(temp))
-            {
-                size_t   pos1 = temp.find('[');
-                if (pos1 == 0) pos1 = line.find('['); else pos1 = std::string::npos;
-                size_t   pos2 = line.find(']');
-
-                if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1)
+        if (file.is_open())
+        {
+
+            char linearray[CONFIG_FILE_MAX_LINELENGHT];
+
+            ConfigFileSection* newsection = 0;
+
+            while (file.good() && !file.eof())
+            {
+                file.getline(linearray, CONFIG_FILE_MAX_LINELENGHT);
+
+                std::string line = std::string(linearray);
+
+                std::string temp = getStripped(line);
+                if (!isEmpty(temp) && !isComment(temp))
                 {
-                    // New section
-                    std::string comment = line.substr(pos2 + 1);
-                    if (isComment(comment))
-                        newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
-                    else
-                        newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1));
-                    this->sections_.insert(this->sections_.end(), newsection);
-                    continue;
-                }
-            }
-
-            if (newsection != 0)
-            {
-                if (isComment(line))
-                {
-                    // New comment
-                    newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryComment(removeTrailingWhitespaces(line)));
-                    continue;
-                }
-                else
-                {
-                    size_t pos1 = line.find('=');
-
-                    if (pos1 != std::string::npos && pos1 > 0)
+                    size_t   pos1 = temp.find('[');
+                    if (pos1 == 0) pos1 = line.find('['); else pos1 = std::string::npos;
+                    size_t   pos2 = line.find(']');
+
+                    if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1)
                     {
-                        // New entry
-                        size_t pos2 = line.find('[');
-                        size_t pos3 = line.find(']');
-                        size_t commentposition = getNextCommentPosition(line, pos1 + 1);
-                        while (isBetweenQuotes(line, commentposition))
-                        {
-                            commentposition = getNextCommentPosition(line, commentposition + 1);
-                        }
-                        std::string value = "", comment = "";
-                        if (commentposition == std::string::npos)
-                        {
-                            value = removeTrailingWhitespaces(line.substr(pos1 + 1));
-                        }
+                        // New section
+                        std::string comment = line.substr(pos2 + 1);
+                        if (isComment(comment))
+                            newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
                         else
-                        {
-                            value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));
-                            comment = removeTrailingWhitespaces(line.substr(commentposition));
-                        }
-
-                        if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1)
-                        {
-                            // There might be an array index
-                            unsigned int index = 0;
-                            if (ConvertValue(&index, line.substr(pos2 + 1, pos3 - pos2 - 1)))
-                            {
-                                // New array
-                                std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
-                                (*it)->setValue(value);
-                                (*it)->setComment(comment);
-                                continue;
-                            }
-                        }
-
-                        // New value
-                        newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryValue(getStripped(line.substr(0, pos1)), value, false, comment));
+                            newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1));
+                        this->sections_.insert(this->sections_.end(), newsection);
                         continue;
                     }
                 }
-            }
-        }
-
-        file.close();
-
-        COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
-
-        // Save the file in case something changed (like stripped whitespaces)
-        this->save();
-
-        // Update all ConfigValueContainers
-        this->updateConfigValues();
+
+                if (newsection != 0)
+                {
+                    if (isComment(line))
+                    {
+                        // New comment
+                        newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryComment(removeTrailingWhitespaces(line)));
+                        continue;
+                    }
+                    else
+                    {
+                        size_t pos1 = line.find('=');
+
+                        if (pos1 != std::string::npos && pos1 > 0)
+                        {
+                            // New entry
+                            size_t pos2 = line.find('[');
+                            size_t pos3 = line.find(']');
+                            size_t commentposition = getNextCommentPosition(line, pos1 + 1);
+                            while (isBetweenQuotes(line, commentposition))
+                            {
+                                commentposition = getNextCommentPosition(line, commentposition + 1);
+                            }
+                            std::string value = "", comment = "";
+                            if (commentposition == std::string::npos)
+                            {
+                                value = removeTrailingWhitespaces(line.substr(pos1 + 1));
+                            }
+                            else
+                            {
+                                value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));
+                                comment = removeTrailingWhitespaces(line.substr(commentposition));
+                            }
+
+                            if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1)
+                            {
+                                // There might be an array index
+                                unsigned int index = 0;
+                                if (ConvertValue(&index, line.substr(pos2 + 1, pos3 - pos2 - 1)))
+                                {
+                                    // New array
+                                    std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
+                                    (*it)->setValue(value);
+                                    (*it)->setComment(comment);
+                                    continue;
+                                }
+                            }
+
+                            // New value
+                            newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryValue(getStripped(line.substr(0, pos1)), value, false, comment));
+                            continue;
+                        }
+                    }
+                }
+            }
+
+            file.close();
+
+            COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
+
+            // Save the file in case something changed (like stripped whitespaces)
+            this->save();
+
+            // Update all ConfigValueContainers
+            this->updateConfigValues();
+        } // end file.is_open()
     }
 
     void ConfigFile::save() const
     {
-        boost::filesystem::path filepath(Core::getConfigPath() + "/" + this->filename_);
+        boost::filesystem::path filepath(Core::getConfigPath());
+        filepath /= this->filename_;
 
         std::ofstream file;
Index: code/branches/buildsystem3/src/core/Core.cc
===================================================================
--- code/branches/buildsystem3/src/core/Core.cc	(revision 2688)
+++ code/branches/buildsystem3/src/core/Core.cc	(revision 2690)
@@ -34,4 +34,8 @@
 #include "Core.h"
 #include <cassert>
+#include <fstream>
+#include <boost/filesystem.hpp>
+
+#include "util/Exception.h"
 #include "Language.h"
 #include "CoreIncludes.h"
@@ -51,4 +55,5 @@
     std::string Core::configPath_s(ORXONOX_CONFIG_INSTALL_PATH); // from OrxonoxConfig.h
     std::string Core::logPath_s   (ORXONOX_LOG_INSTALL_PATH);    // from OrxonoxConfig.h
+    std::string Core::mediaPath_s (ORXONOX_MEDIA_INSTALL_PATH);  // from OrxonoxConfig.h
 
     Core* Core::singletonRef_s = 0;
@@ -119,5 +124,5 @@
             defaultMediaPath = ORXONOX_MEDIA_DEV_PATH;
 
-        SetConfigValue(mediaPath_, defaultMediaPath)
+        SetConfigValue(mediaPath_s, defaultMediaPath)
             .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged);
 
@@ -157,12 +162,12 @@
     void Core::mediaPathChanged()
     {
-        if (mediaPath_ != "" && mediaPath_[mediaPath_.size() - 1] != '/')
-        {
-            ModifyConfigValue(mediaPath_, set, mediaPath_ + "/");
-        }
-
-        if (mediaPath_ == "")
-        {
-            ModifyConfigValue(mediaPath_, set, "/");
+        if (mediaPath_s != "" && mediaPath_s[mediaPath_s.size() - 1] != '/')
+        {
+            ModifyConfigValue(mediaPath_s, set, mediaPath_s + "/");
+        }
+
+        if (mediaPath_s == "")
+        {
+            ModifyConfigValue(mediaPath_s, set, "/");
             COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
         }
@@ -245,9 +250,9 @@
         if (*path.end() != '/' && *path.end() != '\\')
         {
-            ModifyConfigValue(mediaPath_, tset, path + "/");
+            ModifyConfigValue(mediaPath_s, tset, path + "/");
         }
         else
         {
-            ModifyConfigValue(mediaPath_, tset, path);
+            ModifyConfigValue(mediaPath_s, tset, path);
         }
     }
@@ -264,12 +269,51 @@
     }
 
-    /*static*/ void Core::setDevBuild()
-    {
-        // Be careful never to call this function before main()!
-
-        Core::isDevBuild_s = true;
-        // Constants taken from OrxonoxConfig.h
-        Core::configPath_s = ORXONOX_CONFIG_DEV_PATH;
-        Core::logPath_s    = ORXONOX_LOG_DEV_PATH;
+    /**
+    @brief
+        Checks for "orxonox_dev_build.keep_me" in the working diretory.
+        If found it means that this is not an installed run, hence we
+        don't write the logs and config files to ~/.orxonox
+    */
+    /*static*/ void Core::checkDevBuild()
+    {
+        std::ifstream probe;
+        probe.open("orxonox_dev_build.keep_me");
+        if (probe)
+        {
+            Core::isDevBuild_s = true;
+            // Constants are taken from OrxonoxConfig.h
+            Core::configPath_s = ORXONOX_CONFIG_DEV_PATH;
+            Core::logPath_s    = ORXONOX_LOG_DEV_PATH;
+            Core::mediaPath_s  = ORXONOX_MEDIA_DEV_PATH;
+            probe.close();
+        }
+    }
+
+    /*
+    @brief
+        Checks for the log and the config directory and creates them
+        if necessary. Otherwise me might have problems opening those files.
+    */
+    /*static*/ void Core::createDirectories()
+    {
+        std::vector<std::pair<boost::filesystem::path, std::string> > directories;
+        directories.push_back(std::pair<boost::filesystem::path, std::string>
+            (boost::filesystem::path(Core::configPath_s), "config"));
+        directories.push_back(std::pair<boost::filesystem::path, std::string>
+            (boost::filesystem::path(Core::logPath_s),    "log"));
+
+        for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin();
+            it != directories.end(); ++it)
+        {
+            if (boost::filesystem::exists(it->first) && !boost::filesystem::is_directory(it->first))
+            {
+                ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
+                                         Please remove " + it->first.file_string());
+            }
+            if (boost::filesystem::create_directory(it->first)) // function may not return true at all (bug?)
+            {
+                COUT(4) << "Created " << it->second << " directory" << std::endl;
+            }
+        }
     }
 }
Index: code/branches/buildsystem3/src/core/Core.h
===================================================================
--- code/branches/buildsystem3/src/core/Core.h	(revision 2688)
+++ code/branches/buildsystem3/src/core/Core.h	(revision 2690)
@@ -68,8 +68,7 @@
             static bool isDevBuild() { return Core::isDevBuild_s; }
 
-            static const std::string& getMediaPath()
-            { assert(singletonRef_s); return singletonRef_s->mediaPath_; }
             static void tsetMediaPath(const std::string& path)
             { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
+            static const std::string& getMediaPath()  { return mediaPath_s; }
             static const std::string& getConfigPath() { return configPath_s; }
             static const std::string& getLogPath()    { return logPath_s; }
@@ -96,5 +95,6 @@
             void _tsetMediaPath(const std::string& path);
 
-            static void setDevBuild();
+            static void createDirectories();
+            static void checkDevBuild();
 
             int softDebugLevel_;                            //!< The debug level
@@ -104,5 +104,4 @@
             std::string language_;                          //!< The language
             bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
-            std::string mediaPath_;                         //!< Path to the data/media file folder
 
             static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
@@ -115,4 +114,5 @@
             static std::string configPath_s;                //!< Path to the config file folder
             static std::string logPath_s;                   //!< Path to the log file folder
+            static std::string mediaPath_s;                 //!< Path to the data/media file folder
 
             static Core* singletonRef_s;
Index: code/branches/buildsystem3/src/core/input/KeyBinder.cc
===================================================================
--- code/branches/buildsystem3/src/core/input/KeyBinder.cc	(revision 2688)
+++ code/branches/buildsystem3/src/core/input/KeyBinder.cc	(revision 2690)
@@ -248,5 +248,5 @@
         True if loading succeeded.
     */
-    void KeyBinder::loadBindings(const std::string& filename, const std::string& defaultFilename)
+    void KeyBinder::loadBindings(const std::string& filename)
     {
         COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
@@ -255,17 +255,4 @@
             return;
 
-        boost::filesystem::path folder(Core::getConfigPath());
-        boost::filesystem::path filepath(folder/filename);
-
-        // get bindings from default file if filename doesn't exist.
-        std::ifstream infile;
-        infile.open(filepath.file_string().c_str());
-        if (!infile)
-        {
-            ConfigFileManager::getInstance().setFilename(this->configFile_, defaultFilename);
-            ConfigFileManager::getInstance().saveAs(this->configFile_, filename);
-        }
-        else
-            infile.close();
         ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
 
Index: code/branches/buildsystem3/src/core/input/KeyBinder.h
===================================================================
--- code/branches/buildsystem3/src/core/input/KeyBinder.h	(revision 2688)
+++ code/branches/buildsystem3/src/core/input/KeyBinder.h	(revision 2690)
@@ -61,5 +61,5 @@
         virtual ~KeyBinder();
 
-        void loadBindings(const std::string& filename, const std::string& defaultFilename);
+        void loadBindings(const std::string& filename);
         void clearBindings();
         bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
Index: code/branches/buildsystem3/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/buildsystem3/src/orxonox/CMakeLists.txt	(revision 2688)
+++ code/branches/buildsystem3/src/orxonox/CMakeLists.txt	(revision 2690)
@@ -39,13 +39,4 @@
 # Not using precompiled header files: Avoid dependencies
 INCLUDE_DIRECTORIES(pch/nopch)
-
-IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
-  # Get around displaying a few hundred lines of warning code
-  SET_SOURCE_FILES_PROPERTIES(
-    gamestates/GSGraphics.cc
-    gui/GUIManager.cc
-    PROPERTIES COMPILE_FLAGS "-Wno-sign-compare"
-  )
-ENDIF()
 
 ADD_EXECUTABLE(orxonox ${ORXONOX_FILES})
Index: code/branches/buildsystem3/src/orxonox/Main.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/Main.cc	(revision 2688)
+++ code/branches/buildsystem3/src/orxonox/Main.cc	(revision 2690)
@@ -37,5 +37,4 @@
 #include <exception>
 #include <cassert>
-#include <fstream>
 
 #include "OrxonoxConfig.h"
@@ -95,11 +94,8 @@
     // First, determine whether we have an installed or a binary dir run
     // The latter occurs when simply running from the build directory
-    std::ifstream probe;
-    probe.open("orxonox_dev_build.keep_me");
-    if (probe)
-    {
-        Core::setDevBuild();
-        probe.close();
-    }
+    Core::checkDevBuild();
+
+    // Make sure the directories we write in exist or else make them
+    Core::createDirectories();
 
     // create a signal handler (only active for linux)
Index: code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc	(revision 2688)
+++ code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc	(revision 2690)
@@ -107,6 +107,4 @@
         SetConfigValue(ogreLogLevelCritical_, 2)
             .description("Corresponding orxonox debug level for ogre Critical");
-        SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini")
-            .description("Filename of default master keybindings.");
     }
 
@@ -148,5 +146,5 @@
         // Configure master input state with a KeyBinder
         masterKeyBinder_ = new KeyBinder();
-        masterKeyBinder_->loadBindings("masterKeybindings.ini", defaultMasterKeybindings_);
+        masterKeyBinder_->loadBindings("masterKeybindings.ini");
         inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
 
Index: code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.h	(revision 2688)
+++ code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.h	(revision 2690)
@@ -105,5 +105,4 @@
         int                   ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
         int                   ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
-        std::string           defaultMasterKeybindings_; //!< Filename of default master keybindings.
 
         // console commands
Index: code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc	(revision 2688)
+++ code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc	(revision 2690)
@@ -75,6 +75,4 @@
     {
         SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
-        SetConfigValue(defaultKeybindings_, "def_keybindings.ini")
-            .description("Filename of default keybindings.");
     }
 
@@ -85,5 +83,5 @@
             inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
             keyBinder_ = new KeyBinder();
-            keyBinder_->loadBindings("keybindings.ini", defaultKeybindings_);
+            keyBinder_->loadBindings("keybindings.ini");
             inputState_->setHandler(keyBinder_);
 
Index: code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.h	(revision 2688)
+++ code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.h	(revision 2690)
@@ -66,6 +66,4 @@
         //##### ConfigValues #####
         std::string           keyDetectorCallbackCode_;
-        //! Filename of default keybindings.
-        std::string           defaultKeybindings_;
 
         // console commands
