diff --git a/taxonomy_image.module b/taxonomy_image.module
index 4fe8ee7..201d6f7 100644
--- a/taxonomy_image.module
+++ b/taxonomy_image.module
@@ -1,4 +1,5 @@
 <?php
+// $Id: taxonomy_image.module,v 1.12.4.13.2.44 2009/04/16 13:33:35 nancyw Exp $
 
 /**
  * @file
@@ -34,7 +35,8 @@ function taxonomy_image_display($tid, $tags = NULL, $profile = NULL, $overrides
     $width = variable_get('taxonomy_image_width', '');
     $height = variable_get('taxonomy_image_height', '');
     // Any overrides specified?
-    if ($overrides) {
+    if ($overrides) 
+    {
       extract($overrides, EXTR_IF_EXISTS);
     }
 
@@ -68,7 +70,6 @@ function taxonomy_image_display($tid, $tags = NULL, $profile = NULL, $overrides
       $my_attrs = array(
         'width' => $current->width,
         'height' => $current->height,
-        'class' => 'taxonomy-image-term-' . $current->tid .' taxonomy-image-vid-' . $current->vid
         );
       // $tag was originally an HTML attribute string. It should now be a standard attributes array.
       // If the caller provided the same key, this will force me to use those.
@@ -252,9 +253,9 @@ function taxonomy_image_get_object($tid, $recursive = NULL) {
   }
 
   // If there was no image, but there is a default, fake it.
-  $term = taxonomy_get_term($tid);
   if (!isset($image[$tid]->path) && ($default = variable_get('taxonomy_image_default', NULL))) {
     $image[$tid]->path = $default;
+    $term = taxonomy_get_term($tid);
     $image[$tid]->name = $term->name;
     $image[$tid]->description = $term->description;
 //    $image[$tid]->url = file_create_url($mypath . $image[$tid]->path);
@@ -263,11 +264,10 @@ function taxonomy_image_get_object($tid, $recursive = NULL) {
   // Get more properties if we had an image.
   if (!empty($image[$tid]->path)) {
     $image[$tid]->tid = $tid;
-    $image[$tid]->vid = $term->vid;
-    $p = $fullpath . $image[$tid]->path;
-    if (is_readable($p) ) {
-      $img = getimagesize($p);
-    }
+//    $img = getimagesize($image[$tid]->path);
+    global $base_url;
+	$image[$tid]->url= $base_url . "/" . file_directory_path() .  $image[$tid]->url;
+    $img = getimagesize($image[$tid]->url);
     // Make sure it worked.
     if (!$img) {
       return NULL;
@@ -661,9 +661,7 @@ function taxonomy_image_taxonomy($op, $type, $form_values = NULL) {
       }
       break;
     case 'delete':
-      if (_taxonomy_image_exists($tid)) {
-        taxonomy_image_delete($tid);
-      }
+      taxonomy_image_delete($tid);
       break;
   }
 }
@@ -672,10 +670,10 @@ function taxonomy_image_taxonomy($op, $type, $form_values = NULL) {
  * Helper function for adding an image to a term
  */
 function taxonomy_image_add($tid, $filename) {
-  // @TODO: maybe we need to store also the FILE-ID from {files} table, better deletion and shared counts.
-  
-  // Delete old image before saving the new one.
-  if (_taxonomy_image_exists($tid)) {
+
+  $count = db_result(db_query('SELECT COUNT(tid) FROM {term_image} WHERE tid=%d', $tid));
+  if ($count == 1) {
+    // Delete old image before saving the new one.
     taxonomy_image_delete($tid);
   }
 
@@ -688,87 +686,41 @@ function taxonomy_image_add($tid, $filename) {
   }
 }
 
-/**
- * Deletes the Taxonomy Image associated with the given termid.
- * @param $tid - the id of the term to delete.
- * return none - the association is broken, the path is removed from the files table,
- *   and the image is deleted from the disk, if appropriate.
- */
 function taxonomy_image_delete($tid) {
-  $verbose = variable_get('taxonomy_image_verbose_delete', FALSE);
-  // Is there an image to delete?
-  $path = _taxonomy_image_exists($tid);
-  if (!$path) {
-    // No image, go back now.
-    return;
-  }
-
-  // See how many terms are using this image.
-  $count = db_result(db_query("SELECT COUNT(path) FROM {term_image} WHERE path='%s'", $path));
-
-  // Get the term's name.
-  $term = taxonomy_get_term($tid);
-  $term_name = check_plain(taxonomy_image_tt("taxonomy:term:$term->tid:name", $term->name));
-
-  // Break the term to image association.
-  $del_tid = db_query('DELETE FROM {term_image} WHERE tid=%d', $tid);
-  if ($del_tid) {
-    if ($verbose) {
-      drupal_set_message(t('Term image association removed for !name.', array('!name' => $term_name)), 'status');
-    }
-    // Delete the cached version.
-    cache_clear_all("taxonomy_image:$tid", 'cache_tax_image');        
-  }
-  else {
-    drupal_set_message(t('Error deleting %path for !name.', array('%path' => $path, '!name' => $term_name)), 'error');
-    // Don't delete anything else either.
-    return;
-  }
+  $old_path = db_result(db_query('SELECT path FROM {term_image} WHERE tid=%d', $tid));
+  $how_many = db_result(db_query("SELECT COUNT(path) FROM {term_image} WHERE path='%s'", $old_path));
 
-  if ($count > 1) {
-    // This file is shared, don't remove file.
-    if ($verbose) {
-      drupal_set_message(t('%path is used !count other places.', array('%path' => $full_path, '!count' => $count - 1)), 'status');
-    }
-    return;
-  }
+  // Delete the cached version.
+  cache_clear_all("taxonomy_image:$tid", 'cache_tax_image');
 
   $taxonomy_image_path = file_directory_path() .'/'. variable_get('taxonomy_image_path', 'category_pictures') .'/';
-  $full_path = $taxonomy_image_path . $path;
- 
-  // This is the only term using this file, so it is safe to delete it
-  // The physical file will be deleted only if also removed from {files} table.
-  $file_del = db_query("DELETE FROM {files} WHERE filepath='%s'", $full_path);
-  if ($file_del) {
-    if ($verbose) {
-      drupal_set_message(t('%path deleted from database.', array('%path' => $full_path)), 'status');
-    }
+  $full_path = $taxonomy_image_path . $old_path;
+  if ($how_many == 1) {
+    // This is the only term using this file, so it is safe to delete it.
+    $file_del_ok = db_query("DELETE FROM {files} WHERE filepath='%s'", $full_path);
   }
   else {
-    drupal_set_message(t('Error deleting image %path.', array('%path' => $full_path)), 'error');
-    // Don't even try to delete from disk.
-    return;
+    // Pretend we deleted it.
+    $file_del_ok = TRUE;
+    drupal_set_message(t('Not deleted from the files table because it is use on !count other terms.', array('!count' => $how_many - 1)));
   }
 
-  $phys_del = file_delete($full_path);
-  if ($phys_del) {
-    if ($verbose) {
-      drupal_set_message(t('%path deleted from disk.', array('%path' => $full_path)), 'status');
-    }
+  $db_del_ok = db_query('DELETE FROM {term_image} WHERE tid=%d', $tid);
+  if ($file_del_ok && $db_del_ok) {
+    drupal_set_message(t('!name image removed.', array('!name' => $old_path)));
   }
   else {
-    drupal_set_message(t('Error deleting image file %path from disk.', array('%path' => $full_path)), 'warning');
+    drupal_set_message(t('Image delete failed. File: !file, Db: !db.',
+      array('!file' => ($file_del_ok ? 'yes' : 'no'), '!db' => ($db_del_ok ? 'yes' : 'no'))));
   }
+  return;
 }
 
-/**
- * Check if the given TID has an image associated.
- *
- * @param $tid: Term-ID to check
- * @return the image filename or FALSE
- */
 function _taxonomy_image_exists($tid) {
-  return db_result(db_query("SELECT path FROM {term_image} WHERE tid=%d", $tid));
+  if (db_fetch_object(db_query('SELECT path FROM {term_image} WHERE tid=%d', $tid))) {
+    return TRUE;
+  }
+  return FALSE;
 }
 
 /**
