diff --git a/formats/xml_format.inc b/formats/xml_format.inc
index c57cec4..aa48841 100755
--- a/formats/xml_format.inc
+++ b/formats/xml_format.inc
@@ -178,8 +178,12 @@ function taxonomy_xml_xml_parse(&$data, &$vid = 0) {
   xml_set_character_data_handler($xml_parser, 'taxonomy_xml_element_data');
 
   if (!xml_parse($xml_parser, $data, 1)) {
-    watchdog('taxonomy_xml', 'Failed to parse XML file: %error at line %line.', array('%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)),  WATCHDOG_ERROR);
-    drupal_set_message(t('Failed to parse file: %error at line %line.', array('%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
+    $msg = 'Failed to parse XML file: %error at line %line.';
+    $lines = array('%error' => xml_error_string(xml_get_error_code($xml_parser)),
+		   '%line' => xml_get_current_line_number($xml_parser));
+    watchdog('taxonomy_xml', $msg, $lines, WATCHDOG_ERROR);
+    drupal_set_message(t($msg, $lines), 'error');
+    return FALSE;
   }
   xml_parser_free($xml_parser);
 
@@ -223,7 +227,7 @@ function taxonomy_xml_xml_parse(&$data, &$vid = 0) {
   // Get the maximum depth of terms
   $term_depth = array();
   foreach ($_tx_terms as $term) {
-    $term_depth[] = $term['depth'];
+    $term_depth[] = isset($term['depth']) ? $term['depth'] : 0;
   }
 
   // Import terms in order of depth, no matter what order in the file
@@ -261,8 +265,10 @@ function taxonomy_xml_xml_parse(&$data, &$vid = 0) {
               $term_exists = TRUE;
               // Map the term tid from the imported XML file to the tid in term_data database table
               $new_tid[$term_data['old_tid']] = $existing_term->tid;
-              $modified_terms[$existing_term->tid] = $existing_term;
-              $skipped_terms[$existing_term->tid] = $existing_term->name;
+	      if(array_diff_assoc($term_data, (array)$existing_term))
+		$modified_terms[$existing_term->tid] = $existing_term;
+	      else
+		$skipped_terms[$existing_term->tid] = $existing_term->name;
             }
           }
         }
@@ -370,6 +376,8 @@ function taxonomy_xml_setup_vocabulary_from_data($edit) {
   }
 
   // Ensure the merged attributes are up to date.
-  taxonomy_vocabulary_save($vocabulary /* TODO Vocabulary object replaces array $placeholder_vocabulary */);
+  if(isset($vocabulary))
+    taxonomy_vocabulary_save($vocabulary /* TODO Vocabulary object replaces array $placeholder_vocabulary */);
+
   return $placeholder_vocabulary['vid'];
 }
