diff --git a/taxonomy_title.module b/taxonomy_title.module
old mode 100644
new mode 100755
index 7d2ee65..9de2f5a
--- a/taxonomy_title.module
+++ b/taxonomy_title.module
@@ -40,6 +40,11 @@ function taxonomy_title_form_taxonomy_form_term_alter(&$form, &$form_state) {
       '#description' => t('This is the title you will see in the heading tag on your taxonomy term page. If left blank, the term name will be used.'),
       '#weight' => 0,
       );
+
+    $form['identification']['taxonomy_title_set'] = array(
+      '#type' => 'value',
+      '#value' => $title !== FALSE ? TRUE : FALSE
+    );
   }
 }
 
@@ -54,8 +59,13 @@ function taxonomy_title_taxonomy_term_delete($op, $type, $array = NULL) {
  * Implements hook_taxonomy_term_update().
  */
 function taxonomy_title_taxonomy_term_update($term) {
+  if ( !empty($term->taxonomy_title) ){
+    _taxonomy_title_update($term->tid, $term->taxonomy_title);
+  }
+
+  if ( $term->taxonomy_title_set === TRUE && empty($term->taxonomy_title) ){
   _taxonomy_title_delete_title($term->tid);
-  _taxonomy_title_insert_title($term->tid, $term->taxonomy_title);
+  }
 }
 
 /**
@@ -152,11 +162,18 @@ function _taxonomy_title_insert_title($tid, $title) {
  *   The taxonomy term title to use for this term.
  */
 function _taxonomy_title_update($tid, $title) {
-  if (db_result(db_query("SELECT title FROM {taxonomy_title} WHERE tid = %d", $tid))) {
-    db_query("UPDATE {taxonomy_title} SET title = '%s' WHERE tid = %d", $title, $tid);     
+  $old_title = _taxonomy_title_get_title($tid);
+
+  if ( $old_title !== FALSE ) {
+    db_update('taxonomy_title')
+      ->fields(array(
+        'title' => $title
+      ))
+      ->condition('tid',$tid,'=')
+      ->execute();
   }
   else {
-    db_query("INSERT INTO {taxonomy_title} (tid, title) VALUES (%d, '%s')", $tid, $title);
+    _taxonomy_title_insert_title($tid, $title);
   }
   // Add Suppot for i18nstrings.
   if (function_exists('i18nstrings_update')) {
