diff --git a/blockcache_alter.install b/blockcache_alter.install
index 40dc6de..386a07b 100644
--- a/blockcache_alter.install
+++ b/blockcache_alter.install
@@ -6,10 +6,59 @@
  */
 
 /**
+ * Implementation of hook_install().
+ */
+function blockcache_alter_install() {
+  drupal_install_schema('blockcache_alter');
+}
+
+/**
  * Implementation of hook_uninstall().
  */
 function blockcache_alter_uninstall() {
   db_query("DELETE FROM {variable} WHERE name LIKE 'bc_%'");
   variable_del('bca_debug');
   variable_del('bca_corepatch');
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function blockcache_alter_schema() {
+  $schema['blockcache_alter'] = array(
+    'description' => 'Stores cache settings for blocks.',
+    'fields' => array(
+      'module' => array(
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'default' => '',
+        'description' => "The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks.",
+      ),
+      'delta' => array(
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => '0',
+        'description' => 'Unique ID for block within a module.',
+      ),
+      'cache' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 1,
+        'size' => 'tiny',
+        'description' => 'Binary flag to indicate block cache mode. (-1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See BLOCK_CACHE_* constants in block.module for more detailed information.',
+      ),
+    ),
+  );
+
+  return $schema;
+}
+
+/**
+ * Implementation of hook_update_N().
+ */
+function blockcache_alter_update_6001() {
+  drupal_install_schema('blockcache_alter');
+  return array();
+}
diff --git a/blockcache_alter.module b/blockcache_alter.module
index 8421169..1f81984 100644
--- a/blockcache_alter.module
+++ b/blockcache_alter.module
@@ -20,6 +20,26 @@ function blockcache_alter_menu() {
 }
 
 /**
+ * Blockcache alter rehash function.
+ *
+ * This function is called during the block list adinistration screen
+ * and during hook_flush_caches() so the cache settings are updated.
+ */
+function blockcache_alter_rehash() {
+  $caches = db_query('SELECT * FROM {blockcache_alter}');
+  while ($block = db_fetch_object($caches)) {
+    db_query("UPDATE {blocks} SET cache = %d WHERE module = '%s' AND delta = '%s'", $block->cache, $block->module, $block->delta);
+  }
+}
+
+/**
+ * Implementation of hook_flush_caches().
+ */
+function blockcache_alter_flush_caches() {
+  blockcache_alter_rehash();
+}
+
+/**
  * Menu callback, settings page for blockcache alter
  */
 function blockcache_alter_admin_settings() {
@@ -45,6 +65,12 @@ function blockcache_alter_admin_settings() {
  * Implementation of hook_form_alter().
  */
 function blockcache_alter_form_alter(&$form, $form_state, $form_id) {
+
+  // Rehash on the block admin screen.
+  if ($form_id == 'block_admin_display_form') {
+    blockcache_alter_rehash();
+  }
+
   // Add caching fieldset to the block configure page.
   if ($form_id == 'block_admin_configure') {
 
@@ -72,7 +98,7 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) {
     );
 
     // Retrieve current cache setting for this block.
-    $default_value = db_result(db_query("SELECT cache FROM {blocks} WHERE module = '%s' AND delta = '%s'", $form['module']['#value'], $form['delta']['#value']));
+    $default_value = db_result(db_query("SELECT cache FROM {blockcache_alter} WHERE module = '%s' AND delta = '%s'", $form['module']['#value'], $form['delta']['#value']));
 
     // Blockcache fieldset.
     $form['cache'] = array(
@@ -213,8 +239,9 @@ function blockcache_alter_save_settings($form, &$form_state) {
     module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']);
     drupal_set_message(t('The block configuration has been saved.'));
 
-    // Update block cache settings.
-    db_query("UPDATE {blocks} set cache = %d WHERE module = '%s' AND delta = '%s'", $form_state['values']['cache_block'], $form_state['values']['module'], $form_state['values']['delta']);
+    // Save block cache settings.
+    db_query("DELETE FROM {blockcache_alter} WHERE module = '%s' AND delta = '%s'", $form_state['values']['module'], $form_state['values']['delta']);
+    db_query("INSERT INTO {blockcache_alter} (module, delta, cache) VALUES ('%s', '%s', %d)", $form_state['values']['module'], $form_state['values']['delta'], $form_state['values']['cache_block']);
 
     // Core patch applied or not.
     $core_patch = variable_get('bca_corepatch', 0);
