2.0 ready
diff --git a/wally/config.py b/wally/config.py
index c760509..abc6bb0 100644
--- a/wally/config.py
+++ b/wally/config.py
@@ -13,8 +13,6 @@
 
 import pretty_yaml
 
-cfg_dict = {}
-
 
 class NoData(object):
     @classmethod
@@ -23,6 +21,10 @@
 
 
 class Config(object):
+    def __init__(self, val=None):
+        if val is not None:
+            self.update(val)
+
     def get(self, name, defval=None):
         obj = self.__dict__
         for cname in name.split("."):
@@ -32,14 +34,8 @@
             return defval
         return obj
 
-
-cfg = Config()
-cfg.__dict__ = cfg_dict
-
-
-def mkdirs_if_unxists(path):
-    if not os.path.exists(path):
-        os.makedirs(path)
+    def update(self, val):
+        self.__dict__.update(val)
 
 
 def get_test_files(results_dir):
@@ -55,71 +51,80 @@
         log_file='log.txt',
         sensor_storage='sensor_storage',
         nodes_report_file='nodes.yaml',
-        results='results',
+        results_storage='results',
         hwinfo_directory='hwinfo',
         hwreport_fname='hwinfo.txt',
         raw_results='raw_results.yaml')
 
     res = dict((k, in_var_dir(v)) for k, v in res.items())
-    res['var_dir'] = results_dir
+    res['results_dir'] = results_dir
     return res
 
 
-def load_config(file_name, explicit_folder=None):
-    cfg_dict.update(yaml.load(open(file_name).read()))
+def load_config(file_name):
+    file_name = os.path.abspath(file_name)
 
-    var_dir = cfg_dict.get('internal', {}).get('var_dir_root', '/tmp')
-    run_uuid = None
+    defaults = dict(
+        sensors_remote_path='/tmp/sensors',
+        testnode_log_root='/tmp/wally',
+        settings={}
+    )
 
-    if explicit_folder is None:
+    raw_cfg = yaml.load(open(file_name).read())
+    raw_cfg['config_folder'] = os.path.dirname(file_name)
+    if 'include' in raw_cfg:
+        default_path = os.path.join(raw_cfg['config_folder'],
+                                    raw_cfg.pop('include'))
+        default_cfg = yaml.load(open(default_path).read())
+
+        # TODO: Need more intelectual configs merge?
+        default_cfg.update(raw_cfg)
+        raw_cfg = default_cfg
+
+    cfg = Config(defaults)
+    cfg.update(raw_cfg)
+
+    results_storage = cfg.settings.get('results_storage', '/tmp')
+    results_storage = os.path.abspath(results_storage)
+
+    existing = file_name.startswith(results_storage)
+
+    if existing:
+        cfg.results_dir = os.path.dirname(file_name)
+        cfg.run_uuid = os.path.basename(cfg.results_dir)
+    else:
+        # genarate result folder name
         for i in range(10):
-            run_uuid = pet_generate(2, "_")
-            results_dir = os.path.join(var_dir, run_uuid)
-            if not os.path.exists(results_dir):
+            cfg.run_uuid = pet_generate(2, "_")
+            cfg.results_dir = os.path.join(results_storage,
+                                           cfg.run_uuid)
+            if not os.path.exists(cfg.results_dir):
                 break
         else:
-            run_uuid = str(uuid.uuid4())
-            results_dir = os.path.join(var_dir, run_uuid)
-        cfg_dict['run_uuid'] = run_uuid.replace('_', '-')
-    else:
-        if not os.path.isdir(explicit_folder):
-            ex2 = os.path.join(var_dir, explicit_folder)
-            if os.path.isdir(ex2):
-                explicit_folder = ex2
-            else:
-                raise RuntimeError("No such directory " + explicit_folder)
+            cfg.run_uuid = str(uuid.uuid4())
+            cfg.results_dir = os.path.join(results_storage,
+                                           cfg.run_uuid)
 
-        results_dir = explicit_folder
+    # setup all files paths
+    cfg.update(get_test_files(cfg.results_dir))
 
-    cfg_dict.update(get_test_files(results_dir))
-    mkdirs_if_unxists(cfg_dict['var_dir'])
+    if existing:
+        cfg.update(load_run_params(cfg.run_params_file))
 
-    if explicit_folder is not None:
-        cfg_dict.update(load_run_params(cfg_dict['run_params_file']))
-        run_uuid = cfg_dict['run_uuid']
-
-    mkdirs_if_unxists(cfg_dict['sensor_storage'])
-
-    if 'sensors_remote_path' not in cfg_dict:
-        cfg_dict['sensors_remote_path'] = '/tmp/sensors'
-
-    testnode_log_root = cfg_dict.get('testnode_log_root', '/var/wally')
+    testnode_log_root = cfg.get('testnode_log_root')
     testnode_log_dir = os.path.join(testnode_log_root, "{0}/{{name}}")
-    cfg_dict['default_test_local_folder'] = \
-        testnode_log_dir.format(cfg_dict['run_uuid'])
+    cfg.default_test_local_folder = testnode_log_dir.format(cfg.run_uuid)
 
-    mkdirs_if_unxists(cfg_dict['results'])
-    mkdirs_if_unxists(cfg_dict['hwinfo_directory'])
-
-    return results_dir
+    return cfg
 
 
-def save_run_params():
+def save_run_params(cfg):
     params = {
-        'comment': cfg_dict['comment'],
-        'run_uuid': cfg_dict['run_uuid']
+        'comment': cfg.comment,
+        'run_uuid': cfg.run_uuid
     }
-    with open(cfg_dict['run_params_file'], 'w') as fd:
+
+    with open(cfg.run_params_file, 'w') as fd:
         fd.write(pretty_yaml.dumps(params))