diff --git a/includes/tvi.query.inc b/includes/tvi.query.inc
index fad4d5f..e52c5bf 100755
--- a/includes/tvi.query.inc
+++ b/includes/tvi.query.inc
@@ -9,18 +9,18 @@
  * Return a default setting object.
  */
 function tvi_default_settings($type = TVI_TYPE_TERM, $xid = 0) {
-	$settings = new stdClass();
-	
+  $settings = new stdClass();
+
   $settings->type = $type;
   $settings->xid  = $xid;
-  
+
   $settings->view_name = 0;
   $settings->display = TVI_DEFAULT_DISPLAY;
   $settings->status  = 0;
-  
+
   $settings->is_default = TRUE;
-		
-	return $settings;	
+
+  return $settings;
 }
 
 //------------------------------------------------------------------------------
@@ -30,18 +30,22 @@ function tvi_default_settings($type = TVI_TYPE_TERM, $xid = 0) {
  * flag is set.
  */
 function tvi_load_settings($xid, $type = TVI_TYPE_TERM, $return_default = TRUE) {
-	
-  $settings = db_select('tvi_settings', 'tvi')
-          ->fields('tvi')
-          ->condition('tvi.type', $type)
-          ->condition('tvi.xid', $xid)
-          ->execute()
-          ->fetchObject();
-  
+
+  if ($type == TVI_TYPE_VOCAB) {
+    $vocabulary = taxonomy_vocabulary_load($xid);
+    $xid = $vocabulary->machine_name;
+  }
+  elseif ($type == TVI_TYPE_TERM && module_exists('uuid')) {
+    $xid = reset(entity_get_uuid_by_id('taxonomy_term', array($xid)));
+  }
+
+  $settings = variable_get('tvi_' . $type . '_' . $xid);
+  $settings = is_array($settings) ? (object) $settings : $settings;
+
   if (!is_object($settings)) {
-  	return ($return_default ? tvi_default_settings($type, $xid) : NULL);
+    return ($return_default ? tvi_default_settings($type, $xid) : NULL);
   }
-  
+
   $settings->is_default = FALSE;
   return $settings;
 }
@@ -52,51 +56,30 @@ function tvi_load_settings($xid, $type = TVI_TYPE_TERM, $return_default = TRUE)
  * Save settings information for a taxonomy vocabulary or term to the database.
  */
 function tvi_update_settings($settings) {
-	
-  if (is_array($settings)) {
-   $settings = (object)$settings;
+  if (is_object($settings)) {
+    $settings = (array) $settings;
   }
 
-  $count = db_select('tvi_settings', 'tvi')
-        ->fields('tvi')
-        ->condition('tvi.type', $settings->type)
-        ->condition('tvi.xid', $settings->xid)
-        ->countQuery()
-        ->execute()
-        ->fetchCol();
-
-  if($count[0] != 0) {
-    $result = db_update('tvi_settings')
-        ->condition('type', $settings->type)
-        ->condition('xid', $settings->xid)
-        ->fields(array(
-            'view_name' => $settings->view_name,
-            'display' => $settings->display,
-            'status' => $settings->status,
-          ))
-        ->execute();
-  }
-  else {
-    $result = db_insert('tvi_settings')
-        ->fields(array(
-            'type' => $settings->type,
-            'xid' => $settings->xid,
-            'view_name' => $settings->view_name,
-            'display' => $settings->display,
-            'status' => $settings->status,
-          ))
-        ->execute();
-  }
-  return $result;
+  variable_set('tvi_' . $settings['type'] . '_' . $settings['xid'], $settings);
 }
 
 //------------------------------------------------------------------------------
 
+/**
+ * Delete settings information for a taxonomy vocabulary or term in 
+ * the database.
+ */
 function tvi_remove_settings($xid, $type = TVI_TYPE_TERM) {
-  $return = db_delete('tvi_settings')
-      ->condition('type', $settings->type)
-      ->condition('xid', $settings->xid)
-      ->execute();
+
+  if ($type == TVI_TYPE_VOCAB) {
+    $vocabulary = taxonomy_vocabulary_load($xid);
+    $xid = $vocabulary->machine_name;
+  }
+  elseif ($type == TVI_TYPE_TERM && module_exists('uuid')) {
+    $xid = reset(entity_get_uuid_by_id('taxonomy_term', array($xid)));
+  }
+
+  variable_del('tvi_' . $type . '_' . $xid);
 }
 
-//------------------------------------------------------------------------------
\ No newline at end of file
+//------------------------------------------------------------------------------
diff --git a/tvi.install b/tvi.install
index a0a45a9..8de0e05 100755
--- a/tvi.install
+++ b/tvi.install
@@ -1,58 +1,6 @@
 <?php
 
 /**
- * Implementation of hook_schema().
- * 
- * @see http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_schema/7
- */
-function tvi_schema() {
-	
-	$schema['tvi_settings'] = array(
-		'description' => 'Stores data relating a view display with a taxonomy term or vocabulary.',
-    'fields' => array(
-      'type' => array(
-        'type' => 'varchar',
-        'length' => 50,
-        'not null' => TRUE,
-        'default' => TVI_TYPE_TERM,
-        'description' => 'The type of taxonomy view setting. Can be; TVI_TYPE_TERM or TVI_TYPE_VOCAB.',
-      ),
-      'xid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'default' => 0,
-        'description' => 'Taxonomy vocabulary or term ID.',
-      ),
-      'view_name' => array(
-        'type' => 'varchar',
-        'length' => 128,
-        'not null' => TRUE,
-        'default' => '',
-        'description' => 'The view name that is used for this taxonomy display.',
-      ),
-      'display' => array(
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => 'default',
-        'description' => 'The view display to use.',
-      ),
-      'status' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'default' => 0,
-        'description' => 'A flag to indicate whether to use or not.',
-      ),
-    ),
-    'primary key' => array('type', 'xid'),
-  );
-	
-  return $schema;
-}
-
-/**
  * Implementation of hook_install().
  * 
  * @see http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_install/7
@@ -71,4 +19,47 @@ function tvi_install() {
           ->condition('name', 'tvi')
           ->fields(array('weight' => $view_info->weight + 5))
           ->execute();
-}
\ No newline at end of file
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function tvi_uninstall() {
+  db_delete('variable')
+    ->condition('name', 'tvi_%', 'LIKE');
+}
+
+/**
+ * Replace vids by machine_names.
+ */
+function tvi_update_7001() {
+  $settings = db_select('tvi_settings', 'tvi')
+                ->fields('tvi')
+                ->condition('tvi.type', TVI_TYPE_VOCAB)
+                ->execute()
+                ->fetchAll();
+  foreach ($settings as $setting) {
+    $voc = taxonomy_vocabulary_load($setting->xid);
+    db_update('tvi_settings')
+      ->fields(array('xid' => $voc->machine_name))
+      ->condition('type', $setting->type)
+      ->condition('xid', $setting->xid)
+      ->execute();
+  }
+}
+
+
+/**
+ * Drop schema in favor of {variable} table.
+ */
+function tvi_update_7002() {
+  tvi_include('query');
+  $settings = db_select('tvi_settings', 'tvi')
+                ->fields('tvi')
+                ->execute()
+                ->fetchAll();
+  foreach ($settings as $setting) {
+    tvi_update_settings($setting);
+  }
+  db_drop_table('tvi_settings');
+}
