diff --git a/flag_weights.install b/flag_weights.install
index 184520d..3a45931 100644
--- a/flag_weights.install
+++ b/flag_weights.install
@@ -19,7 +19,7 @@ function flag_weights_install() {
     // 'description' => t('Flag weight within region.'),
   );
 
-  db_add_field('flag_content', 'weight', $field);
+  db_add_field('flagging', 'weight', $field);
 
   // Add a field to the existing flags table (Flag module)
   $field = array(
@@ -31,7 +31,7 @@ function flag_weights_install() {
     'description' => 'Default weight applied to new items.',
    );
 
-  db_add_field('flags', 'default_weight', $field);
+  db_add_field('flag', 'default_weight', $field);
 
 }
 
@@ -39,10 +39,10 @@ function flag_weights_install() {
  * Implementation of hook_uninstall().
  */
 function flag_weights_uninstall() {
-  if (db_table_exists('flag_content') && db_field_exists('flag_content', 'weight')) {
-    db_drop_field('flag_content', 'weight');
+  if (db_table_exists('flagging') && db_field_exists('flagging', 'weight')) {
+    db_drop_field('flagging', 'weight');
   }
-  if (db_table_exists('flags') && db_field_exists('flags', 'default_weight')) {
-    db_drop_field('flags', 'default_weight');
+  if (db_table_exists('flag') && db_field_exists('flag', 'default_weight')) {
+    db_drop_field('flag', 'default_weight');
   }
 }
diff --git a/flag_weights.module b/flag_weights.module
index 11563d7..742bbe1 100644
--- a/flag_weights.module
+++ b/flag_weights.module
@@ -16,7 +16,7 @@ define('MAX_DEFAULT_WEIGHT', 2147483647);
  */
 function flag_weights_schema_alter(&$schema) {
   // Add fields to existing schema.
-  $schema['flag_content']['fields']['weight'] = array(
+  $schema['flagging']['fields']['weight'] = array(
     'type' => 'int',
     'not null' => TRUE,
     'default' => 0,
@@ -24,7 +24,7 @@ function flag_weights_schema_alter(&$schema) {
     // 'description' => t('Flag weight within region.'),
   );
 
-  $schema['flags']['fields']['default_weight'] = array(
+  $schema['flag']['fields']['default_weight'] = array(
     'type' => 'int',
     'not null' => TRUE,
     'default' => 0,
@@ -41,7 +41,7 @@ function flag_weights_schema_alter(&$schema) {
 function flag_weights_views_data() {
   $data = array();
 
-  $data['flag_content']['weight'] = array(
+  $data['flagging']['weight'] = array(
     'title' => t('Weight'),
     'help' => t('Used for sorting the list of flagged items.'),
     'real field' => 'weight',
@@ -64,9 +64,9 @@ function flag_weights_views_data() {
  *   The content-type for the flag, eg: node.
  * @see _flag_weights_flag()
  */
-function flag_weights_set_flag($content_type, $content_id, $account = NULL, $weight = 0) {
-  $handler = flag_create_handler($content_type);
-  return _flag_weights_flag($handler, $content_id, $account, $weight);
+function flag_weights_set_flag($entity_type, $entity_id, $account = NULL, $weight = 0) {
+  $handler = flag_create_handler($entity_type);
+  return _flag_weights_flag($handler, $entity_id, $account, $weight);
 }
 
 /**
@@ -76,9 +76,9 @@ function flag_weights_set_flag($content_type, $content_id, $account = NULL, $wei
  *   The machine-name for the flag to use, eg: bookmarks.
  * @see _flag_weights_flag()
  */
-function flag_weights_set_flag_with_flag($flag_name, $content_id, $account = NULL, $weight = 0) {
+function flag_weights_set_flag_with_flag($flag_name, $entity_id, $account = NULL, $weight = 0) {
   $handler = flag_get_flag($flag_name);
-  return _flag_weights_flag($handler, $content_id, $account, $weight);
+  return _flag_weights_flag($handler, $entity_id, $account, $weight);
 }
 
 /**
@@ -96,13 +96,13 @@ function flag_weights_set_flag_with_flag($flag_name, $content_id, $account = NUL
  *   FALSE if some error occured (e.g., user has no permission, flag isn't
  *   applicable to the item, etc.), TRUE otherwise.
  */
-function _flag_weights_flag($handler, $content_id, $account = NULL, $weight = 0) {
-  $ok = $handler->flag('flag', $content_id, $account);
+function _flag_weights_flag($handler, $entity_id, $account = NULL, $weight = 0) {
+  $ok = $handler->flag('flag', $entity_id, $account);
   if ($ok && $weight != 0) {
     if (!isset($account)) {
       $account = $GLOBALS['user'];
     }
-    flag_weights_set_weight($handler->fid, $handler->content_type, $content_id, $account->uid, $weight);
+    flag_weights_set_weight($handler->fid, $handler->entity_type, $entity_id, $account->uid, $weight);
   }
   return $ok;
 }
@@ -110,15 +110,14 @@ function _flag_weights_flag($handler, $content_id, $account = NULL, $weight = 0)
 /**
  * Update the weight of an existing flagged item.
  */
-function flag_weights_set_weight($fid, $content_type, $content_id, $uid, $weight) {
-
-  db_update('flag_content')
+function flag_weights_set_weight($fid, $entity_type, $flagging_id, $uid, $weight) {
+  db_update('flagging')
   ->fields(array(
     'weight' => $weight,
   ))
   ->condition('fid', $fid)
-  ->condition('content_type', $content_type)
-  ->condition('content_id', $content_id)
+  ->condition('entity_type', $entity_type)
+  ->condition('flagging_id', $flagging_id)
   ->condition('uid', $uid)
   ->execute();
 }
@@ -179,11 +178,11 @@ function flag_weights_flag_form_submit($form, &$form_state) {
 }
 
 function _flag_weights_get_default_weight($fid) {
-  return db_query("SELECT default_weight FROM {flags} WHERE fid = :fid", array(':fid' => $fid))->fetchField();
+  return db_query("SELECT default_weight FROM {flag} WHERE fid = :fid", array(':fid' => $fid))->fetchField();
 }
 
 function _flag_weights_set_default_weight($fid, $default_weight) {
-  db_update('flags')
+  db_update('flag')
   ->fields(array(
     'default_weight' => $default_weight,
   ))
@@ -192,48 +191,46 @@ function _flag_weights_set_default_weight($fid, $default_weight) {
 }
 
 /**
- * Implements hook_flag().
+ * Implements hook_flag_flag().
  *
  * When content has been flagged, update the flag to use the default weight.
  */
-function flag_weights_flag($action, $flag, $content_id, $account) {
-  if ($action == 'flag') {
-    $default_weight = _flag_weights_get_default_weight($flag->fid);
-
-    // If the configured default weight is MIN/MAX then set it to the right int.
-    if ($default_weight == MIN_DEFAULT_WEIGHT) {
-      if ($flag->global) {
-        $found_min = db_query("SELECT min(weight) FROM {flag_content} WHERE fid = :fid", array(':fid' => $flag->fid))->fetchField();
-      }
-      else {
-        $found_min = db_query("SELECT min(weight) FROM {flag_content} WHERE fid = :fid AND uid = :uid", array(':fid' => $flag->fid, ':uid' => $account->uid))->fetchField();
-      }
-
-      if ($found_min !== FALSE && $found_min > MIN_DEFAULT_WEIGHT) {
-        $default_weight = $found_min - 1;
-      }
+function flag_weights_flag_flag($flag, $entity_id, $account, $flagging) {
+  $default_weight = _flag_weights_get_default_weight($flag->fid);
+
+  // If the configured default weight is MIN/MAX then set it to the right int.
+  if ($default_weight == MIN_DEFAULT_WEIGHT) {
+    if ($flag->global) {
+      $found_min = db_query("SELECT min(weight) FROM {flagging} WHERE fid = :fid", array(':fid' => $flag->fid))->fetchField();
     }
-    elseif ($default_weight == MAX_DEFAULT_WEIGHT) {
-      if ($flag->global) {
-        $found_max = db_query("SELECT max(weight) FROM {flag_content} WHERE fid = :fid", array(':fid' => $flag->fid))->fetchField();
-      }
-      else {
-        $found_max = db_query("SELECT max(weight) FROM {flag_content} WHERE fid = :fid AND uid = :uid", array(':fid' => $flag->fid, ':uid' => $account->uid))->fetchField();
-      }
-      if ($found_max !== FALSE && $found_max < MAX_DEFAULT_WEIGHT) {
-        $default_weight = $found_max + 1;
-      }
+    else {
+      $found_min = db_query("SELECT min(weight) FROM {flagging} WHERE fid = :fid AND uid = :uid", array(':fid' => $flag->fid, ':uid' => $account->uid))->fetchField();
     }
 
-    // Don't bother applying a weight of 0 - this is the default.
-    if ($default_weight != 0) {
-      db_update('flag_content')
-  ->fields(array(
+    if ($found_min !== FALSE && $found_min > MIN_DEFAULT_WEIGHT) {
+      $default_weight = $found_min - 1;
+    }
+  }
+  elseif ($default_weight == MAX_DEFAULT_WEIGHT) {
+    if ($flag->global) {
+      $found_max = db_query("SELECT max(weight) FROM {flagging} WHERE fid = :fid", array(':fid' => $flag->fid))->fetchField();
+    }
+    else {
+      $found_max = db_query("SELECT max(weight) FROM {flagging} WHERE fid = :fid AND uid = :uid", array(':fid' => $flag->fid, ':uid' => $account->uid))->fetchField();
+    }
+    if ($found_max !== FALSE && $found_max < MAX_DEFAULT_WEIGHT) {
+      $default_weight = $found_max + 1;
+    }
+  }
+
+  // Don't bother applying a weight of 0 - this is the default.
+  if ($default_weight != 0) {
+    db_update('flagging')
+      ->fields(array(
         'weight' => $default_weight,
       ))
-  ->condition('fid', $flag->fid)
-  ->condition('content_id', $content_id)
-  ->execute();
-    }
+      ->condition('fid', $flag->fid)
+      ->condition('entity_id', $entity_id)
+      ->execute();
   }
 }
diff --git a/handlers/draggableviews_handler_flag_weights.inc b/handlers/draggableviews_handler_flag_weights.inc
index 558232f..921429c 100644
--- a/handlers/draggableviews_handler_flag_weights.inc
+++ b/handlers/draggableviews_handler_flag_weights.inc
@@ -12,36 +12,36 @@ $plugin = array(
 	),
 );
 
-/*
-* Implementation using the Flag Weight module.
-*/
+/**
+ * Implementation using the Flag Weight module.
+ */
 class draggableviews_handler_flag_weights extends draggableviews_handler {
 	//iStryker: set the weight to node weight.  I don't know why its 'node' weight, it should be entity weight I think
-	//This will probably change when flag weight changes its naming convention 
+	//This will probably change when flag weight changes its naming convention
 	function get($field, $index) {
 		$row = $field->view->result[$index];
 		return (isset($row->flag_content_node_weight)) ? $row->flag_content_node_weight : 0;
 	}
-	
+
   function set($form_state) {
     global $user; // assume $extra['uid] = '***CURRENT_USER***'
-    
+
     $fv = $form_state['values'];
     $view = $form_state['build_info']['args'][0];
     $relationship = $view->relationship['flag_content_rel'];
     $fid = $relationship->definition['extra'][0]['value'];
     $flag = flag_get_flag($relationship->options['flag']);
-    
+
     // For global flags, use uid 0
     $uid = $flag->global ? 0 : $user->uid;
-    
+
     // Save records to our flags table.
     foreach ($fv['draggableviews'] as $item) {
     	// Make sure id is available.
     	if (!isset($item['id'])) {
     		continue;
     	}
-    	flag_weights_set_weight($fid, $flag->content_type, $item['id'], $uid, $item['weight']);
+    	flag_weights_set_weight($fid, $flag->entity_type, $item['id'], $uid, $item['weight']);
     }
   }
 }
