diff --git includes/rules.core.inc includes/rules.core.inc
index 4962f8b..a6ca1d2 100644
--- includes/rules.core.inc
+++ includes/rules.core.inc
@@ -969,20 +969,27 @@ abstract class RulesPlugin extends RulesExtendable {
    * @see rules_import()
    */
   public function export($prefix = '',$php = FALSE) {
-    $export[strtoupper($this->plugin())] = $this->exportSettings();
+    $export = $this->exportToArray();
     return $this->isRoot() ? $this->returnExport($export, $prefix, $php) : $export;
   }
 
+  protected function exportToArray() {
+    $export[strtoupper($this->plugin())] = $this->exportSettings();
+    return $export;
+  }
+
   protected function exportSettings() {
     $export = array();
-    foreach ($this->pluginParameterInfo() as $name => $info) {
-      if (($return = $this->exportParameterSetting($name, $info)) !== NULL) {
-        $export['USING'][$name] = $return;
+    if (!$this->isRoot()) {
+      foreach ($this->pluginParameterInfo() as $name => $info) {
+        if (($return = $this->exportParameterSetting($name, $info)) !== NULL) {
+          $export['USING'][$name] = $return;
+        }
       }
-    }
-    foreach ($this->providesVariables() as $name => $info) {
-      if (!empty($info['source name'])) {
-        $export['PROVIDE'][$info['source name']][$name] = $info['label'];
+      foreach ($this->providesVariables() as $name => $info) {
+        if (!empty($info['source name'])) {
+          $export['PROVIDE'][$info['source name']][$name] = $info['label'];
+        }
       }
     }
     return $export;
@@ -1199,14 +1206,13 @@ abstract class RulesAbstractPlugin extends RulesPlugin {
     $this->importSettings($export);
   }
 
-  public function export($prefix = '',$php = FALSE) {
+  protected function exportToArray() {
     $export = $this->exportSettings();
     if (!$this->providesVariables()) {
       // Abbreviate the export making "USING" implicit.
       $export = isset($export['USING']) ? $export['USING'] : array();
     }
-    $export = array($this->elementName => $export);
-    return $this->isRoot() ? $this->returnExport($export, $prefix, $php) : $export;
+    return array($this->elementName => $export);
   }
 
   public function dependencies() {
@@ -1790,20 +1796,33 @@ abstract class RulesContainerPlugin extends RulesPlugin implements IteratorAggre
     return $export;
   }
 
-  public function export($prefix = '',$php = FALSE) {
+  protected function exportToArray() {
     $export = array();
     if (isset($this->info['variables'])) {
       $export['USES VARIABLES'] = $this->info['variables'];
     }
-    $export += $this->exportChildren();
-    return $this->isRoot() ? $this->returnExport($export, $prefix, $php) : $export;
+    if ($settings_export = $this->exportSettings()) {
+      $export[strtoupper($this->plugin())] = $settings_export + $this->exportChildren();
+    }
+    else {
+      $export += $this->exportChildren();
+    }
+    return $export;
   }
 
   public function import(array $export) {
     if (isset($export['USES VARIABLES'])) {
       $this->info['variables'] = $export['USES VARIABLES'];
     }
-    $this->importChildren($export);
+    $key = strtoupper($this->plugin());
+    if (isset($export[$key]) && (isset($export[$key]['USING']) || isset($export[$key]['PROVIDE']))) {
+      $export = $export[$key];
+      $this->importSettings($export);
+      $this->importChildren($export);
+    }
+    else {
+      $this->importChildren($export);
+    }
   }
 
   protected function importChildren($export, $key = NULL) {
@@ -1874,6 +1893,21 @@ abstract class RulesActionContainer extends RulesContainerPlugin implements Rule
     $this->info += array('provides' => array());
     return $this->info['provides'];
   }
+
+  protected function exportToArray() {
+    $export = parent::exportToArray();
+    if (isset($this->info['provides'])) {
+      $export['PROVIDES VARIABLES'] = $this->info['provides'];
+    }
+    return $export;
+  }
+
+  public function import(array $export) {
+    parent::import($export);
+    if (isset($export['PROVIDES VARIABLES'])) {
+      $this->info['provides'] = $export['PROVIDES VARIABLES'];
+    }
+  }
 }
 
 /**
@@ -1931,7 +1965,6 @@ abstract class RulesConditionContainer extends RulesContainerPlugin implements R
     return $export;
   }
 
-
   protected function importChildren($export, $key = NULL) {
     $key = isset($key) ? $key : strtoupper($this->plugin());
     // Care for negated elements.
@@ -2150,6 +2183,10 @@ function _rules_import_get_plugin($key, $default = 'action') {
       }
     }
   }
+  // Cut of any leading NOT from the key.
+  if (strpos($key, 'NOT ') === 0) {
+    $key = substr($key, 4);
+  }
   if (isset($map[$key])) {
     return $map[$key];
   }
diff --git includes/rules.plugins.inc includes/rules.plugins.inc
index 4822cba..daa6475 100644
--- includes/rules.plugins.inc
+++ includes/rules.plugins.inc
@@ -103,12 +103,11 @@ class RulesCondition extends RulesAbstractPlugin implements RulesConditionInterf
     return $result;
   }
 
-  public function export($prefix = '',$php = FALSE) {
+  protected function exportToArray() {
     $not = $this->negate ? 'NOT ' : '';
     $export = $this->exportSettings();
     // Abbreviate the export making "USING" implicit.
-    $export = array($not . $this->elementName => isset($export['USING']) ? $export['USING'] : array());
-    return $this->isRoot() ? $this->returnExport($export, $prefix, $php) : $export;
+    return array($not . $this->elementName => isset($export['USING']) ? $export['USING'] : array());
   }
 
   public function import(array $export) {
@@ -260,8 +259,8 @@ class Rule extends RulesActionContainer {
     return $vars;
   }
 
-  public function export($prefix = '',$php = FALSE) {
-    $export = parent::export($prefix, $php);
+  protected function exportToArray() {
+    $export = parent::exportToArray();
     if (!$this->isRoot()) {
       $export['LABEL'] = $this->label;
     }
@@ -312,12 +311,14 @@ class Rule extends RulesActionContainer {
   }
 
   /**
-   * Overriden to expose the variables of all actions.
+   * Overriden to expose the variables of all actions for embedded rules.
    */
   public function providesVariables() {
     $provides = parent::providesVariables();
-    foreach ($this->actions() as $action) {
-      $provides += $action->providesVariables();
+    if (!$this->isRoot()) {
+      foreach ($this->actions() as $action) {
+        $provides += $action->providesVariables();
+      }
     }
     return $provides;
   }
@@ -587,11 +588,11 @@ class RulesLoop extends RulesActionContainer {
     return !empty($this->label) ? $this->label : t('Loop');
   }
 
-  protected function exportChildren($key = 'LOOP OVER') {
+  protected function exportChildren($key = 'DO') {
     return parent::exportChildren($key);
   }
 
-  protected function importChildren($export, $key = 'LOOP OVER') {
+  protected function importChildren($export, $key = 'DO') {
     parent::importChildren($export, $key);
   }
 }
diff --git rules.module rules.module
index 652e559..920faab 100644
--- rules.module
+++ rules.module
@@ -83,12 +83,13 @@ function rules_condition($name, $settings = array()) {
  *      variable upon execution. As a consequence no value will be set
  *      initially, but the "Set data value" action may be used to do so. This is
  *      in particular useful for defining variables which can be provided to the
- *      caller (see e.g. rules_action_set()) but need not be passed in as
- *      parameter.
+ *      caller (see $provides argument) but need not be passed in as parameter.
+ * @param $provides
+ *   An array of the names of variables, which should be provided to the caller.
  * @return Rule
  */
-function rule($variables = NULL) {
-  return rules_plugin_factory('rule', $variables);
+function rule($variables = NULL, $provides = array()) {
+  return rules_plugin_factory('rule', $variables, $provides);
 }
 
 /**
@@ -489,7 +490,6 @@ function rules_rules_plugin_info() {
           'class' => 'RulesLoopUI',
         ),
       ),
-      'import keys' => array('LOOP OVER'),
     ),
     'reaction rule' => array(
       'class' => 'RulesReactionRule',
diff --git tests/rules.test tests/rules.test
index b36eff5..7451613 100644
--- tests/rules.test
+++ tests/rules.test
@@ -629,6 +629,30 @@ class RulesTestCase extends DrupalWebTestCase {
     $set->execute($node);
     $this->assertEqual($node->title, 'test', 'Imported rule set has been executed.');
     RulesLog::logger()->checkLog();
+
+    // Try import / export for a rule component providing a variable.
+    $rule = rule(array(
+      'number' => array(
+        'type' => 'integer',
+        'label' => 'Number',
+        'parameter' => FALSE,
+      )), array('number'));
+    $rule->action('data_set', array('data:select' => 'number', 'value' => 3));
+    $rule->name = 'rules_test_provides';
+
+    $export = '{ "rules_test_provides" : {
+    "PLUGIN" : "rule",
+    "REQUIRES" : [ "rules" ],
+    "USES VARIABLES" : { "number" : { "type" : "integer", "label" : "Number", "parameter" : false } },
+    "DO" : [ { "data_set" : { "data" : [ "number" ], "value" : 3 } } ],
+    "PROVIDES VARIABLES" : [ "number" ]
+  }
+}';
+    $this->assertEqual($export, $rule->export(), 'Rule 2 has been exported correctly.');
+    $imported_rule = rules_import($rule->export());
+
+    $this->assertTrue(!empty($imported_rule) && $imported_rule->integrityCheck(), 'Rule 2 has been imported.');
+    $this->assertEqual($export, $imported_rule->export(), 'Export of imported rule 2 equals original export.');
   }
 
   /**
diff --git tests/rules_test.rules_defaults.inc tests/rules_test.rules_defaults.inc
index 80fc1b5..010167d 100644
--- tests/rules_test.rules_defaults.inc
+++ tests/rules_test.rules_defaults.inc
@@ -48,7 +48,8 @@ function _rules_export_get_test_export() {
               "node" : [ "comment:node" ],
               "type" : { "value" : { "page" : "page" } }
             }
-          }
+          },
+          { "NOT AND" : [ { "OR" : [] } ] }
         ]
       }
     ],
@@ -68,6 +69,11 @@ function _rules_export_get_test_export() {
           "message" : "fein, [comment:node:title] has been made sticky!",
           "type" : [ "level" ]
         }
+      },
+      { "LOOP" : {
+          "USING" : { "list" : [ "site:current-user:roles" ] },
+          "DO" : [ { "drupal_message" : { "message" : [ "list-item" ] } } ]
+        }
       }
     ]
   }
