diff --git a/reference_option_limit.module b/reference_option_limit.module
index 800e2ae..986be60 100644
--- a/reference_option_limit.module
+++ b/reference_option_limit.module
@@ -231,6 +231,12 @@ function reference_option_limit_field_widget_form_alter(&$element, &$form_state,
   // Unselected checkboxes end up here as 0s.  Surely this is babysitting :(
   $fields_match = array_filter($context['instance']['options_limit_fields']);
 
+
+  // Do nothing if we've already been here and set these in form state.
+  if (isset($form_state['reference_option_limit'][$field_name])) {
+    return;
+  }
+
   // Stash our settings in $form_state so hook_form_alter() can find them.
   // We need to do this because in this current hook we can only see this
   // field's form element.
@@ -245,7 +251,7 @@ function reference_option_limit_field_widget_form_alter(&$element, &$form_state,
     'empty_behaviour' => !empty($context['instance']['options_limit_empty_behaviour']),
   );
   // Allow for settings for more than one field.
-  $form_state['reference_option_limit'][$field_name] = $settings;
+  $form_state['reference_option_limit']['settings'][$field_name] = $settings;
 }
 
 /**
@@ -262,7 +268,7 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
     //dsm($form_state, 'hfa fs');
 
     // For each field to work on.
-    foreach ($form_state['reference_option_limit'] as $settings) {
+    foreach ($form_state['reference_option_limit']['settings'] as $field_name => $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);
@@ -303,14 +309,13 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
         // 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) {
-            $match_values[$field_name_matching][$delta] = $item[$column];
-          }
-        }
-        else {
+        // We're either here the first time around, or we're here on AJAX.
+        // However, there are three, not two cases:
+        //  1. First time here.
+        //  2. Our own AJAX callback.
+        //  3. Another form element's AJAX, eg an image field.
+        if (!isset($form_state['values'])) {
+          // Case 1: First time round.
           // Urgh, for taxonomy term reference fields the default value is an
           // array!
           // @todo: other field types probably have other quirks :(
@@ -327,6 +332,34 @@ function reference_option_limit_form_alter(&$form, &$form_state, $form_id) {
             $match_values[$field_name_matching][] = $form[$field_name_matching][LANGUAGE_NONE]['#default_value'];
           }
         }
+        elseif (isset($form_state['values'][$field_name_matching])) {
+          // Case 2: Our element's AJAX.
+          // @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) {
+            $match_values[$field_name_matching][$delta] = $item[$column];
+          }
+
+          // Stash the match values in the form state, so they are there for
+          // case 3.
+          $form_state['reference_option_limit']['storage'][$field_name]['match_values'] = $match_values;
+        }
+        else {
+          // Case 3: Another form element's AJAX callback.
+          // It's likely our form elements are not getting validated, and hence
+          // input from them will not make it into $form_state['values'] this
+          // time around.
+          // However, it's also likely that the form HTML for those elements
+          // is not about to be replaced by AJAX, and that any selection made
+          // by the user will (correctly) remain there.
+          // This means that we have to ensure that our dependent element in
+          // the internal version of the form continues to match the element
+          // that the user sees, otherwise the values selected by the user
+          // will be treated as illegal when submitted.
+          // Hence retrieve them from the stash we left when we came here for
+          // case 2.
+          $match_values = $form_state['reference_option_limit']['storage'][$field_name]['match_values'];
+        }
       }
       //dsm($match_values, 'mv');
       // @todo: figure out if there is a way to distinguish between these cases:
@@ -450,7 +483,7 @@ function reference_option_limit_js($form, $form_state) {
   // 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) {
+  foreach ($form_state['reference_option_limit']['settings'] as $settings) {
     if (isset($settings['fields_match'][$field_name_triggering])) {
       $field_name_dependent = $settings['field'];
     }
