diff --git flag.module flag.module
index fe4286c..83b82d1 100644
--- flag.module
+++ flag.module
@@ -1496,9 +1496,12 @@ function flag_get_default_flags($include_disabled = FALSE) {
 
   foreach (module_implements('flag_default_flags') as $module) {
     $function = $module . '_flag_default_flags';
-    foreach ($function() as $config) {
+    foreach ($function() as $name => $config) {
+      $config += array(
+        'name' => $name,
+        'module' => $module,
+      );
       $flag = flag_flag::factory_by_array($config);
-      $flag->module = $module;
 
       // Disable flags that are not at the current API version.
       if (!$flag->is_compatible()) {
diff --git includes/flag.export.inc includes/flag.export.inc
index 1570602..3e1b0d4 100644
--- includes/flag.export.inc
+++ includes/flag.export.inc
@@ -50,9 +50,15 @@ function flag_export_flags($flags = array(), $module = '', $indent = '') {
 
     // Remove the flag ID.
     unset($new_flag['fid']);
+    // The name is emitted as the key for the array.
+    unset($new_flag['name']);
+    // Sort the types array for consistent exports.
+    if (isset($new_flag['types'])) {
+      sort($new_flag['types']);
+    }
 
     $output .= $indent . '// Exported flag: "'. check_plain($flag->get_title()) . '"' . ".\n";
-    $output .= $indent . '$flags[] = ' . (function_exists('features_var_export') ? features_var_export($new_flag, $indent) : var_export($new_flag, TRUE)) . ";\n";
+    $output .= $indent . '$flags[\''  $flag->name '\'] = ' . (function_exists('features_var_export') ? features_var_export($new_flag, $indent) : var_export($new_flag, TRUE)) . ";\n";
   }
   $output .= $indent . 'return $flags;';
   return $output;
