diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index e22c8d8d359b4d64b0b18809482940ddb3224292..a6374b929bdf028da85f37ac2284e68f450e1a2c 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -134,20 +134,12 @@ function _taxonomy_confirm_del_vocabulary($vid) {
 }
 
 function taxonomy_form_term($edit = array()) {
-  $vocabulary_id = arg(3);
-
-  if (!$vocabulary_id) {
-    $vocabulary_id = $edit["vid"];
-  }
+  $vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(3);
   $vocabulary = taxonomy_get_vocabulary($vocabulary_id);
 
   $form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") . ". " . t("The name for this term.  Example: 'Linux'."));
   $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") . ". " . t("A description of the term."));
 
-  if ($vocabulary->relations) {
-    $form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") . ". ", 1, "<" . t("none") . ">", array($edit["tid"]));
-  }
-
   if ($vocabulary->hierarchy) {
     $parent = array_keys(taxonomy_get_parents($edit["tid"]));
     $children = taxonomy_get_tree($vocabulary_id, $edit["tid"]);
@@ -166,6 +158,10 @@ function taxonomy_form_term($edit = array()) {
     }
   }
 
+  if ($vocabulary->relations) {
+    $form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") . ". ", 1, "<" . t("none") . ">", array($edit["tid"]));
+  }
+
   $form .= form_textarea(t("Synonyms"), "synonyms", implode("\n", taxonomy_get_synonyms($edit["tid"])), 30, 5, t("Optional") . ". ". t(l("Synonyms", "admin/taxonomy/help#synonyms") ." of this term, one synonym per line."));
   $form .= form_weight(t("Weight"), "weight", $edit["weight"], 10, t("Optional. In listings, the heavier terms will sink and the lighter terms will be positioned nearer the top."));
   $form .= form_hidden("vid", $vocabulary->vid);
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index e22c8d8d359b4d64b0b18809482940ddb3224292..a6374b929bdf028da85f37ac2284e68f450e1a2c 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -134,20 +134,12 @@ function _taxonomy_confirm_del_vocabulary($vid) {
 }
 
 function taxonomy_form_term($edit = array()) {
-  $vocabulary_id = arg(3);
-
-  if (!$vocabulary_id) {
-    $vocabulary_id = $edit["vid"];
-  }
+  $vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(3);
   $vocabulary = taxonomy_get_vocabulary($vocabulary_id);
 
   $form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") . ". " . t("The name for this term.  Example: 'Linux'."));
   $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") . ". " . t("A description of the term."));
 
-  if ($vocabulary->relations) {
-    $form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") . ". ", 1, "<" . t("none") . ">", array($edit["tid"]));
-  }
-
   if ($vocabulary->hierarchy) {
     $parent = array_keys(taxonomy_get_parents($edit["tid"]));
     $children = taxonomy_get_tree($vocabulary_id, $edit["tid"]);
@@ -166,6 +158,10 @@ function taxonomy_form_term($edit = array()) {
     }
   }
 
+  if ($vocabulary->relations) {
+    $form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") . ". ", 1, "<" . t("none") . ">", array($edit["tid"]));
+  }
+
   $form .= form_textarea(t("Synonyms"), "synonyms", implode("\n", taxonomy_get_synonyms($edit["tid"])), 30, 5, t("Optional") . ". ". t(l("Synonyms", "admin/taxonomy/help#synonyms") ." of this term, one synonym per line."));
   $form .= form_weight(t("Weight"), "weight", $edit["weight"], 10, t("Optional. In listings, the heavier terms will sink and the lighter terms will be positioned nearer the top."));
   $form .= form_hidden("vid", $vocabulary->vid);