--- subdomain.module	2008-06-12 23:07:43.000000000 -0500
+++ subdomain.module	2008-08-05 08:40:16.000000000 -0500
@@ -147,10 +147,13 @@ function subdomain_token_values($type, $
 
         case SUBDOMAIN_VOCAB:
           $vocab = variable_get('subdomain_vocab', NULL);
-          if (is_array($object->taxonomy) && in_array($vocab, array_keys($object->taxonomy))) {
-            if ($tid = is_array($object->taxonomy[$vocab]) ? array_shift($object->taxonomy[$vocab]) : $object->taxonomy[$vocab]) {
-              $term_name = db_result(db_query("SELECT name FROM {term_data} WHERE tid = %d", $tid));
-              $values['subdomain'] = subdomain_build_token($term_name, $tid);
+          if (is_array($object->taxonomy)) {
+            foreach ($object->taxonomy as $tid) {
+              $term_name = db_result(db_query("SELECT name FROM {term_data} WHERE tid = %d AND vid = %d", $tid, $vocab));
+              if ($term_name) {
+            	$values['subdomain'] = subdomain_build_token($term_name, $tid);
+            	break;
+              }
             }
           }
           break;
@@ -158,8 +161,12 @@ function subdomain_token_values($type, $
       break;
 
     case 'taxonomy':
+      $vocab = variable_get('subdomain_vocab', NULL);
       if (variable_get('subdomain_type', SUBDOMAIN_USER) == SUBDOMAIN_VOCAB) {
-        $values['subdomain'] = subdomain_build_token($object->name, $object->tid);
+        $term_name = db_result(db_query("SELECT name FROM {term_data} WHERE tid = %d AND vid = %d", $object->tid, $vocab));
+        
+        if ($term_name)
+          $values['subdomain'] = subdomain_build_token($object->name, $object->tid);
       }
       break;
     case 'user':
@@ -184,9 +191,7 @@ function subdomain_admin_settings() {
     $vocabs = taxonomy_get_vocabularies();
     if (is_array($vocabs) && count($vocabs)) {
       foreach ($vocabs as $vocab) {
-        if (!$vocab->hierarchy) {
-          $vocab_options[$vocab->vid] = $vocab->name;
-        }
+        $vocab_options[$vocab->vid] = $vocab->name;
       }
       if (is_array($vocab_options)) {
         $options[SUBDOMAIN_VOCAB] = 'Taxonomy Vocabulary and associated content';        
