diff --git a/data_entity/data_entity.module b/data_entity/data_entity.module
index 0903ac0..a9da316 100644
--- a/data_entity/data_entity.module
+++ b/data_entity/data_entity.module
@@ -63,17 +63,18 @@ function data_entity_entity_info() {
       'label' => $table->title,
       'controller class' => 'DataEntityController',
       'base table'  => $table_name,
+      'bundle keys' => array('bundle' => 'type'),
       'fieldable' => TRUE,
       'entity keys' => array(
         'id' => $id_field,
       ),
       'bundles' => array(
         $entity_type => array(
+          'type'  => $entity_type,
           'label' => $table->title,
           'admin' => array(
             'path'      => 'admin/structure/data/edit/%data_ui_table',
             'real path' => 'admin/structure/data/edit/' . $table_name,
-            'bundle argument' => 4,
             'access arguments' => array('administer data tables'),
           ),
         ),
@@ -126,6 +127,48 @@ function data_entity_menu_alter(&$items) {
   $tables = data_entity_get_entity_tables();
   $info = array();
 
+  // Fix Field UI menu items
+  if (module_exists('field_ui')) {
+    $prefix = 'admin/structure/data/edit/%data_ui_table/fields';
+    $prefix_new = 'admin/structure/data/edit/%data_entity_string/fields';
+    $argument_to_replace = '__nothing__';
+    $new_items = array();
+    $entity_tables = data_entity_get_entity_tables();
+    foreach ($items as $key => $item) {
+      if (strpos($key, $prefix) !== 0) {
+        $new_items[$key] = $item;
+        continue;
+      }
+      // We don't want data_ui_table_load() to run when editing fields,
+      // Entity UI forms accept string names as their arguments.
+      $item = $items[$key];
+      // Field UI incorrectly replaces dynamic % argument with the last value loaded with %data_ui_table
+      // Fix this.
+      if ($key == $prefix) {
+        $static_name = $item['page arguments'][1];
+        $new_key = str_replace($prefix, $prefix_new, $key);
+
+        foreach ($item['page arguments'] as $arg_key => $value) {
+          if ($value == $static_name) {
+            $item['page arguments'][$arg_key] = 4;
+          }
+        }
+        $new_items[$new_key] = $item;
+      }
+      elseif (!empty($item['load arguments'])) {
+        foreach ($item['load arguments'] as $arg_key => $value) {
+          if ($value == $static_name) {
+            $item['load arguments'][$arg_key] = 4;
+          }
+        }
+        $new_key = $prefix_new . substr($key, strlen($prefix));
+        $new_key = str_replace('%field_ui_menu', '%data_entity_field_ui_menu', $new_key);
+        $new_items[$new_key] = $item;
+      }
+    }
+    $items = $new_items;
+  }
+
   /*
   // This breaks access on these menu items!
   foreach ($tables as $table_name => $table) {
@@ -157,6 +200,27 @@ function data_entity_item_load($deid, $table_name) {
 }
 
 /**
+ * Menu loader callback.
+ * @see data_entity_menu_alter()
+ *
+ */
+function data_entity_string_load($table_name) {
+  return 'data_' . $table_name;
+}
+
+/**
+ * Helper menu loader function to pass correct values to field_ui_menu_load()
+ * @see field_ui_menu_load()
+ * @see data_entity_menu_alter()
+ */
+function data_entity_field_ui_menu_load() {
+  $args = func_get_args();
+  $args[1] = 'data_' . $args[1];
+  $args[2] = 'data_' . $args[2];
+  return call_user_func_array('field_ui_menu_load', $args);
+}
+
+/**
  * Implements hook_permission().
  */
 function data_entity_permission() {
diff --git a/includes/DataTable.inc b/includes/DataTable.inc
index 30a85cb..8604b88 100644
--- a/includes/DataTable.inc
+++ b/includes/DataTable.inc
@@ -58,6 +58,7 @@ class DataTable {
   protected function __construct($name) {
     // Set our name after sanitizing it.
     $this->name = db_escape_table($name);
+    $this->type = 'data_' . $this->name;
 
     // Try to load table information.
     if ($table = _data_load_table($name)) {
