diff --git a/configuration.module b/configuration.module
index b68ed7f..4de4afc 100644
--- a/configuration.module
+++ b/configuration.module
@@ -172,8 +172,10 @@ function configuration_import_new_configurations($list = array()) {
   $handlers = configurarion_get_handlers();
   foreach ($handlers as $handler) {
     $class = '\\' . $handler['namespace'] . '\\' . $handler['handler'];
-    $class::importAllNewConfigurations($list);
+    $components=$class::checkAllNewConfigurations($list);
   }
+  $class::importAllNewConfigurations($components);
+  // @todo stop using the clear cache hook to rebuild components.
   drupal_flush_all_caches();
 }
 
diff --git a/lib/Drupal/configuration/Config/Configuration.php b/lib/Drupal/configuration/Config/Configuration.php
index ddc3bb1..9ba3e1c 100644
--- a/lib/Drupal/configuration/Config/Configuration.php
+++ b/lib/Drupal/configuration/Config/Configuration.php
@@ -118,10 +118,37 @@ class Configuration {
   }
 
   /**
-   * Loads all the non imported configurations.
-   */
-  public static function importAllNewConfigurations($list = array()) {
+  * Loads all the non imported configurations.
+  */
+  public static function importAllNewConfigurations($component_stack = array()) {
+    foreach ($component_stack as $component) {
+        list($component_name, $identifier) = explode('.', $component);
+        $handler = Configuration::getConfigurationHandler($component_name);
+        $handler_instance = new $handler($identifier);
+        $handler_instance->storage->load();
+        $data = $handler_instance->storage->getData();
+        $dependencies = $handler_instance->storage->getDependencies();
+        $modules = $handler_instance->storage->getModules();
+        $handler_instance
+            ->setData($data)
+            ->setDependencies($dependencies)
+            ->setModules($modules)
+            ->saveToStaging();
+        // @todo Change this method or provide a new one to complete the import
+        // process.
+        //$handler_instance::rebuildHook();
+        unset($handler_instance);
+    }
+  }
 
+  /**
+   * Build an array of components to import based on the dependencies.
+   */
+  public static function checkAllNewConfigurations($list = array()) {
+    $real_dependencies = &drupal_static(__FUNCTION__);
+    if (!isset($real_dependencies)) {
+      $real_dependencies = array();
+    }
     $import_all = empty($list);
 
     $path = drupal_realpath('config://');
@@ -132,36 +159,64 @@ class Configuration {
     $files = file_scan_directory($path, $look_for);
 
     foreach ($files as $file) {
-      $storage = static::getStorageInstance();
-
-      // Avoid namespace issues.
-      $file_array = (array)$file;
-      $filename = $file_array['name'];
-      $storage
-        ->setFileName($filename)
-        ->load();
-
-      $data = $storage->getData();
-      $dependencies = $storage->getDependencies();
-      $modules = $storage->getModules();
-
-      // Obtain the identifier of the configuration based on the file name.
-      $identifier = substr($file_array['name'], strpos($file_array['name'], '.') + 1);
-
-      if ($import_all || !empty($list[static::$component . '.' . $identifier])) {
-        // Create a configuration object, and save it into the staging area.
-        $config = new static($identifier);
-        $config
-          ->setData($data)
-          ->setDependencies($dependencies)
-          ->setModules($modules)
-          ->saveToStaging();
-
-        unset($storage);
-        unset($config);
+      $filename = $file->name;
+      if (!in_array($filename, $real_dependencies)) {
+        $storage = static::getStorageInstance();
+        // Avoid namespace issues.
+        $file_array = (array)$file;
+        $filename = $file_array['name'];
+        $storage
+          ->setFileName($filename)
+          ->load();
+  
+        $data = $storage->getData();
+        $dependencies = $storage->getDependencies();
+        $modules = $storage->getModules();
+        
+        // Obtain the identifier of the configuration based on the file name.
+        $identifier = substr($file_array['name'], strpos($file_array['name'], '.') + 1);
+  
+        if ($import_all || !empty($list[static::$component . '.' . $identifier])) {
+          // Create a configuration object, and save it into the staging area.
+          $config = new static($identifier);
+          $config
+            ->setData($data)
+            ->setDependencies($dependencies)
+            ->setModules($modules);
+          $config->getPriorizatedDependencies($real_dependencies);
+          unset($storage);
+          unset($config);
+        }
+      }
+
+    }
+    return $real_dependencies;
+  }
+  
+  public function getPriorizatedDependencies(&$component_ordered_stack = array()) {
+    if(empty($this->dependencies)) {
+      $id = $this->getUniqueId();
+      if (!in_array($id, $component_ordered_stack)) {
+        $component_ordered_stack[] = $this->getUniqueId();
+      }
+    }
+    else {
+      foreach ($this->dependencies as $dependency) {
+        list($dependency_component, $dependency_identifier) = explode('.', $dependency);
+        $handler = Configuration::getConfigurationHandler($dependency_component);
+        $dependency_config = new $handler($dependency_identifier);
+        $dependency_config->storage->load();
+        $dependency_config->setDependencies($dependency_config->storage
+        ->getDependencies());
+        $dependency_config->getPriorizatedDependencies($component_ordered_stack);
+        unset($dependency_config);
+      }
+      $id = $this->getUniqueId();
+      if (!in_array($id, $component_ordered_stack)) {
+        $component_ordered_stack[] = $this->getUniqueId();
       }
-      // @TODO Build the import order based on the dependencies.
     }
+    return $component_ordered_stack;
   }
 
   /**
@@ -515,7 +570,7 @@ class Configuration {
    */
   public static function alterDependencies(Configuration $config, &$stack) {
     // Override
-  }
+  }  
 
   /**
    * Returns TRUE if all the dependencies of this configurations are met.
