diff --git a/webform_conditional.module b/webform_conditional.module
index e123879..cf248cd 100644
--- a/webform_conditional.module
+++ b/webform_conditional.module
@@ -129,12 +129,11 @@ function webform_conditional_form_alter(&$form, $form_state, $form_id) {
         }
       }
     }
-  }
-  if (!empty($js_fields)) {
     //can't add javascript in this function or it will not be added if the form is built from cache.  Need to run "after_build" function
     $form['#after_build'][] = 'webform_conditional_add_js';
     $js_settings = array(
-      'fields' => $js_fields,
+      // Rewrite previous settings if the form is being rebuilt.
+      'fields' => isset($js_fields) ? $js_fields : FALSE,
       'nid' => $nid,
       'showSpeed' => NULL, //'fast',
     );
@@ -237,6 +236,15 @@ function _webform_conditional_get_css_id($nid, $cid) {
  *  The form
  */
 function webform_conditional_add_js(&$form, $form_state) {
+  // If the form is being rebuilt we need to reset the previous settings,
+  // otherwise array_merge_recursive() will turn string values into arrays.
+  $javascript = &drupal_static('drupal_add_js', array());
+  foreach ($javascript['settings']['data'] as $delta => $settings) {
+    if (key($settings) == 'webform_conditional') {
+      unset($javascript['settings']['data'][$delta]);
+      break;
+    }
+  }
   drupal_add_js(array('webform_conditional' => $form['#webform_conditional_js']), array('type' => "setting", 'scope' => JS_DEFAULT));
   drupal_add_js(drupal_get_path('module', 'webform_conditional') . '/webform_conditional.js');
   return $form;
