diff --git a/data_entity/data_entity.entity.inc b/data_entity/data_entity.entity.inc
index 5a58199..ec73a2c 100644
--- a/data_entity/data_entity.entity.inc
+++ b/data_entity/data_entity.entity.inc
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Entity controller class for Data entities.
  *
@@ -31,4 +30,29 @@ class DataEntityController extends EntityAPIController implements EntityAPIContr
 
     return $entities;
   }
+
+  /**
+   * Permanently saves the entity.
+   */
+
+  public function save ($entity) {
+    $record = array();
+    $table_name = $this->dataTable;
+    $schema = drupal_get_schema($table_name);
+
+    // Get all fields in the table
+    foreach ($schema['fields'] as $field_name => $field_info) {
+      // Only use fields which are being saved
+      if (isset($entity->{$field_name})) {
+        $record[$field_name] = $entity->{$field_name};
+      }
+    }
+
+    // Save the row
+    if ($handler = DataHandler::instance($table_name)) {
+      $handler->save($record);
+    }
+
+  }
+
 }
diff --git a/data_entity/data_entity.module b/data_entity/data_entity.module
index 755da61..86db65a 100644
--- a/data_entity/data_entity.module
+++ b/data_entity/data_entity.module
@@ -33,9 +33,12 @@ function data_entity_meta_add_defaults(&$meta) {
  */
 function data_entity_get_id_field($table) {
   if (isset($table->table_schema['primary key'])) {
-    // @todo: whopping assumption that there's a single primary key field.
-    $id_field = $table->table_schema['primary key'][0];
-    return $id_field;
+    // Use the first primary key which is an integer
+    foreach ($table->table_schema['primary key'] as $id_field) {
+      if ($table->table_schema['fields'][$id_field]['type'] == 'int') {
+        return $id_field;
+      }
+    }
   }
 }
 
@@ -184,7 +187,7 @@ function data_entity_permission() {
 
   foreach ($tables as $table_name => $table) {
     $permissions['edit data in table ' . $table_name] = array(
-      'title' => t('Edit data in the %table_name table', array('%table_name' => $table->title)), 
+      'title' => t('Edit data in the %table_name table', array('%table_name' => $table->title)),
     );
   }
 
@@ -223,3 +226,45 @@ function data_entity_views_api() {
   );
 }
 
+/**
+ * Implements hook_entity_property_info().
+ *
+ * Allow modules to define metadata about entity properties.
+ */
+
+function data_entity_entity_property_info() {
+  $tables = data_entity_get_entity_tables();
+  foreach ($tables as $table) {
+    foreach ($table->table_schema['fields'] as $field_name => $field) {
+      $info['data_' . $table->name]['properties'][$field_name] = array(
+        'label' => !empty($table->meta['fields'][$field_name]['label']) ? $table->meta['fields'][$field_name]['label'] : $field_name,
+        'description' => 'Field of type ' . $field['type'] . '.',
+        'getter callback' => 'entity_property_verbatim_get',
+        'setter callback' => 'entity_property_verbatim_set',
+        'field' => TRUE,
+      );
+    }
+  }
+  return $info;
+}
+
+/**
+ * Invoked before a feed item is saved.
+ *
+ * @param $source
+ *  FeedsSource object that describes the source that is being imported.
+ * @param $entity
+ *   The entity object.
+ * @param $item
+ *   The parser result for this entity.
+ */
+function data_entity_feeds_presave(FeedsSource $source, $entity, $item) {
+  if (substr($entity->feeds_item->entity_type, 0, 5) == 'data_') {
+    // Add a timestamp source field
+    foreach ($source->importer->config['processor']['config']['mappings'] as $mapping) {
+      if ($mapping['source'] == 'feeds_item_imported') {
+        $entity->{$mapping['target']} = $source->state['start_time'];
+      }
+    }
+  }
+}
