diff --git a/configuration.module b/configuration.module
index b68ed7f..4ee4aee 100644
--- a/configuration.module
+++ b/configuration.module
@@ -172,8 +172,9 @@ 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::checkNewConfigurations($list);
   }
+  $class::importConfigurations($components);
   drupal_flush_all_caches();
 }
 
diff --git a/lib/Drupal/configuration/Config/Configuration.php b/lib/Drupal/configuration/Config/Configuration.php
index ddc3bb1..c3997ca 100644
--- a/lib/Drupal/configuration/Config/Configuration.php
+++ b/lib/Drupal/configuration/Config/Configuration.php
@@ -13,28 +13,23 @@ class Configuration {
    * The component of this configuration, example, content_type, field, etc.
    */
   static protected $component = '';
-
   /**
    * The identifier that identifies to the component, usually the machine name.
    */
   protected $identifier;
-
   /**
    * The required modules to load this configuration.
    */
   protected $required_modules = array();
-
   /**
    * An array of configuration objects required to use this configuration.
    */
   protected $dependencies = array();
-
   /**
    * An array of configuration objects that are parts of this configurations
    * but are not required to use this configuration.
    */
   protected $optional_configurations = array();
-
   /**
    * The status of this configuration.
    *
@@ -45,18 +40,15 @@ class Configuration {
    * CONFIGURATION_IN_SYNC
    */
   protected $status;
-
   /**
    * The data of this configuration.
    */
   protected $data;
-
   /**
    * An array of keys names to export. If the array is empty,
    * all the keys of the configuration will be exported.
    */
   protected $keys_to_export = array();
-
   /**
    * An object to save and load the data from a persistent medium.
    */
@@ -110,58 +102,108 @@ class Configuration {
   }
 
   /**
-   * Returns a that manages the configurations for the given component.
+   * Returns a handler that manages the configurations for the given component.
    */
   public static function getConfigurationHandler($component) {
     $handlers = static::getAllConfigurationHandlers();
-    return  '\\' . $handlers[$component]['namespace'] . '\\' . $handlers[$component]['handler'];
+    return '\\' . $handlers[$component]['namespace'] . '\\' . $handlers[$component]['handler'];
   }
 
   /**
-   * Loads all the non imported configurations.
+   * Loads configurations into staging setting status as "needs rebuild".
    */
-  public static function importAllNewConfigurations($list = array()) {
+  public static function importConfigurations($component_stack = array()) {
+    foreach ($component_stack as $component) {
+      list($component_name, $identifier) = explode('.', $component, 2);
+      $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 Set state to "needs rebuild" or something like that.
+      unset($handler_instance);
+    }
+  }
 
+  /**
+   * Build an array of components to import based on the dependencies.
+   */
+  public static function checkNewConfigurations($list = array()) {
+    $real_dependencies = &drupal_static(__FUNCTION__);
+    if (!isset($real_dependencies)) {
+      $real_dependencies = array();
+    }
     $import_all = empty($list);
 
     $path = drupal_realpath('config://');
     $storage_system = static::getStorageSystem();
     $ext = $storage_system::$file_extension;
-    $look_for = '/' . static::$component . '\..*' . $ext . '$/';
+    $look_for = '/\A' . static::$component . '\..*' . $ext . '$/';
 
     $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();
+      $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])) {
+          $config = new static($identifier);
+          $config->setDependencies($dependencies);
+          $config->getPriorizatedDependencies($real_dependencies);
+          unset($storage);
+          unset($config);
+        }
+      }
+    }
+    return $real_dependencies;
+  }
 
-        unset($storage);
-        unset($config);
+  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();
       }
-      // @TODO Build the import order based on the dependencies.
     }
+    else {
+      foreach ($this->dependencies as $dependency) {
+        list($dependency_component, $dependency_identifier) = explode('.', $dependency);
+        if (!in_array($dependency, $component_ordered_stack)) {
+          $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();
+      }
+    }
+    return $component_ordered_stack;
   }
 
   /**
@@ -181,9 +223,9 @@ class Configuration {
    */
   static public function defaultHook() {
     $configurations = db_select('configuration_staging', 'cs')
-                        ->fields('cs', array('identifier', 'data'))
-                        ->condition('component', static::$component)
-                        ->execute();
+            ->fields('cs', array('identifier', 'data'))
+            ->condition('component', static::$component)
+            ->execute();
     $return = array();
     foreach ($configurations as $configuration) {
       $return[$configuration->identifier] = unserialize($configuration->data);
@@ -196,9 +238,9 @@ class Configuration {
    */
   public function saveToStaging() {
     db_delete('configuration_staging')
-      ->condition('component', static::$component)
-      ->condition('identifier', $this->getIdentifier())
-      ->execute();
+        ->condition('component', static::$component)
+        ->condition('identifier', $this->getIdentifier())
+        ->execute();
 
     $fields = array(
       'component' => static::$component,
@@ -268,12 +310,12 @@ class Configuration {
 
     // Save the configuration into a file.
     $this->storage
-            ->setData($this->data)
-            ->setKeysToExport($this->getKeysToExport())
-            ->setDependencies($dependencies)
-            ->setOptionalConfigurations($optional_configurations)
-            ->setModules($this->required_modules)
-            ->save();
+        ->setData($this->data)
+        ->setKeysToExport($this->getKeysToExport())
+        ->setDependencies($dependencies)
+        ->setOptionalConfigurations($optional_configurations)
+        ->setModules($this->required_modules)
+        ->save();
 
     // Also, save the configuration in the database
     $this->saveToStaging();
@@ -531,10 +573,10 @@ class Configuration {
     foreach ($this->dependecies as $dependency) {
       // First, look for the dependency in the staging table.
       $exists = db_select('configuration_staging', 'cs')
-                        ->fields('cs', array('identifier'))
-                        ->condition('component', static::$component)
-                        ->condition('identifier', $this->getIdentifier())
-                        ->fetchField();
+              ->fields('cs', array('identifier'))
+              ->condition('component', static::$component)
+              ->condition('identifier', $this->getIdentifier())
+              ->fetchField();
 
       if (!$exists) {
         // If not exists in the database, look into the config:// directory.
@@ -546,4 +588,5 @@ class Configuration {
       }
     }
   }
+
 }
diff --git a/lib/Drupal/configuration/Config/MenuConfiguration.php b/lib/Drupal/configuration/Config/MenuConfiguration.php
index dad4952..db98833 100644
--- a/lib/Drupal/configuration/Config/MenuConfiguration.php
+++ b/lib/Drupal/configuration/Config/MenuConfiguration.php
@@ -17,14 +17,14 @@ class MenuConfiguration extends Configuration {
     $this->data = menu_load($this->getIdentifier());
     return $this;
   }
-  
+
   static public function rebuildHook() {
     $menus = db_select('configuration_staging', 'c')
-                ->fields('c', array('data'))
-                ->condition('component', self::$component)
-                ->execute()
-                ->fetchCol();
-    
+            ->fields('c', array('data'))
+            ->condition('component', self::$component)
+            ->execute()
+            ->fetchCol();
+
     if ($menus) {
       //$existing = $this->getAllIdentifiers();
       foreach ($menus as $serialized_menu) {
diff --git a/lib/Drupal/configuration/Config/MenuLinkConfiguration.php b/lib/Drupal/configuration/Config/MenuLinkConfiguration.php
index 0c1ec88..7a5aa80 100644
--- a/lib/Drupal/configuration/Config/MenuLinkConfiguration.php
+++ b/lib/Drupal/configuration/Config/MenuLinkConfiguration.php
@@ -18,14 +18,14 @@ class MenuLinkConfiguration extends Configuration {
     $this->data = menu_link_load($mlid);
     return $this;
   }
-  
+
   static public function rebuildHook() {
     $menulinks = db_select('configuration_staging', 'c')
-                ->fields('c', array('data'))
-                ->condition('component', self::$component)
-                ->execute()
-                ->fetchCol();
-    
+            ->fields('c', array('data'))
+            ->condition('component', self::$component)
+            ->execute()
+            ->fetchCol();
+
     if ($menulinks) {
       //$existing = $this->getAllIdentifiers();
       foreach ($menulinks as $serialized_menulink) {
