diff --git a/facetapi_select.module b/facetapi_select.module
index 3ab613e..584c3e3 100644
--- a/facetapi_select.module
+++ b/facetapi_select.module
@@ -1,15 +1,36 @@
 <?php
 
-function facetapi_select_facet_form($form_state, $options, $count = 0) {
-  drupal_add_js(drupal_get_path('module', 'facetapi_select') .'/js/facetapi_select.js');
-  
+function facetapi_select_facet_form($form_state, $variables, $count = 0) {
   $name = 'facetapi_select_facet_form_' . $count;
+  // Add link to deactive widget if currently active
+  if (isset($variables['active_path'])) {
+    $form['deactivate_link'] = array(
+      '#type' => 'markup',
+      '#markup' => l(
+        theme('facetapi_deactivate_widget'),
+        $variables['active_path'],
+        array(
+          'attributes' => array(
+            'class' => 'facetapi-active',
+            'id' => drupal_html_id('facetapi-link'),
+            'rel' => 'nofollow',
+          ),
+          // Because the path has already been through url(), mark it as external.
+          'external' => TRUE,
+          'html' => TRUE,
+        )),
+    );
+  }
   $form['facets'] = array(
     '#type' => 'select',
     '#id' => $name,
     '#default_value' => '',
-    '#options' => $options,
+    '#options' => $variables['options'],
     '#attributes' => array('onchange' => "top.location.href=document.getElementById('$name').options[document.getElementById('$name').selectedIndex].value"),
+    '#attached' => array(
+      'js' => array(
+        drupal_get_path('module', 'facetapi_select') .'/js/facetapi_select.js',
+      ),
+    ),
   );
   $form['submit'] = array(
     '#type' => 'submit',
@@ -62,28 +83,28 @@ class FacetapiSelectDropdowns extends FacetapiWidgetLinks {
       $path = !empty($this->settings->settings['submit_page']) ? $this->settings->settings['submit_page'] : $item['#path'];
       $path = strpos($item['#path'], $path) === 0 ? $item['#path'] : $path;
       $url = url($path, array('query' => $item['#query']));
-      $options[$url] = $item['#markup'].' ('.$item['#count'].')';
+      $variables['options'][$url] = $item['#markup'].' ('.$item['#count'].')';
       if ($item['#active']) {
-        $facet_active = TRUE;
+        $variables['active_path'] = $url;
       }
     }
 
-    if (!$facet_active) {
+    if (!isset($variables['active_path'])) {
       if (!empty($settings->settings['default_option_label'])) {
-        array_unshift($options, $settings->settings['default_option_label']);
+        array_unshift($variables['options'], $settings->settings['default_option_label']);
       }
       else {
-        array_unshift($options, t('--Choose--'));
+        array_unshift($variables['options'], t('--Choose--'));
       }
     }
 
     // We keep track of how many facets we're adding, because each facet form
     // needs a different form id.
-    if (end($options) !== '(-)') {
+    if (end($variables['options']) !== '(-)') {
       if (!isset($form_state)) {
         $form_state = array();
       }
-      $element = facetapi_select_facet_form($form_state, $options, $count);
+      $element = facetapi_select_facet_form($form_state, $variables, $count);
     }
   }
 
