diff --git a/metatag.install b/metatag.install
index f1ee370..70c8723 100644
--- a/metatag.install
+++ b/metatag.install
@@ -317,34 +317,64 @@ function metatag_update_7006() {
  * of Metatag may have failed to purge these.
  */
 function metatag_update_7007() {
-  $result = db_query("DELETE m
+  $nodes = db_query("SELECT m.entity_id
     FROM {metatag} m
     LEFT OUTER JOIN {node} n
-    	ON m.entity_id=n.nid
+      ON m.entity_id=n.nid
     WHERE m.entity_type='node'
-    	AND n.nid IS NULL");
-  if ($result->rowCount() > 0) {
-    drupal_set_message(t('Removed @count meta tag record(s) for nodes that had been purged.', array('@count' => $result->rowCount())));
+      AND n.nid IS NULL")
+    ->fetchCol();
+  if (count($nodes) > 0) {
+    $deleted = db_delete('metatag')
+      ->condition('entity_type', 'node')
+      ->condition('entity_id', $nodes)
+      ->execute();
+    if ($deleted > 0) {
+      drupal_set_message(t('Removed @count meta tag record(s) for nodes that had been purged.', array('@count' => $deleted)));
+    }
+    else {
+      drupal_set_message(t('There were no meta tag records to purge for removed nodes. This is a good thing :)'));
+    }
   }
 
-  $result = db_query("DELETE m
+  $users = db_query("SELECT m.entity_id
     FROM {metatag} m
     LEFT OUTER JOIN {users} u
-    	ON m.entity_id=u.uid
+      ON m.entity_id=u.uid
     WHERE m.entity_type='user'
-    	AND u.uid IS NULL");
-  if ($result->rowCount() > 0) {
-    drupal_set_message(t('Removed @count meta tag record(s) for users that had been purged.', array('@count' => $result->rowCount())));
+      AND u.uid IS NULL")
+    ->fetchCol();
+  if (count($users) > 0) {
+    $deleted = db_delete('metatag')
+      ->condition('entity_type', 'user')
+      ->condition('entity_id', $users)
+      ->execute();
+    if ($deleted > 0) {
+      drupal_set_message(t('Removed @count meta tag record(s) for users that had been purged.', array('@count' => $deleted)));
+    }
+    else {
+      drupal_set_message(t('There were no meta tag records to purge for removed users. This is a good thing :)'));
+    }
   }
 
-  $result = db_query("DELETE m
+  $terms = db_query("SELECT m.entity_id
     FROM {metatag} m
     LEFT OUTER JOIN {taxonomy_term_data} t
-    	ON m.entity_id=t.tid
+      ON m.entity_id=t.tid
     WHERE m.entity_type='taxonomy_term'
-    	AND t.tid IS NULL");
-  if ($result->rowCount() > 0) {
-    drupal_set_message(t('Removed @count meta tag record(s) for taxonomy terms that had been purged.', array('@count' => $result->rowCount())));
+      AND t.tid IS NULL")
+    ->fetchCol();
+  if (count($terms) > 0) {
+    $deleted = db_delete('metatag')
+      ->condition('entity_type', 'taxonomy_term')
+      ->condition('entity_id', $terms)
+      ->execute();
+    if ($deleted > 0) {
+      drupal_set_message(t('Removed @count meta tag record(s) for taxonomy terms that had been purged.', array('@count' => $deleted)));
+    }
+    else {
+      drupal_set_message(t('There were no meta tag records to purge for removed taxonomy terms. This is a good thing :)'));
+    }
   }
 }
 
@@ -352,7 +382,7 @@ function metatag_update_7007() {
  * Remove any empty records that may be hanging around from old releases.
  */
 function metatag_update_7008() {
-  $result = db_query("DELETE m FROM {metatag} m WHERE m.data IS NULL or m.data = '' OR m.data = :empty", array(':empty' => serialize(array())));
+  $result = db_query("DELETE FROM {metatag} m WHERE m.data IS NULL OR m.data = '' OR m.data = :empty", array(':empty' => serialize(array())));
   if ($result->rowCount() > 0) {
     drupal_set_message(t('Purged @count empty meta tag record(s).', array('@count' => $result->rowCount())));
   }
