diff --git a/mongodb_block/mongodb_block.module b/mongodb_block/mongodb_block.module
index 3ffc718..34c4c1b 100644
--- a/mongodb_block/mongodb_block.module
+++ b/mongodb_block/mongodb_block.module
@@ -319,7 +319,7 @@ function mongodb_block_save_block($collection, $block) {
  *
  * @see block.tpl.php
  */
-function template_preprocess_block(&$variables) {
+function template_preprocess_mongodb_block(&$variables) {
   $block_counter = &drupal_static(__FUNCTION__, array());
   $variables['block'] = $variables['elements']['#block'];
   // All blocks get an independent counter for each region.
diff --git a/mongodb_field_storage/mongodb_field_storage.module b/mongodb_field_storage/mongodb_field_storage.module
index fbbd7a4..0473b6b 100644
--- a/mongodb_field_storage/mongodb_field_storage.module
+++ b/mongodb_field_storage/mongodb_field_storage.module
@@ -495,6 +495,114 @@ function mongodb_field_storage_entity_info_alter(&$entity_info) {
   }
 }
 
+/**
+ * Implements hook_node_insert().
+ */
+function mongodb_field_storage_node_insert($node) {
+  // Add taxonomy index entries for the node.
+  mongodb_field_storage_build_node_index($node);
+}
+
+/**
+ * Implements hook_node_update().
+ */
+function mongodb_field_storage_node_update($node) {
+  // Always rebuild the node's taxonomy index entries on node save.
+  mongodb_field_storage_build_node_index($node);
+}
+
+/**
+ * Implements hook_module_implements_alter().
+ */
+function mongodb_field_storage_module_implements_alter(&$implementations, $hook) {
+  if (in_array($hook, array('node_insert', 'node_update'))) {
+    if (array_key_exists('taxonomy', $implementations) === TRUE) {
+      // Move mongodb_field_storage_node_xxxx() after taxonomy module
+      // implementation.
+      $group = $implementations['mongodb_field_storage'];
+      unset($implementations['mongodb_field_storage']);
+      $key = array_search('taxonomy', array_keys($implementations)) + 1;
+      $implementations = array_slice($implementations, 0, $key, TRUE) + array('mongodb_field_storage' => $group) + array_slice($implementations, $key, NULL, TRUE);
+      reset($implementations);
+    }
+  }
+}
+
+/**
+ * Builds and inserts taxonomy index entries for a given node.
+ *
+ * The index lists all terms that are related to a given node entity, and is
+ * therefore maintained at the entity level.
+ *
+ * @param object $node
+ *   The node object.
+ */
+function mongodb_field_storage_build_node_index($node) {
+  // We maintain a denormalized table of term/node relationships, containing
+  // only data for current, published nodes.
+  $status = NULL;
+  if (variable_get('taxonomy_maintain_index_table', TRUE)) {
+    // If a node property is not set in the node object when node_save() is
+    // called, the old value from $node->original is used.
+    if (!empty($node->original)) {
+      $status = (int) (!empty($node->status) || (!isset($node->status) && !empty($node->original->status)));
+      $sticky = (int) (!empty($node->sticky) || (!isset($node->sticky) && !empty($node->original->sticky)));
+    }
+    else {
+      $status = (int) (!empty($node->status));
+      $sticky = (int) (!empty($node->sticky));
+    }
+  }
+  // We only maintain the taxonomy index for published nodes.
+  if ($status) {
+    // Collect a unique list of all the term IDs from all node fields.
+    $tid_all = array();
+    foreach (field_info_instances('node', $node->type) as $instance) {
+      $field_name = $instance['field_name'];
+      $field = field_info_field($field_name);
+      if ($field['module'] == 'taxonomy' && $field['storage']['type'] == 'mongodb_field_storage') {
+        // If a field value is not set in the node object when node_save() is
+        // called, the old value from $node->original is used.
+        if (isset($node->{$field_name})) {
+          $items = $node->{$field_name};
+        }
+        elseif (isset($node->original->{$field_name})) {
+          $items = $node->original->{$field_name};
+        }
+        else {
+          continue;
+        }
+        foreach (field_available_languages('node', $field) as $langcode) {
+          if (!empty($items[$langcode])) {
+            foreach ($items[$langcode] as $item) {
+              $tid_all[$item['tid']] = $item['tid'];
+            }
+          }
+        }
+      }
+    }
+    // Insert index entries for all the node's terms.
+    if (!empty($tid_all)) {
+      $query = db_insert('taxonomy_index')->fields(array(
+        'nid',
+        'tid',
+        'sticky',
+        'created',
+        )
+      );
+      foreach ($tid_all as $tid) {
+        $query->values(array(
+          'nid' => $node->nid,
+          'tid' => $tid,
+          'sticky' => $sticky,
+          'created' => $node->created,
+        ));
+      }
+      $query->execute();
+    }
+  }
+}
+
 class MongoDbEntityLoader {
   function __construct($entityType, $ids, $conditions) {
     $this->entityType = $entityType;
