diff --git a/reference_option_limit.module b/reference_option_limit.module
index e2e2348..f200c91 100644
--- a/reference_option_limit.module
+++ b/reference_option_limit.module
@@ -237,6 +237,9 @@ function reference_option_limit_field_widget_form_alter(&$element, &$form_state,
   // When in ajax, these are already here!!!!
   $settings = array(
     'field'         => $field_name,
+    // We may not be at the top level of the form; this tells us where we
+    // actually are.
+    'field_parents' => $element['#field_parents'],
     'fields_match'  => $fields_match,
     // If there's a better way for hook_form_alter() to get these values than
     // stashing them here, file a patch! ;)
@@ -258,6 +261,8 @@ function reference_option_limit_field_widget_form_alter(&$element, &$form_state,
  */
 function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
   // Check that the form is one we need to act on.
+  // dsm($form, 'hfa form');
+  // dsm($form_state, 'hfa fs');
   if (!isset($form_state['reference_option_limit'])) {
     return;
   }
@@ -291,20 +296,26 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
       return;
     }
   }
-  //dsm($form, 'hfa form');
-  //dsm($form_state, 'hfa fs');
-
+  
+  // dsm($form, 'hfa form');
+  // dsm($form_state, 'hfa fs');
+  
   // For each field to work on.
   foreach ($form_state['reference_option_limit'] as $settings) {
     // Get the current field name, info, and instance.
     $field_name_option_limited = $settings['field'];
     $field_option_limited = field_info_field($field_name_option_limited);
     $field_instance_option_limited = field_info_instance($settings['entity_type'], $field_name_option_limited, $settings['entity_bundle']);
+    
+    // Get the form element to act on.
+    $parents = $settings['field_parents'];
+    $parents[] = $field_name_option_limited;
+    $element_limited =& drupal_array_get_nested_value($form, $parents);
 
     // Add a wrapper div to the limited field for the ajax to work on.
     $settings['ajax_wrapper'] = 'reference-options-limit-' . str_replace('_', '-', $field_name_option_limited);
-    $form[$field_name_option_limited]['#prefix'] = '<div id="' . $settings['ajax_wrapper'] . '">';
-    $form[$field_name_option_limited]['#suffix'] = '</div>';
+    $element_limited['#prefix'] = '<div id="' . $settings['ajax_wrapper'] . '">';
+    $element_limited['#suffix'] = '</div>';
     //dsm($settings, 'settings');
 
     $match_columns = array();
@@ -312,9 +323,14 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
     $matching_field_labels = array();
     // Iterate over each matching field, ie, those we match values with.
     foreach ($settings['fields_match'] as $field_name_matching) {
+      $parents = $settings['field_parents'];
+      $parents[] = $field_name_matching;
+      $element_matching =& drupal_array_get_nested_value($form, $parents);
+      // dsm($element_matching, '$element_matching');
       // Make each matchable field ajaxy so its changes cause the limited
       // field to update itself.
-      $form[$field_name_matching][LANGUAGE_NONE]['#ajax'] = array(
+      
+      $element_matching[LANGUAGE_NONE]['#ajax'] = array(
         'callback' => 'reference_option_limit_js',
         'wrapper' => $settings['ajax_wrapper'],
         'method' => 'replace',
@@ -323,32 +339,38 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
       );
 
       $field_info_matching = field_info_field($field_name_matching);
-      //dsm($field_info_matching, '$field_info_matching');
+      // dsm($field_info_matching, '$field_info_matching');
       // We build up an array of the labels of all matching fields in case
       // we need it further down for a UI message.
       $field_instance_matching = field_info_instance($settings['entity_type'], $field_name_matching, $settings['entity_bundle']);
+      
       $matching_field_labels[] = $field_instance_matching['label'];
 
       // Get the list of columns we should be extracting from the form and
       // then matching on.
       $match_columns[$field_name_matching] = reference_option_limit_get_match_columns($field_info_matching);
-
+      
       // Build an array of field values to match on. This is keyed first by
       // field name, and then by delta (or with default values, whatever).
       // First time around these are in default values; in ajax calls these are in $form_state.
       if (isset($form_state['values'])) {
         // @todo: Figure out what on earth should happen when we have more than one column!
         $column = $match_columns[$field_name_matching][0];
-        foreach ($form_state['values'][$field_name_matching][LANGUAGE_NONE] as $delta => $item) {
+        $values_field_matching = drupal_array_get_nested_value($form_state['values'], $parents);
+        // dsm($values_field_matching,'$values_field_matching');
+
+        foreach ($values_field_matching[LANGUAGE_NONE] as $delta => $item) {
           $match_values[$field_name_matching][$delta] = $item[$column];
         }
+     
       }
       else {
         // Urgh, for taxonomy term reference fields the default value is an
         // array!
         // @todo: other field types probably have other quirks :(
-        if (is_array($form[$field_name_matching][LANGUAGE_NONE]['#default_value'])) {
-          $default_value_array = $form[$field_name_matching][LANGUAGE_NONE]['#default_value'];
+        
+        if (is_array($element_matching[LANGUAGE_NONE]['#default_value'])) {
+          $default_value_array = $element_matching[LANGUAGE_NONE]['#default_value'];
           if (count($default_value_array)) {
             $match_values[$field_name_matching][] = $default_value_array;
           }
@@ -357,11 +379,12 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
           }
         }
         else {
-          $match_values[$field_name_matching][] = $form[$field_name_matching][LANGUAGE_NONE]['#default_value'];
+          $match_values[$field_name_matching][] = $element_matching[LANGUAGE_NONE]['#default_value'];
         }
+        // dsm($match_values, 'mv term');
       }
     }
-    //dsm($match_values, 'mv');
+    // dsm($match_values, 'mv');
     // @todo: figure out if there is a way to distinguish between these cases:
     //  1: there are no matching values at all for some reason
     //  2: we are on a form for creating a new entity and no default is set for anything
@@ -382,6 +405,7 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
       // @todo: handle more than one column to match on.
       $column = $match_columns[$field_name_matching][0];
       $values = $match_values[$field_name_matching];
+      // dsm($values,'$values');
       // We currently treat multiple values on one field as an OR condition,
       // i.e., we limit by any of the values but not all of them.
       // @todo: Add a UI option to make this an AND condition.
@@ -433,7 +457,7 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
     else {
       $entities = array();
     }
-    //dsm($entities);
+    // dsm($entities, 'found entities');
 
     // Build an array of options.
     $options_limited = array();
@@ -445,9 +469,10 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
 
     // Do the same prep work as options_field_widget_form() on our instance
     // to get a properties array to pass to _options_prepare_options().
+    
     $type = str_replace('options_', '', $field_instance_option_limited['widget']['type']);
     $multiple = $field_option_limited['cardinality'] > 1 || $field_option_limited['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
-    $required = $form[$field_name_option_limited][LANGUAGE_NONE]['#required'];
+    $required = $element_limited[LANGUAGE_NONE]['#required'];
     $has_value = TRUE; // isset($items[0][$value_key]); ?????
     $properties = _options_properties($type, $multiple, $required, $has_value);
 
@@ -463,18 +488,23 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
       $label = theme('options_none', array('instance' => $field_instance_option_limited, 'option' => $properties['empty_option']));
       $options_limited = array('_none' => $label) + $options_limited;
     }
-    //dsm($options_limited, '$options_limited post stuff');
+    
+    // dsm($options_limited, '$options_limited post stuff');
 
     // Add an explanation if there are no options to select at all.
     if ($options_limited_empty) {
-      $form[$field_name_option_limited][LANGUAGE_NONE]['#description'] .= ' ' . t('No options are available for the current form values. Try selecting different values for the following fields: @fields.', array(
+      $element_limited[LANGUAGE_NONE]['#description'] .= ' ' . t('<b>No options are available for the current form values. Try selecting different values for the following fields: @fields.</b>', array(
         '@fields' => implode(', ', $matching_field_labels),
       ));
     }
+    // dsm($element_limited, '$element_limited');
 
     // Set the new options into the form element.
-    $form[$field_name_option_limited][LANGUAGE_NONE]['#options'] = $options_limited;
-  } // foreach settings
+
+    $element_limited[LANGUAGE_NONE]['#options'] = $options_limited;
+  }
+  // dsm($form, 'hfa form');
+  // dsm($form_state, 'hfa fs');
 }
 
 /**
@@ -504,27 +534,52 @@ function reference_option_limit_get_match_columns($field) {
 /**
  * Ajax callback for the updated term reference field.
  */
-function reference_option_limit_js($form, $form_state) {
+function reference_option_limit_js(&$form, &$form_state) {
   // Deduce the field the triggering element belongs to.
   // @todo: not sure how robust this is.
-  $field_name_triggering = $form_state['triggering_element']['#parents'][0];
-
+    
+  // dsm($form_state, '$form_state');
+  
+  // field matching is the penultimate item of the parents array
+  $count = count($form_state['triggering_element']['#parents']);
+  $delta = $count - 2;
+  $field_name_triggering = $form_state['triggering_element']['#parents'][$delta];
+  
+  // dsm($field_name_triggering, '$field_name_triggering');
   // Find which option limited field we should be returning the element for.
   // @todo: I have no idea how to make this work if the triggering field affects
   // more than one option limited field!
   foreach ($form_state['reference_option_limit'] as $settings) {
     if (isset($settings['fields_match'][$field_name_triggering])) {
       $field_name_dependent = $settings['field'];
+      // @todo - limited to only one parent !
+      if (isset($settings['field_parents'][0])) {
+        $field_parent = $settings['field_parents'][0];
+      }
     }
   }
-
+  
+  // dsm($form, 'hfa form');
+  // dsm($form_state, 'hfa fs');
   if ($messages = theme('status_messages')) {
-    $form[$field_name_dependent]['messages'] = array(
-      '#markup' => '<div class="views-messages">' . $messages . '</div>',
-    );
+    if (isset($field_parent)) {
+      $form[$field_parent][$field_name_dependent]['messages'] = array(
+        '#markup' => '<div class="views-messages">' . $messages . '</div>',
+      );
+    }
+    else {
+      $form[$field_name_dependent]['messages'] = array(
+        '#markup' => '<div class="views-messages">' . $messages . '</div>',
+      );
+    }
+  }
+  
+  if (isset($field_parent)) {
+    return $form[$field_parent][$field_name_dependent];
+  }
+  else {
+    return $form[$field_name_dependent];
   }
-
-  return $form[$field_name_dependent];
 }
 
 /**
