diff --git a/location_taxonomize.admin.inc b/location_taxonomize.admin.inc
index bd4bd37..3b90e31 100644
--- a/location_taxonomize.admin.inc
+++ b/location_taxonomize.admin.inc
@@ -43,7 +43,7 @@ function location_taxonomize_form($form, &$form_state) {
     $form['location_taxonomize_vocab']['#collapsed'] = TRUE;
     unset($form['location_taxonomize_vocab']['#description']);
   }
-  
+
   // hidden form element used to indicate if LT is initialized already or not
   $form['location_taxonomize_vocab']['state'] = array(
     '#type' => 'hidden',
@@ -53,7 +53,7 @@ function location_taxonomize_form($form, &$form_state) {
   } else {
     $form['location_taxonomize_vocab']['state']['#value'] = 'initialization';
   }
-  
+
   // display the status of the current Location Taxonomy, if initialized
   if ($initialized) {
     $form['location_taxonomize_vocab']['vid'] = array(
@@ -65,7 +65,7 @@ function location_taxonomize_form($form, &$form_state) {
                           the vocabulary first, using the button below.')
     );
   }
-  
+
   // Source selection
   $source_options = location_taxonomize_get_sources();
   $form['location_taxonomize_vocab']['source'] = array(
@@ -93,7 +93,7 @@ function location_taxonomize_form($form, &$form_state) {
   if ($initialized) {
     $form['location_taxonomize_vocab']['source']['#disabled'] = TRUE;
   }
-  
+
   // Choose initialization method, if we have not initialized
   if(!$initialized) {
     // check if there is already a Location vocab we could use
@@ -159,7 +159,7 @@ function location_taxonomize_form($form, &$form_state) {
     $form['location_taxonomize_vocab']['hierarchy']['#disabled'] = TRUE;
     $form['location_taxonomize_vocab']['hierarchy']['#default_value'] = $opts_vocab['hierarchy'];
   }
-  
+
   // Stop the form here if we have not yet initialized
   if (!$initialized) {
     $form = system_settings_form($form);
@@ -167,11 +167,11 @@ function location_taxonomize_form($form, &$form_state) {
     $form['#submit'][] = 'location_taxonomize_initialize';
     return $form;
   }
-  
+
   /*************************************************
    * Initialization ends here
    ************************************************/
-   
+
   // determine whether the hierarchy configuration includes a province field
   $hierarchy = _location_taxonomize_get_hierarchy();
   $province_field_name = location_taxonomize_source_field_name('province');
@@ -179,7 +179,7 @@ function location_taxonomize_form($form, &$form_state) {
   // determine whether the hierarchy configuration includes a country field
   $country_field_name = location_taxonomize_source_field_name('country');
   $has_country_field = in_array($country_field_name, $hierarchy);
-    
+
   // operations fieldset
   $form['location_taxonomize_ops'] = array(
     '#type' => 'fieldset',
@@ -197,7 +197,7 @@ function location_taxonomize_form($form, &$form_state) {
       process all locations that have been saved on this site by the Location module
       and add them to the Location Vocabulary</li></ul>'),
   );
-  
+
   // button to empty the location vocabulary
   $form['location_taxonomize_ops']['emptyvocab'] = array(
     '#type' => 'button',
@@ -210,30 +210,30 @@ function location_taxonomize_form($form, &$form_state) {
       'event' => 'mousedown',
     ),
   );
-  
+
   // disassociate button
   $form['location_taxonomize_ops']['disassociate'] = array(
     '#type' => 'submit',
     '#value' => t('Disassociate Vocab'),
     '#submit' => array('location_taxonomize_disassociate', ),
   );
-  
+
   // bulk taxonomize button
   $form['location_taxonomize_ops']['bulk_taxonomize'] = array(
     '#type' => 'submit',
     '#value' => t('Bulk Taxonomize Locations'),
     '#submit' => array('location_taxonomize_bulk_taxonomize', ),
   );
-  
+
   // placeholder div for ajax message
   $form['location_taxonomize_ops']['msg-div'] = array(
     '#type' => 'container',
     '#id' => 'msg-div',
   );
-  
+
   // get settings variables
   $opts_settings = variable_get('location_taxonomize_settings');
-  
+
   // settings fieldset
   $form['location_taxonomize_settings'] = array(
     '#type' => 'fieldset',
@@ -242,7 +242,7 @@ function location_taxonomize_form($form, &$form_state) {
     '#collapsed' => FALSE,
     '#tree' => TRUE,
   );
-  
+
   // option to enable or disable synchronization
   $form['location_taxonomize_settings']['enable'] = array(
     '#type' => 'checkbox',
@@ -250,15 +250,15 @@ function location_taxonomize_form($form, &$form_state) {
     '#default_value' => $opts_settings['enable'],
     '#description' => t("Turn on or off the main functionality of this module. You can achieve the same functiuonality without this checked using the 'Bulk Taxonomize' Feature"),
   );
-  
+
   // Term Attach feature
   $form['location_taxonomize_settings']['term_attach'] = array(
     '#type'         => 'checkbox',
-    '#title'        => t('Also attach Location Taxonomy terms to nodes with those locations'),
+    '#title'        => t('Also attach Location Taxonomy terms to entities with those locations'),
     '#default_value'  => $opts_settings['term_attach'],
     '#description'    => t("In order for this to work you must add a field of type Term Reference with the name 'location_taxonomize_terms' to all node types you wish to attach terms to. If this field allows only one value, only the 'lowest' term in the hierarchy will be attached. If you want all terms to attach, set the field to allow multiple values."),
   );
-  
+
   // options for hiding the term references field
   $form['location_taxonomize_settings']['hide_terms_field'] = array(
     '#type'         => 'checkbox',
@@ -266,7 +266,7 @@ function location_taxonomize_form($form, &$form_state) {
     '#default_value'  => $opts_settings['hide_terms_field'],
     '#description'    => t("This is useful if you want the terms to only be attached by Location Taxonomize. Otherwise users could select terms which don't actually correspond to entered locations."),
   );
-  
+
   // naming fieldset
   $form['location_taxonomize_settings']['naming'] = array(
     '#type'         => 'fieldset',
@@ -277,7 +277,7 @@ function location_taxonomize_form($form, &$form_state) {
     '#description' => t('Change the way Location terms are named in the
                         Location Vocabulary.'),
   );
-  
+
   $form['location_taxonomize_settings']['naming']['country'] = array(
     '#type'       => 'radios',
     '#title'      => t('Country naming'),
@@ -288,7 +288,7 @@ function location_taxonomize_form($form, &$form_state) {
     ),
     '#default_value' => $opts_settings['naming']['country'],
   );
-  
+
   $form['location_taxonomize_settings']['naming']['usa'] = array(
     '#type'       => 'checkbox',
     '#title'      => t("Use 'USA' instead of 'US'"),
@@ -299,14 +299,14 @@ function location_taxonomize_form($form, &$form_state) {
       ),
     ),
   );
-  
+
   // disable country naming if there is no province field
   if (!$has_country_field) {
     $form['location_taxonomize_settings']['naming']['country']['#disabled'] = TRUE;
     $form['location_taxonomize_settings']['naming']['usa']['#disabled'] = TRUE;
     $form['location_taxonomize_settings']['naming']['country']['#description'] = t('These options are disabled because no Country field is included in your hierarchy');
   }
-  
+
   $form['location_taxonomize_settings']['naming']['province'] = array(
     '#type'       => 'radios',
     '#title'      => t('Province naming'),
@@ -317,13 +317,13 @@ function location_taxonomize_form($form, &$form_state) {
     ),
     '#default_value' => $opts_settings['naming']['province'],
   );
-  
+
   // disable province naming if there is no province field
   if (!$has_province_field) {
     $form['location_taxonomize_settings']['naming']['province']['#disabled'] = TRUE;
     $form['location_taxonomize_settings']['naming']['province']['#description'] = t('These options are disabled because no Province field is included in your hierarchy');
   }
-  
+
   // text to use if there is no value to save for a term
   $form['location_taxonomize_settings']['na_text'] = array(
     '#type'           => 'textfield',
@@ -337,7 +337,7 @@ function location_taxonomize_form($form, &$form_state) {
     '#default_value'  => $opts_settings['na_text'],
     '#required'       => 1,
   );
-  
+
   // option to enable or disable the Full Name field
   $form['location_taxonomize_settings']['longname_enable'] = array(
     '#type' => 'checkbox',
@@ -345,7 +345,7 @@ function location_taxonomize_form($form, &$form_state) {
     '#description' => t('e.g. San Francisco, CA, USA'),
     '#default_value' => $opts_settings['longname_enable'],
   );
-  
+
   $longname_opts = $opts_settings['longname'];
   // Long Name fieldset
   $form['location_taxonomize_settings']['longname'] = array(
@@ -379,7 +379,7 @@ function location_taxonomize_form($form, &$form_state) {
     '#options' => _location_taxonomize_get_hierarchy(TRUE, TRUE),
     '#default_value' => $longname_opts['fields'],
   );
-  
+
   $form['location_taxonomize_settings']['longname']['separator'] = array(
     '#type' => 'textfield',
     '#title' => t('Separator'),
@@ -394,7 +394,7 @@ function location_taxonomize_form($form, &$form_state) {
       ),
     ),
   );
-  
+
   $form['location_taxonomize_settings']['longname']['country_naming'] = array(
     '#type' => 'radios',
     '#title' => t('Country naming in Long Names'),
@@ -406,13 +406,13 @@ function location_taxonomize_form($form, &$form_state) {
     ),
     '#default_value' => $longname_opts['country_naming'],
   );
-  
+
   // disable country naming field if province is not included in hierarchy
   if (!$has_country_field) {
     $form['location_taxonomize_settings']['longname']['country_naming']['#disabled'] = TRUE;
     $form['location_taxonomize_settings']['longname']['country_naming']['#description'] = t('These options are disabled because no Country field is included in your hierarchy');
   }
-  
+
   $form['location_taxonomize_settings']['longname']['usa'] = array(
     '#type' => 'checkbox',
     '#title' => t("Use 'USA' instead of 'US'"),
@@ -424,7 +424,7 @@ function location_taxonomize_form($form, &$form_state) {
       ),
     ),
   );
-  
+
   $form['location_taxonomize_settings']['longname']['province_naming'] = array(
     '#type' => 'radios',
     '#title' => t('Province naming in Long Names'),
@@ -448,9 +448,9 @@ function location_taxonomize_form($form, &$form_state) {
     '#title' => t('Show confirmation messages when taxonomizing'),
     '#default_value' => variable_get('location_taxonomize_show_messages', 1),
     '#description' => t('Uncheck this to turn off messages that are shown when locations are taxonomized and terms are saved, like "X terms saved to the location vocabulary."'),
-    
+
   );
-  
+
   return system_settings_form($form);
 }
 
@@ -493,7 +493,7 @@ function location_taxonomize_form_validate($form, &$form_state) {
       $separator_empty = empty($form_state['values']['location_taxonomize_settings']['longname']['separator']);
       if ($longname_enabled && $separator_empty) {
         form_set_error(
-          'location_taxonomize_settings][longname][separator', 
+          'location_taxonomize_settings][longname][separator',
           t('Separator field is required.')
         );
       }
diff --git a/location_taxonomize.inc b/location_taxonomize.inc
index 7e4e25c..d684d49 100644
--- a/location_taxonomize.inc
+++ b/location_taxonomize.inc
@@ -78,7 +78,7 @@ function location_taxonomize_empty_vocab() {
  * @param $assoc - whether to return an associative array (TRUE) or
  *                keyed array (FALSE)
  * @param $labels - if TRUE and $assoc is TRUE, returns the labels
- *                  of the fields as the array values 
+ *                  of the fields as the array values
  */
 function _location_taxonomize_get_hierarchy($assoc = FALSE, $labels = FALSE) {
   $settings = variable_get('location_taxonomize_vocab');
@@ -122,7 +122,7 @@ function _location_taxonomize_init_var_longname() {
 function location_taxonomize_get_sources() {
   // Get source modules
   $possibilities = module_invoke_all('location_taxonomize_source');
-  
+
   $available = array();
   foreach ($possibilities as $module => $name) {
     if (module_exists($module)) {
@@ -180,18 +180,24 @@ function _location_taxonomize_get_fields($assoc = TRUE, $labels = FALSE, $source
 }
 
 /**
- * Checks the given form to make sure that the term attach field exists and is 
+ * Checks the given form to make sure that the term attach field exists and is
  * set up correctly
  */
 function location_taxonomize_term_attach_check_field($form) {
   $field_name = 'field_' . LT_TERM_ATTACH_FIELD;
-  // make sure that a field by this name exists
-  if (!isset($form[$field_name])) return FALSE;
-  // make sure that this field has the right settings
+  // Make sure that a field by this name exists.
+  if (!isset($form[$field_name]) || !is_array(field_info_field($field_name))) {
+    return FALSE;
+  }
+  // Make sure that this field has the right settings.
   $field_info = field_info_field($field_name);
-  if ($field_info['deleted'] == 1) return FALSE;
+  if ($field_info['deleted'] == 1) {
+    return FALSE;
+  }
   if ($field_info['type'] != 'taxonomy_term_reference') return FALSE;
-  if ($field_info['settings']['allowed_values'][0]['vocabulary'] != LT_MODULE_ID) return FALSE;
+  if ($field_info['settings']['allowed_values'][0]['vocabulary'] != LT_MODULE_ID) {
+    return FALSE;
+  }
   return $field_name;
 }
 
@@ -230,7 +236,7 @@ function location_taxonomize_source_default_set($module) {
 }
 
 /**
- * Some fields are defined as 'Primary Fields'. 
+ * Some fields are defined as 'Primary Fields'.
  * This function returns an array mapping internal field names
  * to source field names, or the other direction, if $reverse is TRUE
  */
@@ -269,7 +275,7 @@ function location_taxonomize_convert_field_name($name) {
   return $name;
 }
 
-/** 
+/**
  * Converts an internal name to a source name
  */
 function location_taxonomize_source_field_name($internal_name) {
diff --git a/location_taxonomize.module b/location_taxonomize.module
index 3d1bd0f..2bbb45e 100644
--- a/location_taxonomize.module
+++ b/location_taxonomize.module
@@ -79,14 +79,14 @@ function location_taxonomize_initialize($form, $form_state) {
       taxonomy_vocabulary_save((object) array(
         'name' => t('Location'),
         'machine_name' => LT_VOCAB_NAME,
-        'description' => t('This vocabulary is synchronized with Location data automatically by the @name module', 
+        'description' => t('This vocabulary is synchronized with Location data automatically by the @name module',
                          array('@name' => LT_MODULE_NAME)),
       ));
       // save the vid of the newly created vocabulary
       $vocab = taxonomy_vocabulary_machine_name_load(LT_VOCAB_NAME);
       $vid = $vocab->vid;
       variable_set('location_taxonomize_vid', $vid);
-      $msg = t('Successfully created the Location taxonomy (vid @vid)', 
+      $msg = t('Successfully created the Location taxonomy (vid @vid)',
               array('@vid' => $vid));
       break;
     case 'existing':
@@ -151,18 +151,23 @@ function location_taxonomize_taxonomize($items, $form, &$form_state) {
   return array("saved" => $saved, "tids" => $tids);
 }
 
-function location_taxonomize_taxonomize_bulk($items) {
+/**
+ * Bulk process locations for their attached entities.
+ */
+function location_taxonomize_taxonomize_bulk($entity_items) {
   $saved = 0;
-  foreach ($items as $nid => $items) {
-    $tids = array();
-    foreach ($items as $item) {
-      $results = location_taxonomize_process_item($item);
-      $saved += $results['saved'];
-      $tids = array_merge($tids, $results['tids']);
-    }
-    if (!empty($tids)) {
-      if (location_taxonomize_term_attach_enabled()) {
-        location_taxonomize_term_attach_bulk($tids, $nid);
+  foreach ($entity_items as $entity_id => $entity_type_items) {
+    foreach ($entity_type_items as $entity_type => $items) {
+      $tids = array();
+      foreach ($items as $item) {
+        $results = location_taxonomize_process_item($item);
+        $saved += $results['saved'];
+        $tids = array_merge($tids, $results['tids']);
+      }
+      if (!empty($tids)) {
+        if (location_taxonomize_term_attach_enabled()) {
+          location_taxonomize_term_attach_bulk($tids, $entity_id, $entity_type);
+        }
       }
     }
   }
@@ -170,12 +175,12 @@ function location_taxonomize_taxonomize_bulk($items) {
 }
 
 /**
- * Determines if a location needs to be taxonomized. 
+ * Determines if a location needs to be taxonomized.
  * If so, it saves the appropriate terms
  * Returns an array containing two items: the first is the number of new terms
  * saved, and the second is an array of all the terms that correspond to this
  * object, including ones that were added and ones that already existed
- * @param $obj - a location object
+ * @param $obj - a location array
  */
 function location_taxonomize_process_item($obj) {
   // make sure we are enabled
@@ -195,12 +200,17 @@ function location_taxonomize_process_item($obj) {
     if ($longname_main) {
       $name = location_taxonomize_make_longname($hlevel, $obj);
       $longname = $name;
-    } else {
+    }
+    else {
       $name = _location_taxonomize_create_term_name($hlevel_name, $obj, $settings);
     }
     // find if the term exists already or not
-    if ($hlevel == 0) $parentid = -1;
-    else $parentid = $tids[$hlevel-1];
+    if ($hlevel == 0) {
+      $parentid = -1;
+    }
+    else {
+      $parentid = $tids[$hlevel-1];
+    }
     $findterm = _find_term($name, $hlevel, $parentid);
     // save if necessary
     if (!$findterm) {
@@ -210,7 +220,7 @@ function location_taxonomize_process_item($obj) {
       );
       // add longname if necessary
       if ($settings['longname_enable'] && !$longname_main) {
-          _location_taxonomy_add_longname($term, $hlevel, $obj);
+        _location_taxonomy_add_longname($term, $hlevel, $obj);
       }
       // set term parent
       if ($hlevel == 0) {
@@ -223,7 +233,9 @@ function location_taxonomize_process_item($obj) {
       $tids[] = $term->tid;
       $saved++;
     }
-    elseif ($findterm->tid) $tids[] = $findterm->tid;
+    elseif ($findterm->tid) {
+      $tids[] = $findterm->tid;
+    }
   }
   return array('saved' => $saved, 'tids' => $tids);
 }
@@ -246,8 +258,14 @@ function _find_term($name, $hlevel, $parentid) {
     if (empty($parents) && $parentid == -1) {
       $withparent[] = $term;
     }
-    // for all other terms (one parent is assumed):
-    elseif (array_pop($parents)->tid == $parentid) $withparent[] = $term;
+    // For all other terms (one parent is assumed).
+    else {
+      $parent = array_pop($parents);
+      // Make sure we actually had a parent before comparing.
+      if (!empty($parent->tid) && $parent->tid == $parentid) {
+        $withparent[] = $term;
+      }
+    }
   }
   // there is one term that matches exactly
   if (count($withparent) == 1) {
@@ -385,48 +403,59 @@ function _location_taxonomize_create_term_name($hlevel_name, &$location, &$setti
   * Attaches the given tids to the node form given in form_state if they need to
   * be attached
   * Note that all it does is remove the old numbers and add the new ones. It's
-  * faster than checking which ones are missing and adding. Also ensures that 
+  * faster than checking which ones are missing and adding. Also ensures that
   * only the terms that are relevant are getting saved.
   */
 function location_taxonomize_term_attach($tids, $form, &$form_state) {
   $lang = 'und';
-  
+
   // check that the field exists and is set up correctly
   $field = location_taxonomize_term_attach_check_field($form);
   if ($field == FALSE) {
-    drupal_set_message(t('Location Taxonomize could not attach the terms to the node because the Taxonomy Reference field is not set up correctly'), 'warning');
+    drupal_set_message(t('Location Taxonomize could not attach the terms to the entity because the Taxonomy Reference field is not set up correctly'), 'warning');
     return;
   }
 
-  // empty the currently set values
-  $form_state['values'][$field][$lang] = array();
-  
   // Reverse the order to assign the lowest term in the hierarchy first
   $tids = array_reverse($tids);
-  
-  // add the values
+  // Add the values
   $tids = array_unique($tids);
+
+  // Set the generated tids as the field value.
+  // Check if we're working with profiles.
+  if (!empty($form_state['profiles'])) {
+    foreach ($form_state['profiles'] as $type => $profile) {
+      if (!empty($form_state['values']['profile_' . $profile->type][$field][$lang])) {
+        $values =& $form_state['values']['profile_' . $profile->type];
+        break;
+      }
+    }
+  }
+  else {
+    $values =& $form_state['values'];
+  }
+
+  $values[$field][$lang] = array();
   foreach ($tids as $tid) {
-    $form_state['values'][$field][$lang][]['tid'] = $tid;
+    $values[$field][$lang][]['tid'] = $tid;
   }
 }
 
-function location_taxonomize_term_attach_bulk($tids, $nid) {
-  $langcode = 'und';
-  // load the node
-  $node = node_load($nid);
-  if (!isset($node->field_location_taxonomize_terms)) return;
-  
+function location_taxonomize_term_attach_bulk($tids, $entity_id, $entity_type) {
+  $langcode = LANGUAGE_NONE;
+  // Load the entity.
+  $entity = entity_load_single($entity_type, $entity_id);
+  if (!isset($entity->field_location_taxonomize_terms)) return;
+
   // Reverse the order to assign the lowest term in the hierarchy first
   $tids = array_reverse($tids);
-  
   $tids = array_unique($tids);
   $save = array();
   foreach ($tids as $tid) {
     $save[$langcode][]['tid'] = $tid;
   }
-  $node->field_location_taxonomize_terms = $save;
-  node_save($node);
+  $entity->field_location_taxonomize_terms = $save;
+  entity_save($entity_type, $entity);
 }
 
 ////////////////////////////////////////
diff --git a/location_taxonomize_af/location_taxonomize_af.module b/location_taxonomize_af/location_taxonomize_af.module
index d9b262a..45524ca 100644
--- a/location_taxonomize_af/location_taxonomize_af.module
+++ b/location_taxonomize_af/location_taxonomize_af.module
@@ -3,7 +3,7 @@
 /**
  * @file
  * This is a 'source module' that adds a data source for the Location Taoxnomize
- * module. It implements the Location Taxonomize functionality for the 
+ * module. It implements the Location Taxonomize functionality for the
  * Address Field module.
  */
 
@@ -14,7 +14,7 @@ require_once('location_taxonomize_af.inc');
  */
 function location_taxonomize_af_location_taxonomize_source() {
   return array(
-   'location_taxonomize_af' => 'Address Field', 
+   'location_taxonomize_af' => 'Address Field',
   );
 }
 
@@ -44,7 +44,7 @@ function location_taxonomize_af_field_widget_info_alter(&$info) {
  * Implements hook_form_field_ui_field_edit_form_alter().
  * Here we add a form element on the addressfield widget settings form
  * to allow users to configure whether this field will be taxonomized
- * 
+ *
  */
 function location_taxonomize_af_form_field_ui_field_edit_form_alter(&$form, $form_state, $form_id) {
   if ($form['#field']['type'] != 'addressfield') return;
@@ -64,8 +64,7 @@ function location_taxonomize_af_form_field_ui_field_edit_form_alter(&$form, $for
 function location_taxonomize_af_field_widget_addressfield_standard_form_alter(&$element, &$form_state, $context) {
   // check if this module is enabled as the current source
   if (_location_taxonomize_get_source() != LT_AF_MODULE_ID) return;
-  // apply this only if we are on a node-edit form
-  if (!isset($context['form']['#node_edit_form'])) return;
+
   // check field settings
   $taxonomize = $context['instance']['widget']['settings']['location_taxonomize'];
   // add a process function to addressfield widgets
@@ -86,7 +85,7 @@ function location_taxonomize_af_process_address($element, &$form_state, &$form)
   if (!in_array('location_taxonomize_af_element_submitted', $form['#submit'])) {
     array_unshift($form['#submit'], 'location_taxonomize_af_element_submitted');
   }
-  
+
   // make note that this field needs to be processed in the submit handler
   if (!isset($form_state['temporary']['addressfields']) || !in_array($element['#field_name'], $form_state['temporary']['addressfields'])) {
     $form_state['temporary']['addressfields'][] = $element['#field_name'];
@@ -103,18 +102,38 @@ function location_taxonomize_af_element_submitted($form, &$form_state) {
   $fields = $form_state['temporary']['addressfields'];
   $items = array();
   foreach ($fields as $field) {
-    $deltas = $form_state['values'][$field][$lang];
-    $actual_delta = 0;
-    foreach ($deltas as $delta) {
-       // Add the Administrative Area name, if possible
-       if(isset($form[$field][$lang][$actual_delta]['locality_block']['administrative_area']['#options'])) {
-         $options = $form[$field][$lang][$actual_delta]['locality_block']['administrative_area']['#options'];
-         $delta['administrative_area_name'] = $options[$delta['administrative_area']];
-       }
-      // Add the country name
-      $delta['country_name'] = location_taxonomize_get_country_name($delta['country']);
-      $items[] = $delta;
-      $actual_delta++;
+    // Check if we're working with profiles.
+    if (!empty($form_state['profiles'])) {
+      foreach ($form_state['profiles'] as $type => $profile) {
+        $deltas = $form_state['values']['profile_' . $profile->type][$field][$lang];
+      }
+    }
+    else {
+      $deltas = $form_state['values'][$field][$lang];
+    }
+
+    foreach ($deltas as $delta => $values) {
+      // Don't process 'add more'.
+      if (is_numeric($delta)) {
+        // Add the Administrative Area name, if possible.
+        if (!empty($form_state['profiles'])) {
+          foreach ($form_state['profiles'] as $type => $profile) {
+            if (isset($form['profile_' . $profile->type][$field][$lang][$delta]['locality_block']['administrative_area']['#options'])) {
+              $options = $form['profile_' . $profile->type][$field][$lang][$delta]['locality_block']['administrative_area']['#options'];
+              $values['administrative_area_name'] = $options[$values['administrative_area']];
+            }
+          }
+        }
+        else {
+          if (isset($form[$field][$lang][$delta]['locality_block']['administrative_area']['#options'])) {
+            $options = $form[$field][$lang][$delta]['locality_block']['administrative_area']['#options'];
+            $values['administrative_area_name'] = $options[$values['administrative_area']];
+          }
+        }
+        // Add the country name
+        $values['country_name'] = location_taxonomize_get_country_name($values['country']);
+        $items[] = $values;
+      }
     }
   }
   // taxonomize
@@ -147,26 +166,28 @@ function location_taxonomize_af_bulk_taxonomize_op($form_state, &$context) {
         }
       }
     }
-    // collect node ids
-    $final = array();
+    // Collect entity ids.
+    $entities = array();
     $count = 0;
-    foreach($field_refs as $field) {
-      $e_type = $field[0];
-      $bundle = $field[1]; 
-      $field_name = $field[2]; 
-      $replace = array(
-        ':etype'  => $e_type,
+    foreach ($field_refs as $field) {
+      $entity_type = $field[0];
+      $bundle = $field[1];
+      $field_name = $field[2];
+      $args = array(
+        ':etype'  => $entity_type,
         ':bundle' => $bundle,
       );
       $table = 'field_data_' . $field_name;
-      $result = db_query("SELECT entity_id FROM {$table} WHERE entity_type = :etype AND bundle = :bundle ORDER BY entity_id ASC", $replace);
-      $result_array = $result->fetchAllAssoc('entity_id');
-      foreach($result_array as $e) {
-        if ($e_type == 'node') {
-          $id = $e->entity_id;
-          $final[$id][] = $field_name;
-          $count++;
-        }
+      $enitity_ids = db_select($table, 'af')
+        ->fields('af', array('entity_id'))
+        ->where("entity_type = :etype AND bundle = :bundle", $args)
+        ->orderBy('entity_id')
+        ->execute()
+        ->fetchCol(0);
+
+      foreach ($enitity_ids as $entity_id) {
+        $entities[$entity_id][$entity_type][] = $field_name;
+        $count++;
       }
     }
     $context['sandbox']['progress'] = 0;
@@ -174,7 +195,7 @@ function location_taxonomize_af_bulk_taxonomize_op($form_state, &$context) {
     $context['sandbox']['current'] = 0;
     $context['results']['added'] = 0;
     $context['results']['processed'] = 0;
-    $context['sandbox']['fields'] = $final;
+    $context['sandbox']['fields'] = $entities;
     if ($count == 0) return;
   }
   // maximum 10 addresses per function iteration
@@ -184,19 +205,25 @@ function location_taxonomize_af_bulk_taxonomize_op($form_state, &$context) {
   $saved = 0;
   $taxonomize = array();
   if (!empty($context['sandbox']['fields'])) {
-    foreach ($context['sandbox']['fields'] as $nid => $fields) {
-      $node = node_load($nid);
-      foreach ($fields as $field) {
-        $items = field_get_items('node', $node, $field);
-        foreach ($items as $address) {
-          // Add the country name
-          $address['country_name'] = location_taxonomize_get_country_name($address['country']);
-          $taxonomize[$nid][] = $address;
+    foreach ($context['sandbox']['fields'] as $entity_id => $entity_type_fields) {
+      foreach ($entity_type_fields as $entity_type => $fields) {
+        foreach ($fields as $field) {
+          $entity = entity_load_single($entity_type, $entity_id);
+          $items = field_get_items($entity_type, $entity, $field);
+          foreach ($items as $address) {
+            // Add the country name
+            $address['country_name'] = location_taxonomize_get_country_name($address['country']);
+            $taxonomize[$entity_id][$entity_type][] = $address;
+          }
+          $i++;
+          array_shift($context['sandbox']['fields'][$entity_id][$entity_type]);
+          if (empty($context['sandbox']['fields'][$entity_id][$entity_type])) {
+            unset($context['sandbox']['fields'][$entity_id][$entity_type]);
+          }
         }
-        $i++;
-        array_shift($context['sandbox']['fields'][$nid]);
-        if (empty($context['sandbox']['fields'][$nid])) {
-          unset($context['sandbox']['fields'][$nid]);
+        array_shift($context['sandbox']['fields'][$entity_id]);
+        if (empty($context['sandbox']['fields'][$entity_id])) {
+          unset($context['sandbox']['fields'][$entity_id]);
         }
       }
       if ($i > $limit) break;
@@ -213,4 +240,4 @@ function location_taxonomize_af_bulk_taxonomize_op($form_state, &$context) {
   $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
   $context['sandbox']['current'] = $context['sandbox']['progress'];
   $context['results']['processed'] = $context['sandbox']['progress'];
-}
\ No newline at end of file
+}
diff --git a/location_taxonomize_location/location_taxonomize_location.module b/location_taxonomize_location/location_taxonomize_location.module
index 1694f40..6ee44db 100644
--- a/location_taxonomize_location/location_taxonomize_location.module
+++ b/location_taxonomize_location/location_taxonomize_location.module
@@ -3,7 +3,7 @@
 /**
  * @file
  * This is a 'source module' that adds a data source for the Location Taoxnomize
- * module. It implements the Location Taxonomize functionality for the 
+ * module. It implements the Location Taxonomize functionality for the
  * Location module.
  */
 
@@ -14,11 +14,11 @@ require_once('location_taxonomize_location.inc');
  */
 function location_taxonomize_location_location_taxonomize_source() {
   return array(
-   'location_taxonomize_location' => 'Location', 
+   'location_taxonomize_location' => 'Location',
   );
 }
 
-/** 
+/**
  * Implements hook_form_alter().
  */
 function location_taxonomize_form_alter(&$form, &$form_state, $form_id) {
@@ -43,7 +43,7 @@ function location_taxonomize_location_submitt($form, &$form_state) {
   $items = array();
   foreach ($locations as $obj) {
     unset($obj['location_settings']);
-    // skip empty locations 
+    // skip empty locations
     if (!location_taxonomize_location_location_empty($obj)) {
       $location = location_taxonomize_location_fixup($obj);
       $items[] = $location;
@@ -77,11 +77,24 @@ function location_taxonomize_location_bulk_taxonomize_op($form_state, &$context)
   foreach ($result_array as $row) {
     $address = location_taxonomize_location_fixup((array)$row);
     $lid = $address['lid'];
-    $nid_results = db_query("SELECT nid FROM {location_instance} WHERE lid = :lid", array(":lid" => $lid));
-    $nid = $nid_results->fetchField();
-    $taxonomize[$nid][] = $address;
+    $location_gen_ids = db_query("SELECT genid FROM {location_instance} WHERE lid = :lid", array(":lid" => $lid))->fetchCol(0);
+    foreach ($location_gen_ids as $gen_id) {
+      // The genid field holds info about the field it came from.
+      $parts = explode(':', $gen_id);
+      // Check the field_data_[field_name] table to get the entity_type.
+      $table_name = 'field_data_' . $parts[1];
+      $value_field = $parts[1] . '_lid';
+      $field_data = db_select($table_name, 'location_field')
+        ->fields('location_field', array('entity_type'))
+        ->where("entity_id = :eid AND $value_field = :lid", array(':eid' => $parts[2], ':lid' => $lid))
+        ->execute()
+        ->fetchObject();
+
+      $taxonomize[$parts[2]][$field_data->entity_type][] = $address;
+    }
     $count++;
   }
+
   $results = location_taxonomize_taxonomize_bulk($taxonomize);
   $saved = $results['saved'];
   $context['results']['added'] += $saved;
