--- imagefield.module.original	2008-05-12 21:02:02.000000000 -0300
+++ imagefield.module	2008-09-24 13:37:55.000000000 -0300
@@ -283,7 +283,17 @@ function imagefield_file_update($node, &
     // don't delete files if we're creating new revisions, but still return an empty
     // array...
     if ($node->old_vid || _imagefield_file_delete($file, $field['field_name'])) {
-      return array();
+      if ($field['multiple']) {
+        // If multiple, return an empty array so the file is removed from the content field table
+        $file = array();
+      } else {
+        // If not multiple, empty the array so it's updated to 0 in the main content type table
+        // If we don't do this, a reference to a non existant file (fid) will be left on the content type table.
+        foreach ($file as $key => $value) {
+          $file[$key] = '';
+        }
+      }
+      return $file;
     }
   }
   if ($file['fid'] == 'upload') {
@@ -949,6 +959,11 @@ function imagefield_field_formatter($fie
     $item = array_merge($item, _imagefield_file_load($item['fid']));
   }
 
+  // If there is no filepath at this point, do nothing.
+  if (empty($item['filepath'])) {
+    return;
+  }
+
   $parts = explode('_', $formatter);
   $style = array_pop($parts);
   $fieldtype = implode('_', $parts);
