diff --git a/strongarm.admin.inc b/strongarm.admin.inc
index 6a43b4b..283cb7d 100644
--- a/strongarm.admin.inc
+++ b/strongarm.admin.inc
@@ -14,21 +14,34 @@ function strongarm_admin_form($form_state) {
       // If variable value does not match global $conf, this value has been
       // hardcoded (e.g. in settings.php) and has been allowed to pass
       // through. It cannot be reverted.
-      if ($conf[$name] !== $variable->value) {
+      $hardcoded = FALSE;
+      $restorable = FALSE;
+      if (isset($conf[$name]) && $conf[$name] !== $variable->value) {
         $storage = t('Hardcoded');
         $hardcoded = TRUE;
       }
+      elseif (isset($variable->in_code_only)) {
+        $storage = t('In code');
+        $restorable = TRUE;
+      }
+      elseif ($variable->value != $default->value) {
+        $storage = t('Overridden');
+        $restorable = TRUE;
+      }
       else {
-        $storage = ($variable->value == $default->value) ? t('Default') : t('Overridden');
-        $hardcoded = FALSE;
+        $storage = t('Saved to DB');
       }
 
+      $value = $hardcoded ? $conf[$name] : $variable->value;
+
       // If the variable is in the database and differs from its code value,
       // allow administrator to revert its value.
-      if (!$hardcoded && ($variable->export_type & EXPORT_IN_DATABASE) && ($variable->value != $default->value)) {
+      if ($restorable) {
         $form['revert']['#tree'] = TRUE;
-        $form['revert'][$name] = array('#type' => 'checkbox');
+        $form['revert'][$name]['revert'] = array('#type' => 'checkbox');
+        $form['revert'][$name]['value'] = array('#type' => 'value', '#value' => $default->value);
       }
+
       $form['name'][$name] = array(
         '#type' => 'markup',
         '#value' => $name,
@@ -39,14 +52,14 @@ function strongarm_admin_form($form_state) {
       );
       $form['value'][$name] = array(
         '#type' => 'markup',
-        '#value' => check_plain(_strongarm_readable($variable->value)),
+        '#value' => check_plain(_strongarm_readable($value)),
       );
     }
   }
   if (!empty($form['revert'])) {
     $form['submit'] = array(
       '#type' => 'submit',
-      '#value' => t('Reset to defaults'),
+      '#value' => t('Restore values to DB'),
       '#submit' => array('strongarm_admin_revert_submit'),
     );
   }
@@ -59,8 +72,8 @@ function strongarm_admin_form($form_state) {
 function strongarm_admin_revert_submit(&$form, &$form_state) {
   if (!empty($form_state['values']['revert'])) {
     foreach ($form_state['values']['revert'] as $name => $revert) {
-      if ($revert) {
-        variable_del($name);
+      if ($revert['revert']) {
+        variable_set($name, $revert['value']);
       }
     }
     strongarm_flush_caches();
diff --git a/strongarm.drush.inc b/strongarm.drush.inc
new file mode 100644
index 0000000..8d34bed
--- /dev/null
+++ b/strongarm.drush.inc
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * Implementation of hook_drush_command().
+ */
+function strongarm_drush_command() {
+  $items = array();
+
+  $items['strongarm-revert'] = array(
+    'description' => 'Revert all strongarmed variables from code to the database.',
+    'options' => array(
+      'force' => 'Reset all variables, including those that are marked as already being set to the database.',
+    ),
+    'bootstrap' => 'DRUSH_BOOTSTRAP_DRUPAL_FULL',
+  );
+
+  return $items;
+}
+
+/**
+ * Command callback for strongarm_revert.
+ */
+function drush_strongarm_revert() {
+  _drush_strongarm_revert(drush_get_option('force', FALSE));
+  drush_log('Pushed variables from code to the database.', 'success');
+}
+
+/**
+ * Handle the revert of variables into the database.
+ */
+function _drush_strongarm_revert($force) {
+  global $conf;
+
+  $vars = strongarm_vars_load(TRUE, TRUE);
+  foreach ($vars as $name => $var) {
+    if ($force || isset($var->in_code_only)) {
+      if (!isset($conf[$name]) || $var->value != $conf[$name]) {
+        variable_set($name, $var->value);
+      }
+    }
+  }
+}
diff --git a/strongarm.install b/strongarm.install
index 97172c4..30f50ee 100644
--- a/strongarm.install
+++ b/strongarm.install
@@ -47,3 +47,18 @@ function strongarm_update_6201() {
   }
   return $ret;
 }
+
+/**
+ * Update 6202: Set all strongarm variables that are only set in code in the database.
+ */
+function strongarm_update_6202() {
+  $variables = strongarm_vars_load();
+  if (!empty($variables)) {
+    foreach ($variables as $var_name => $var) {
+      $exists = db_result(db_query("SELECT name FROM {variable} WHERE name = '%s'", $var_name));
+      if (!$exists) {
+        variable_set($var_name, $var->value);
+      }
+    }
+  }
+}
diff --git a/strongarm.module b/strongarm.module
index 5618f18..7e0d209 100644
--- a/strongarm.module
+++ b/strongarm.module
@@ -1,77 +1,6 @@
 <?php
+// $Id: strongarm.module,v 1.1.2.6.2.17 2010/08/05 14:43:24 yhahn Exp $
 
-/**
- * Implementation of hook_init().
- */
-function strongarm_init() {
-  strongarm_set_conf();
-
-  // This is a workaround for the very early check of the 'site_frontpage'
-  // variable in the Drupal bootstrap process. The workaround re-runs
-  // drupal_init_path() to ensure the strongarm'ed version of
-  // 'site_frontpage' is used. Note that this may be too late if other modules
-  // weighted even lower than strongarm (which is a superlightweight -1000)
-  // rely on $_GET['q'] or 'site_frontpage' in hook_init().
-  $_GET['q'] = isset($_REQUEST['q']) ? strongarm_language_strip($_REQUEST['q']) : NULL;
-  drupal_init_path();
-}
-
-/**
- * Retrieve variable configuration from the cache.
- */
-function strongarm_set_conf($reset = FALSE) {
-  $varcache = cache_get('variables', 'cache');
-  $cache = cache_get('strongarm', 'cache');
-  // The > comparison here is cautious but ensures that the strongarm cache
-  // actually was populated after the variable cache. It is possible with
-  // >= for the var cache to be populated again during the same stale second.
-  if (!$reset && ($cache && $varcache && $cache->created > $varcache->created)) {
-    $var_conf = $cache->data;
-  }
-  else {
-    $var_conf = array();
-    foreach (strongarm_vars_load(FALSE, TRUE) as $var) {
-      $var_conf[$var->name] = $var->value;
-    }
-    cache_set('strongarm', $var_conf);
-  }
-  global $conf;
-
-  // Store the original variable values. This allows additional calls to
-  // strongarm_set_conf() to properly set Strongarm values.
-  static $original_conf;
-  if (!isset($original_conf)) {
-    $original_conf = $conf;
-  }
-
-  $conf = array_merge($var_conf, $original_conf);
-}
-
-/**
- * Remove the language prefix for a given path.
- * Strongarm implements this itself as language_initialize() directly affects
- * $_GET['q'] and cannot be reused.
- */
-function strongarm_language_strip($path) {
-  // Configured presentation language mode.
-  $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
-
-  // Get a list of enabled languages.
-  $languages = language_list('enabled');
-  $languages = $languages[1];
-
-  if (in_array($mode, array(LANGUAGE_NEGOTIATION_PATH_DEFAULT, LANGUAGE_NEGOTIATION_PATH))) {
-    $args = explode('/', $path);
-    $prefix = array_shift($args);
-    // Search prefix within enabled languages.
-    foreach ($languages as $language) {
-      if (!empty($language->prefix) && $language->prefix == $prefix) {
-        return implode('/', $args);
-      }
-    }
-  }
-  return $path;
-}
 
 /**
  * Implementation of hook_menu().
@@ -181,12 +110,87 @@ function strongarm_vars_load($sorted = TRUE, $reset = FALSE) {
  */
 if (!function_exists('variable_features_revert')) {
   function variable_features_revert($module) {
-    ctools_component_features_revert('variable', $module);
+    $defaults = features_get_default('variable', $module);
+    if (empty($defaults)) {
+      return;
+    }
+
+    $vars = strongarm_vars_load(TRUE, TRUE);
+    foreach ($defaults as $name => $default) {
+      if (isset($vars[$name]->in_code_only) || ($default->value != $vars[$name]->value)) {
+        variable_set($name, $default->value);
+      }
+    }
+
     cache_clear_all('variables', 'cache');
   }
 }
 
 /**
+ * Implementation of hook_features_rebuild().
+ * Same as revert, but we only want to force variables only in code into the database
+ */
+function variable_features_rebuild($module) {
+  $defaults = features_get_default('variable', $module);
+  if (empty($defaults)) {
+    return;
+  }
+
+  $vars = strongarm_vars_load(TRUE, TRUE);
+  foreach ($defaults as $name => $default) {
+    if (isset($vars[$name]->in_code_only) || (drupal_installation_attempted() && $vars[$name]->export_type & EXPORT_IN_CODE)) {
+      variable_set($name, $default->value);
+    }
+  }
+
+  cache_clear_all('variables', 'cache');
+}
+
+
+/**
+ * Implements hook_features_export().
+ *
+ * This is implemented to remove variables that are in code, but not DB.
+ * This is a result of Strongarm vars now living in the DB, so unlike other
+ * ctools components, an update of this Feature with a variable in code but
+ * not the database, should remove the variable form the Feature.
+ */
+function variable_features_export($data, &$export, $module_name) {
+  // First delegate to the Features ctools export
+  $pipe = ctools_component_features_export('variable', $data, $export, $module_name);
+
+  // Then remove any vars from the export that are only in code
+  $vars = strongarm_vars_load(TRUE, TRUE);
+  foreach ($data as $object_name) {
+    if(!isset($vars[$object_name]) || $vars[$object_name]->in_code_only) {
+      unset($export['features']['variable'][$object_name]);
+    }
+  }
+  return $pipe;
+}
+
+/**
+ * Implements hook_features_export_render().
+ *
+ * Loads default values from the DB since it is now the system of record.
+ */
+function variable_features_export_render($module, $data) {
+  ctools_include('export');
+  $schema = ctools_export_get_schema('variable');
+  $code = '  $export = array();'."\n\n";
+  $identifier = $schema['export']['identifier'];
+  $result = db_query("SELECT * FROM {variable} WHERE name IN (:names)", array(':names' => $data));
+  foreach ($result as $object) {
+    $object = _ctools_export_unpack_object($schema, $object);
+    $code .= _ctools_features_export_crud_export('variable', $object, '  ');
+    $code .= "  \$export[" . ctools_var_export($object->name) . "] = \${$identifier};\n\n";
+  }
+  $code .= '  return $export;';
+
+  return array($schema['export']['default hook'] => $code);
+}
+
+/**
  * Implementation of hook_features_pipe_alter() for node component.
  * Add node type variables on behalf of core modules.
  */
