diff --git a/fieldblock.install b/fieldblock.install
new file mode 100644
index 0000000000000000000000000000000000000000..71442559121dc0efa6d88f7d99336bc477e3815d
--- /dev/null
+++ b/fieldblock.install
@@ -0,0 +1,93 @@
+<?php
+
+/**
+ * Implements hook_install().
+ * Double the maximum length of the delta fields because fieldblock delta's
+ * can easily get longer than 32 characters.
+ */
+function fieldblock_install() {
+  _fieldblock_db_alter_block_delta_length(64);
+}
+
+/**
+ * Implements hook_schema_alter().
+ * Informs Drupal about the fact that we have altered the database.
+ */
+function fieldblock_schema_alter(&$schema) {
+  $schema['block']['fields']['delta']['length'] = 64;
+  $schema['block_role']['fields']['delta']['length'] = 64;
+  $schema['block_node_type']['fields']['delta']['length'] = 64;
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function fieldblock_uninstall() {
+  // Restore database alterations.
+  _fieldblock_db_alter_block_delta_length(32);
+
+  // Delete variables.
+  $entities = entity_get_info();
+  // Loop over the entity types.
+  foreach ($entities as $entity_type => $entity_info) {
+    // Loop over each entity type's bundles.
+    foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
+      $view_modes = field_view_mode_settings($entity_type, $bundle);
+      // Treat the default settings as a real view mode with custom settings.
+      $view_modes['default']['custom_settings'] = true;
+      // Loop over the bundle's view modes.
+      foreach ($view_modes as $view_mode => $view_mode_info) {
+        // Delete the variable, if it exists.
+        $variable_name = 'fieldblock-'. $entity_type .'-'. $bundle .'-'. $view_mode;
+        variable_del($variable_name);
+      }
+    }
+  }
+}
+
+function _fieldblock_db_alter_block_delta_length($length) {
+  // Alter block table.
+  db_drop_unique_key('block', 'tmd');
+  db_change_field('block', 'delta', 'delta',
+    array(
+      'type' => 'varchar',
+      'length' => $length,
+      'not null' => TRUE,
+      'default' => '0',
+      'description' => 'Unique ID for block within a module.',
+    ),
+    array(
+      'unique keys' => array(
+        'tmd' => array('theme', 'module', 'delta'),
+      )
+    )
+  );
+
+  // Alter block_role table.
+  db_drop_primary_key('block_role');
+  db_change_field('block_role', 'delta', 'delta',
+    array(
+      'type' => 'varchar',
+      'length' => $length,
+      'not null' => TRUE,
+      'description' => "The block's unique delta within module, from {block}.delta.",
+    ),
+    array(
+      'primary key' => array('module', 'delta', 'rid'),
+    )
+  );
+
+  // Alter block_node_type table.
+  db_drop_primary_key('block_node_type');
+  db_change_field('block_node_type', 'delta', 'delta',
+    array(
+      'type' => 'varchar',
+      'length' => $length,
+      'not null' => TRUE,
+      'description' => "The block's unique delta within module, from {block}.delta.",
+    ),
+    array(
+      'primary key' => array('module', 'delta', 'type'),
+    )
+  );
+}
\ No newline at end of file
diff --git a/fieldblock.module b/fieldblock.module
index 9d0b28c84923ba96690dbc6902eb1a63599da33f..cf346f5701988aad657223721be60c54ec7fae4b 100644
--- a/fieldblock.module
+++ b/fieldblock.module
@@ -5,58 +5,125 @@
  * Allow fields to be rendered in blocks.
  */
 
-define('FIELDBLOCK_VIEWMODE', 'fieldblock');
+define('FIELDBLOCK_STORAGE_STATIC', 'fieldblock_storage');
 
 /**
- * Implements hook_entity_info_alter().
- * Define a new view mode for all entity types in which the user can control
- * which fields should be available as blocks, and choose formatter settings.
+ * Implements hook_form_alter().
+ * Adds a column to the "display fields" table-form, with a checkbox for each
+ * field.
  */
-function fieldblock_entity_info_alter(&$entity_info) {
-  foreach ($entity_info as $type => $info) {
-    $entity_info[$type]['view modes'][FIELDBLOCK_VIEWMODE] = array(
-      'label' => t('Field as block'),
-      'custom settings' => FALSE,
+function fieldblock_form_field_ui_display_overview_form_alter(&$form, &$form_state, $form_id) {
+  $entity_type = $form['#entity_type'];
+  $bundle = $form['#bundle'];
+  $view_mode = $form['#view_mode'];
+
+  $variable_name = 'fieldblock-'. $entity_type .'-'. $bundle .'-'. $view_mode;
+  $settings = variable_get($variable_name);
+
+  // Add a column header.
+  $form['fields']['#header'][] = t('Display as block');
+
+  // Add checkboxes.
+  $field_names = array_merge($form['#fields'], $form['#extra']);
+  foreach ($field_names as $field_name) {
+    $form['fields'][$field_name]['fieldblock'] = array(
+      '#type' => 'checkbox',
+      '#default_value' => isset($settings[$field_name]) ? true : false,
+      '#title' => '',
     );
   }
+
+  // Add a submit handler.
+  $form['#submit'][] = 'fieldblock_field_display_submit';
 }
 
 /**
- * Implements hook_entity_load().
- * Store the entity type so we can use it later on. See
- * http://drupal.org/node/1042822 for why this workaround is needed.
+ * Form submit handler for field_ui_display_overview_form.
+ * Saves a single variable for each entity + bundle + view mode combination if
+ * a field has been made available as block. Having separate variables makes the
+ * configuration more flexible for exporting with strongarm and features.
  */
-function fieldblock_entity_load($entities, $type) {
-  foreach ($entities as $entity) {
-    $entity->entity_type = $type;
+function fieldblock_field_display_submit($form, &$form_state) {
+  $entity_type = $form['#entity_type'];
+  $bundle = $form['#bundle'];
+  $view_mode = $form['#view_mode'];
+  $variable_name = 'fieldblock-'. $entity_type .'-'. $bundle .'-'. $view_mode;
+  $settings = array();
+
+  foreach ($form_state['values']['fields'] as $field_name => $field) {
+    if ($field['fieldblock']) {
+      $settings[$field_name] = $field_name;
+    }
+  }
+
+  if (empty($settings)) {
+    // This variable may have existed before, so let's clean up a little.
+    variable_del($variable_name);
+  }
+  else {
+    variable_set($variable_name, $settings);
   }
 }
 
 /**
- * Build a list of fields that have been made available as a block.
+ * Implements hook_block_info().
+ */
+function fieldblock_block_info() {
+  $blocks = array();
+
+  $fieldblocks = fieldblock_get_block_list();
+  foreach ($fieldblocks as $fieldblock_id => $description) {
+    $blocks[$fieldblock_id] = array(
+      'info' => $description,
+      'cache' => DRUPAL_CACHE_PER_PAGE,
+    );
+  }
+
+  return $blocks;
+}
+
+/**
+ * Helper function for fieldblock_block_info().
+ * Builds a list of fields that have been made available as a block.
  * @return array
- *   An array with all fields that are made visible in the view mode defined in
- *   fieldblock_entity_info_alter().
+ *   An array with all fields that are made visible via the display fields UI,
+ *   in the form of [fieldblock identifier] => [block description].
  */
 function fieldblock_get_block_list() {
   $fieldblocks = &drupal_static(__FUNCTION__);
 
   if (!isset($fieldblocks)) {
+    $fieldblocks = array();
     $entities = entity_get_info();
+    $instances = field_info_instances();
     // Loop over the entity types.
-    foreach ($entities as $type => $entity_info) {
+    foreach ($entities as $entity_type => $entity_info) {
       // Loop over each entity type's bundles.
       foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
-        $instances = field_info_instances($type, $bundle);
-        // Loop over each bundle's field instances.
-        foreach ($instances as $field_name => $instance) {
-          // Check if the field instance is visible in our own view mode.
-          if (isset($instance['display'][FIELDBLOCK_VIEWMODE]) && $instance['display'][FIELDBLOCK_VIEWMODE]['type'] != 'hidden') {
-            $fieldblocks[$type . '__' . $bundle . '__' . $field_name] = array(
-              'field_label' => $instance['label'],
-              'bundle_label' => $bundle_info['label'],
-              'type' => $type,
-            );
+        $view_modes = field_view_mode_settings($entity_type, $bundle);
+        // Treat the default settings as a real view mode with custom settings.
+        $view_modes['default']['custom_settings'] = true;
+        // Loop over the bundle's view modes.
+        foreach ($view_modes as $view_mode => $view_mode_info) {
+          // Ignore this view mode if its custom settings are not enabled.
+          if (!$view_mode_info['custom_settings']) {
+            continue;
+          }
+          // Get the settings from the stored variable.
+          $variable_name = 'fieldblock-'. $entity_type .'-'. $bundle .'-'. $view_mode;
+          $fieldblock_settings = variable_get($variable_name, false);
+          // If it exists, loop over the fields defined in the variable.
+          if ($fieldblock_settings) {
+            foreach ($fieldblock_settings as $field_name => $field_label) {
+              // Build the fieldblock info.
+              $fieldblock_id = $variable_name .'-'. $field_name;
+              $fieldblocks[$fieldblock_id] = t('@field field (from @type: @bundle: @view_mode)', array(
+                '@field' => $instances[$entity_type][$bundle][$field_name]['label'],
+                '@type' => $entity_type,
+                '@bundle' => $bundle_info['label'],
+                '@view_mode' => $view_mode,
+              ));
+            }
           }
         }
       }
@@ -67,70 +134,55 @@ function fieldblock_get_block_list() {
 }
 
 /**
- * Implements hook_block_info().
+ * Implements hook_block_view().
+ * Retrieves a field, identified by the block delta, from the static cache.
  */
-function fieldblock_block_info() {
-  $blocks = array();
+function fieldblock_block_view($delta = '') {
+  $block = array();
 
-  $fieldblocks = fieldblock_get_block_list();
-  if ($fieldblocks) {
-    foreach ($fieldblocks as $fieldblock_id => $fieldblock) {
-      $blocks[$fieldblock_id] = array(
-        'info' => t('@field (field in @type: @bundle)', array(
-          '@field' => $fieldblock['field_label'],
-          '@type' => $fieldblock['type'],
-          '@bundle' => $fieldblock['bundle_label'],
-        )),
-        'cache' => DRUPAL_CACHE_PER_PAGE,
-      );
+  $fieldblocks_storage = &drupal_static(FIELDBLOCK_STORAGE_STATIC);
+  if (isset($fieldblocks_storage[$delta])) {
+    // If the field has a label, use it as block title and hide it on the
+    // field itself.
+    $block['subject'] = '';
+    if ($fieldblocks_storage[$delta]['#label_display'] != 'hidden') {
+      $block['subject'] = $fieldblocks_storage[$delta]['#title'];
+      $fieldblocks_storage[$delta]['#label_display'] = 'hidden';
     }
+    $block['content'] = $fieldblocks_storage[$delta];
   }
 
-  return $blocks;
+  return $block;
 }
 
 /**
- * Implements hook_block_view().
+ * Implements hook_field_attach_view_alter().
+ * Stores fields attached to the current entity in a static cache, to be
+ * retrieved in fieldblock_block_view, and hides the field from the renderable
+ * array.
  */
-function fieldblock_block_view($fieldblock_id = '') {
-  $block = array();
-
-  list($fieldblock_type, $fieldblock_bundle, $field_name) = explode('__', $fieldblock_id);
-
-  // Figure out what the current entity is. This only works for entities that
-  // have the entity ID as the second argument of the entity URI, like for
-  // instance node/[nid] or user/[uid].
-  // See also http://drupal.stackexchange.com/questions/5703.
-  $router_item = menu_get_item();
-  if (isset($router_item['map'][1])) {
-
-    // This could be our entity.
-    $entity = $router_item['map'][1];
-
-    // If it's an object with an entity_type property, it's safe to assume that
-    // this is the entity we're looking for.
-    if (is_object($entity) && isset($entity->entity_type)) {
-      $entity_type = $entity->entity_type;
-
-      // If the fieldblock type matches the entity type, continue.
-      if ($fieldblock_type == $entity_type) {
-
-        // Find the bundle of the current entity.
-        $entity_ids = entity_extract_ids($entity_type, $entity);
-        $entity_bundle = $entity_ids[2];
-
-        // If the fieldblock bundle matches the entity bundle: build the block!
-        if ($fieldblock_bundle == $entity_bundle) {
-
-          // Get the field formatter settings for the fieldblock view mode.
-          $instance = field_info_instance($fieldblock_type, $field_name, $fieldblock_bundle);
-
-          $block['subject'] = $instance['label'];
-          $block['content'] = field_view_field($entity_type, $entity, $field_name, $instance['display'][FIELDBLOCK_VIEWMODE]);
-        }
-      }
+function fieldblock_field_attach_view_alter(&$output, $context) {
+  $entity_type = $context['entity_type'];
+  $bundle = $output['#bundle'];
+  $view_mode = $context['view_mode'];
+
+  // Check whether the view mode uses custom display settings or the 'default'
+  // mode.
+  $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
+  $actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default');
+
+  $fieldblocks_storage = &drupal_static(FIELDBLOCK_STORAGE_STATIC);
+
+  $variable_name = 'fieldblock-'. $entity_type .'-'. $bundle .'-'. $actual_mode;
+  $fieldblock_settings = variable_get($variable_name, false);
+
+  // Loop over the fieldblocks for this entity + bundle + view mode combination
+  // and store the field's render array for later use.
+  foreach ($fieldblock_settings as $field_name) {
+    if (isset($output[$field_name])) {
+      $fieldblock_id = $variable_name .'-'. $field_name;
+      $fieldblocks_storage[$fieldblock_id] = $output[$field_name];
+      hide($output[$field_name]);
     }
   }
-
-  return $block;
 }