diff --git a/contrib/current_search/current_search.block.inc b/contrib/current_search/current_search.block.inc
index ce0ec6b..6060a35 100644
--- a/contrib/current_search/current_search.block.inc
+++ b/contrib/current_search/current_search.block.inc
@@ -95,7 +95,7 @@ function current_search_block_list_alter(&$blocks) {
 function current_search_block_view($delta = '') {
   // Test block visibility if not already tested. This is necessary when using
   // modules such as Context that do not invoke hook_block_list_alter().
-  $map = &drupal_static('current_search_delta_map');
+  static $map;
   if (NULL === $map && !current_search_check_visibility($delta)) {
     return;
   }
@@ -175,7 +175,7 @@ function current_search_check_visibility($delta) {
 
   // Caches the delta map, defaults to NULL so we can test whether this function
   // was called in hook_block_list_alter() or not.
-  $map = &drupal_static('current_search_delta_map');
+  static $map;
   if (NULL === $map) {
     $map = array();
     $result = db_query('SELECT delta, searcher FROM {block_current_search}');
diff --git a/contrib/current_search/current_search.info b/contrib/current_search/current_search.info
index 24405ca..a94ec88 100644
--- a/contrib/current_search/current_search.info
+++ b/contrib/current_search/current_search.info
@@ -2,7 +2,7 @@ name = Current Search Blocks
 description = Provides an interface for creating blocks containing information about the current search.
 dependencies[] = facetapi
 package = Search Toolkit
-core = 7.x
+core = 6.x
 files[] = plugins/current_search/item.inc
 files[] = plugins/current_search/item_active.inc
 files[] = plugins/current_search/item_group.inc
diff --git a/contrib/current_search/current_search.install b/contrib/current_search/current_search.install
index abeefe0..cfa38e1 100644
--- a/contrib/current_search/current_search.install
+++ b/contrib/current_search/current_search.install
@@ -75,24 +75,17 @@ function current_search_schema() {
 }
 
 /**
- * Update the structure of saved settings objects.
+ * Implementation of hook_install().
  */
-function current_search_update_7101() {
-  // @see http://drupal.org/node/1379166
-  $result = db_query('SELECT name, settings FROM {current_search}');
-  foreach ($result as $record) {
-    $settings = unserialize($record->settings);
-    // Make our best guess as to whether or not we are using the old structure.
-    if (count($settings) != 2 || !isset($settings['items']) || !isset($settings['advanced'])) {
-      $settings = array(
-        'items' => $settings,
-        'advanced' => array(
-          'empty_searches' => 0,
-        ),
-      );
-      db_update('current_search')
-        ->fields(array('settings' => serialize($settings)))
-        ->execute();
-    }
-  }
+function current_search_install() {
+  // Install tables
+  drupal_install_schema('current_search');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function current_search_uninstall() {
+  // Remove tables.
+  drupal_uninstall_schema('current_search');
 }
diff --git a/contrib/current_search/current_search.module b/contrib/current_search/current_search.module
index 183c9ad..ffa2358 100644
--- a/contrib/current_search/current_search.module
+++ b/contrib/current_search/current_search.module
@@ -109,7 +109,7 @@ function current_search_ctools_plugin_type() {
  *   An associative array keyed by plugin ID to human readable label.
  */
 function current_search_get_plugins() {
-  $plugins = &drupal_static(__FUNCTION__, array());
+  static $plugins;
   if (!$plugins) {
     foreach (ctools_get_plugins('current_search', 'items') as $id => $plugin) {
       $plugins[$id] = $plugin['handler']['label'];
diff --git a/contrib/current_search/plugins/current_search/item_active.inc b/contrib/current_search/plugins/current_search/item_active.inc
index a3d0879..a6ca47d 100644
--- a/contrib/current_search/plugins/current_search/item_active.inc
+++ b/contrib/current_search/plugins/current_search/item_active.inc
@@ -40,7 +40,7 @@ class CurrentSearchItemActive extends CurrentSearchItem {
       $data = array('facetapi_active_item' => $item);
       $variables = array(
         'text' => token_replace($pattern, $data),
-        'path' => current_path(),
+        'path' => $_GET['q'],
         'options' => array(
           'attributes' => $attributes,
           'html' => TRUE,
diff --git a/contrib/current_search/plugins/current_search/item_group.inc b/contrib/current_search/plugins/current_search/item_group.inc
index 32ee3df..bc99c36 100644
--- a/contrib/current_search/plugins/current_search/item_group.inc
+++ b/contrib/current_search/plugins/current_search/item_group.inc
@@ -49,7 +49,7 @@ class CurrentSearchGroup extends CurrentSearchItem {
         $text = ($markup['#html']) ? $markup['#markup'] : check_plain($markup['#markup']);
         $variables = array(
           'text' => $text,
-          'path' => current_path(),
+          'path' => $_GET['q'],
           'options' => array(
             'attributes' => $attributes,
             'html' => TRUE,
diff --git a/contrib/current_search/plugins/export_ui/current_search_export_ui.class.php b/contrib/current_search/plugins/export_ui/current_search_export_ui.class.php
index 5d04fa6..12aad06 100644
--- a/contrib/current_search/plugins/export_ui/current_search_export_ui.class.php
+++ b/contrib/current_search/plugins/export_ui/current_search_export_ui.class.php
@@ -53,7 +53,7 @@ class current_search_export_ui extends ctools_export_ui {
         // Sets redirect path and options.
         $op = $form_state['op'];
         $name = $form_state['values']['name'];
-        $path = ('add' != $op) ? current_path() : 'admin/config/search/current_search/list/' . $name . '/edit';
+        $path = ('add' != $op) ? $_GET['q'] : 'admin/config/search/current_search/list/' . $name . '/edit';
         $this->plugin['redirect'][$op] = array($path, $options);
       }
     }
@@ -446,6 +446,11 @@ function current_search_settings_form(&$form, &$form_state) {
 function theme_current_search_sort_settings_table($variables) {
   $output = '';
 
+  // Initializes table header.
+  $header = array(
+    'item' => t('Item'),
+    'weight' => t('weight'),
+  );
   // Builds table rows.
   $rows = array();
   foreach ($variables['element']['#current_search']['items'] as $name => $settings) {
@@ -466,7 +471,7 @@ function theme_current_search_sort_settings_table($variables) {
   $table_id = 'current-search-sort-settings';
   drupal_add_tabledrag($table_id, 'order', 'sibling', 'current-search-sort-weight');
   $output .= drupal_render_children($variables['element']);
-  $output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => $table_id)));
+  $output .= theme('table', $header, $rows, array('attributes' => array('id' => $table_id)));
   return $output;
 }
 
@@ -534,7 +539,7 @@ function current_search_settings_form_submit($form, &$form_state) {
       }
 
       // Sorts settings by weight.
-      uasort($item->settings['items'], 'drupal_sort_weight');
+      uasort($item->settings['items'], 'facetapi_sort_weight');
 
       // Stores advanced settings.
       $item->settings['advanced'] = $form_state['values']['advanced_settings'];
@@ -555,7 +560,7 @@ function current_search_settings_form_submit($form, &$form_state) {
  *
  * @ingroup forms
  */
-function current_search_delete_item_form($form, &$form_state, stdClass $item, $name) {
+function current_search_delete_item_form(&$form_state, stdClass $item, $name) {
   $form['#current_search'] = array(
     'item' => $item,
     'name' => $name
diff --git a/facetapi.admin.inc b/facetapi.admin.inc
index 3e934a8..857e0ef 100644
--- a/facetapi.admin.inc
+++ b/facetapi.admin.inc
@@ -29,8 +29,8 @@ function facetapi_is_overridden(stdClass $settings) {
  * @see facetapi_realm_settings_form_submit()
  * @ingroup forms
  */
-function facetapi_realm_settings_form($form, &$form_state, $searcher, $realm_name) {
-
+function facetapi_realm_settings_form(&$form_state, $searcher, $realm_name) {
+  $form = array();
   // Instantiates adapter, loads realm.
   $adapter = facetapi_adapter_load($searcher);
   $realm = facetapi_realm_load($realm_name);
@@ -122,7 +122,7 @@ function facetapi_realm_settings_form($form, &$form_state, $searcher, $realm_nam
   }
 
   // Sorts by the weight appended above.
-  uasort($form['#facetapi']['facet_info'], 'drupal_sort_weight');
+  uasort($form['#facetapi']['facet_info'], 'facetapi_sort_weight');
 
   $form['table']['enabled_facets'] = array(
     '#type' => 'checkboxes',
@@ -137,7 +137,7 @@ function facetapi_realm_settings_form($form, &$form_state, $searcher, $realm_nam
   else {
     $description = t(
       'To enable block caching, visit the <a href="@performance-page">performance page</a>.',
-      array('@performance-page' => url('admin/config/development/performance', array('query' => array('destination' => current_path()))))
+      array('@performance-page' => url('admin/config/development/performance', array('query' => array('destination' => $_GET['q']))))
     );
   }
   $form['block_cache'] = array(
@@ -200,7 +200,7 @@ function facetapi_realm_settings_form_submit($form, &$form_state) {
     if ('block' == $form['#facetapi']['realm']['name']) {
       drupal_set_message(t(
         'To enable or arrange the facet blocks, visit the <a href="@block-page">blocks administration page</a>.',
-        array('@block-page' => url('admin/structure/block', array('query' => array('destination' => current_path()))))
+        array('@block-page' => url('admin/structure/block', array('query' => array('destination' => $_GET['q']))))
       ));
     }
   }
@@ -235,9 +235,9 @@ function theme_facetapi_realm_settings_table($variables) {
   $path = drupal_get_path('module', 'facetapi');
   drupal_add_css($path . '/facetapi.admin.css', array('weight' => CSS_THEME - 1));
 
-  // Gets variales for code readability.
-  $searcher = $variables['element']['#facetapi']['adapter']->getSearcher();
-  $realm = $variables['element']['#facetapi']['realm'];
+  // Gets variables for code readability.
+  $searcher = $variables['#facetapi']['adapter']->getSearcher();
+  $realm = $variables['#facetapi']['realm'];
 
   $header = array(
     'enabled' => array('data' => t('Enabled')),
@@ -250,31 +250,31 @@ function theme_facetapi_realm_settings_table($variables) {
 
   // Builds field options.
   $rows = array();
-  $facet_info = $variables['element']['#facetapi']['facet_info'];
+  $facet_info = $variables['#facetapi']['facet_info'];
   foreach ($facet_info as $facet_name => $facet) {
 
     // Builds rows.
     $rows[$facet_name] = array(
       'class' => $realm['sortable'] ? array('draggable') : array(),
       'data' => array(
-        drupal_render($variables['element']['enabled_facets'][$facet_name]),
+        drupal_render($variables['enabled_facets'][$facet_name]),
         check_plain($facet['label']) . "<div class='description'>" . filter_xss($facet['description']) . '</div>',
         array(
           'class' => 'facetapi-operations',
-          'data' => drupal_render($variables['element']['operations'][$facet_name]),
+          'data' => drupal_render($variables['operations'][$facet_name]),
         ),
       ),
     );
     if ($realm['sortable']) {
-      $rows[$facet_name]['data'][] = drupal_render($variables['element']['weight'][$facet_name]);
+      $rows[$facet_name]['data'][] = drupal_render($variables['weight'][$facet_name]);
     }
   }
 
   if ($realm['sortable']) {
     drupal_add_tabledrag('facetapi-realm-settings', 'order', 'sibling', 'facetapi-facet-weight');
   }
-  $output .= drupal_render_children($variables['element']);
-  $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'facetapi-realm-settings')));
+  //$output .= drupal_render_children($variables['element']);
+  $output .= theme('table', $header, $rows, array('attributes' => array('id' => 'facetapi-realm-settings')));
 
   return $output;
 }
@@ -376,7 +376,8 @@ function facetapi_get_available_sorts(array $realm, array $facet) {
  * @see facetapi_facet_display_form_submit()
  * @ingroup forms
  */
-function facetapi_facet_display_form($form, &$form_state, FacetapiAdapter $adapter, array $realm, array $facet) {
+function facetapi_facet_display_form(&$form_state, FacetapiAdapter $adapter, array $realm, array $facet) {
+  $form = array();
   $path = drupal_get_path('module', 'facetapi');
   drupal_add_css($path . '/facetapi.admin.css', array('weight' => CSS_THEME - 1));
   drupal_add_js($path . '/facetapi.admin.js');
@@ -462,7 +463,7 @@ function facetapi_facet_display_form($form, &$form_state, FacetapiAdapter $adapt
   }
 
   // Orders the sorts by the default weights set above.
-  uasort($form['#facetapi']['sort_info'], 'drupal_sort_weight');
+  uasort($form['#facetapi']['sort_info'], 'facetapi_sort_weight');
 
   // Builds checkbox options and weight dropboxes.
   $sort_options = array();
@@ -719,7 +720,7 @@ function theme_facetapi_sort_settings_table($variables) {
 
   drupal_add_tabledrag('facetapi-sort-settings', 'order', 'sibling', 'facetapi-sort-weight');
   $output .= drupal_render_children($variables['element']);
-  $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'facetapi-sort-settings')));
+  $output .= theme('table', $header, $rows, array('attributes' => array('id' => 'facetapi-sort-settings')));
 
   return $output;
 }
@@ -805,8 +806,8 @@ function facetapi_facet_display_form_submit($form, &$form_state) {
  * @see facetapi_facet_filters_form_submit()
  * @ingroup forms
  */
-function facetapi_facet_filters_form($form, &$form_state, FacetapiAdapter $adapter, array $realm, array $filters) {
-
+function facetapi_facet_filters_form(&$form_state, FacetapiAdapter $adapter, array $realm, array $filters) {
+  $form = array();
   // We have to set the title due to contextual link magic.
   // @see http://drupal.org/node/1147588#comment-4428940
   drupal_set_title(t('Configure facet filters'));
@@ -865,7 +866,7 @@ function facetapi_facet_filters_form($form, &$form_state, FacetapiAdapter $adapt
       );
     }
   }
-  uasort($plugins, 'drupal_sort_weight');
+  uasort($plugins, 'facetapi_sort_weight');
 
   // Builds table, adds settings to vertical tabs.
   $has_settings = FALSE;
@@ -981,6 +982,12 @@ function facetapi_facet_filters_form($form, &$form_state, FacetapiAdapter $adapt
 function theme_facetapi_filter_settings_table($variables) {
   $element = $variables['element'];
 
+// Initializes table header.
+  $header = array(
+    'status' => t('Status'),
+    'filter' => t('Filter'),
+    'weight' => t('Weight'),
+  );
   // Filter order (tabledrag).
   $rows = array();
   foreach (element_children($element, TRUE) as $name) {
@@ -995,7 +1002,7 @@ function theme_facetapi_filter_settings_table($variables) {
     );
   }
   $output = drupal_render_children($element);
-  $output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => 'facetapi-filter-settings')));
+  $output .= theme('table', $header, $rows, array('attributes' => array('id' => 'facetapi-filter-settings')));
   drupal_add_tabledrag('facetapi-filter-settings', 'order', 'sibling', 'facetapi-filter-weight', NULL, NULL, TRUE);
 
   return $output;
@@ -1049,8 +1056,8 @@ function facetapi_facet_filters_form_submit($form, &$form_state) {
  * @see facetapi_facet_dependencies_form_submit()
  * @ingroup forms
  */
-function facetapi_facet_dependencies_form($form, &$form_state, FacetapiAdapter $adapter, array $realm, array $dependencies) {
-
+function facetapi_facet_dependencies_form(&$form_state, FacetapiAdapter $adapter, array $realm, array $dependencies) {
+  $form = array();
   // We have to set the title due to contextual link magic.
   // @see http://drupal.org/node/1147588#comment-4428940
   drupal_set_title(t('Configure facet dependencies'));
@@ -1192,7 +1199,8 @@ function facetapi_facet_dependencies_form_submit($form, &$form_state) {
  * @see ctools_export_form()
  * @ingroup forms
  */
-function facetapi_export_form($form, &$form_state, FacetapiAdapter $adapter, array $realm, array $facet) {
+function facetapi_export_form(&$form_state, FacetapiAdapter $adapter, array $realm, array $facet) {
+  $form = array();
   $form['facet'] = array();
   $form['global'] = array();
 
@@ -1232,8 +1240,8 @@ function facetapi_export_form($form, &$form_state, FacetapiAdapter $adapter, arr
  *
  * @ingroup forms
  */
-function facetapi_revert_form($form, &$form_state, FacetapiAdapter $adapter, array $realm, array $facet) {
-
+function facetapi_revert_form(&$form_state, FacetapiAdapter $adapter, array $realm, array $facet) {
+  $form = array();
   $form['#facetapi'] = array(
     'adapter' => $adapter,
     'realm' => $realm,
diff --git a/facetapi.api.php b/facetapi.api.php
index 4ce056a..8a361e8 100644
--- a/facetapi.api.php
+++ b/facetapi.api.php
@@ -103,7 +103,7 @@ function hook_facetapi_realm_info() {
       'settings callback' => 'facetapi_block_realm_settings',
       'description' => t(
         'The <em>Blocks</em> realm displays each facet in a separate <a href="@block-page">block</a>. Users are able to refine their searches in a drill-down fashion.',
-        array('@block-page' => url('admin/structure/block', array('query' => array('destination' => current_path()))))
+        array('@block-page' => url('admin/structure/block', array('query' => array('destination' => $_GET['q']))))
       ),
     ),
   );
diff --git a/facetapi.block.inc b/facetapi.block.inc
index d96225d..b004d59 100644
--- a/facetapi.block.inc
+++ b/facetapi.block.inc
@@ -57,8 +57,8 @@ function facetapi_block_list_alter(&$blocks) {
  * Implements hook_block_view().
  */
 function facetapi_block_view($delta = '') {
-  $builds = &drupal_static(__FUNCTION__, array());
-  $parsed = &drupal_static('facetapi_parsed_deltas', array());
+  static $builds = array();
+  static $parsed = array();
 
   // Test block visibility if not already tested. This is necessary when using
   // modules such as Context that do not invoke hook_block_list_alter().
@@ -109,7 +109,7 @@ function facetapi_check_block_visibility($delta) {
 
   // Store parsed deltas so we only calculate once. This also lets us know
   // whether hook_block_list_alter() was called or not.
-  $parsed = &drupal_static('facetapi_parsed_deltas', array());
+  static $parsed = array();
 
   // Ensures the delta is mapped.
   if (!isset($map[$delta])) {
@@ -151,7 +151,7 @@ function facetapi_check_block_visibility($delta) {
  *   An array containing the delta map.
  */
 function facetapi_get_delta_map() {
-  $map = &drupal_static(__FUNCTION__);
+  static $map;
   if (NULL === $map) {
     if ($data = cache_get('facetapi:delta_map')) {
       $map = $data->data;
diff --git a/facetapi.facetapi.inc b/facetapi.facetapi.inc
index 7b4c15e..a029342 100644
--- a/facetapi.facetapi.inc
+++ b/facetapi.facetapi.inc
@@ -19,7 +19,7 @@ function facetapi_facetapi_realm_info() {
     'element type' => 'links',
     'description' => t(
       'The <em>Blocks</em> realm displays each facet in a separate <a href="@block-page">block</a>. Users are able to refine their searches in a drill-down fashion.',
-      array('@block-page' => url('admin/structure/block', array('query' => array('destination' => current_path()))))
+      array('@block-page' => url('admin/structure/block', array('query' => array('destination' => $_GET['q']))))
     ),
   );
 
diff --git a/facetapi.info b/facetapi.info
index a94c431..e2b8f71 100644
--- a/facetapi.info
+++ b/facetapi.info
@@ -2,7 +2,7 @@ name = Facet API
 description = An abstracted facet API that can be used by various search backends.
 dependencies[] = ctools
 package = Search Toolkit
-core = 7.x
+core = 6.x
 files[] = plugins/facetapi/adapter.inc
 files[] = plugins/facetapi/dependency.inc
 files[] = plugins/facetapi/dependency_bundle.inc
diff --git a/facetapi.install b/facetapi.install
index 0d5a876..f3fb7b1 100644
--- a/facetapi.install
+++ b/facetapi.install
@@ -74,7 +74,8 @@ function facetapi_schema() {
  * Implementation of hook_install().
  */
 function facetapi_install() {
-  // Nothing to do...
+  // Install tables
+  drupal_install_schema('facetapi');
 }
 
 /**
@@ -83,120 +84,10 @@ function facetapi_install() {
 function facetapi_uninstall() {
   // Remove all variables that start with "facetapi:".
   $args = array(':module' => 'facetapi%');
-  $result = db_query('SELECT name FROM {variable} WHERE name LIKE :module', $args);
+  $result = dbtng_query('SELECT name FROM {variable} WHERE name LIKE :module', $args);
   foreach ($result as $record) {
     variable_del($record->name);
   }
-}
-
-/**
- * Update hashed block deltas to a URL-safe form.
- */
-function facetapi_update_7000() {
-  $result = db_query("SELECT name FROM {facetapi}");
-  foreach ($result as $f) {
-    if (strlen($r->name) > 32) {
-      $orig_delta = substr(base64_encode(hash('sha256', $r->name, TRUE)), 0, 32);
-      $new_delta = strtr($orig_delta, array('+' => '-', '/' => '_', '=' => ''));
-      db_update('block')
-        ->fields(array(
-          'delta' => $new_delta,
-        ))
-        ->condition('module', 'facetapi')
-        ->condition('delta', $orig_delta)
-        ->execute();
-    }
-  }
-}
-
-/**
- * Hashes all blocks deltas related to Facet API.
- */
-function facetapi_update_7001() {
-
-  // Clears the delta cache.
-  db_delete('cache')
-    ->condition('cid', 'facetapi:delta_map')
-    ->execute();
-
-  // Deletes blocks that are not enabled so they will get re-hashed.
-  db_delete('block')
-    ->condition('module', 'facetapi')
-    ->condition('status', 0)
-    ->execute();
-
-  // Rehashes deltas of enabled facet blocks.
-  $result = db_query("SELECT delta, bid FROM {block} WHERE module = 'facetapi'");
-  foreach ($result as $record) {
-    $current_search = FALSE;
-
-    // Extracts the searcher, realm name, and facet name from $delta.
-    // Process the parts from the end in case the searcher includes a ':'.
-    $parts = explode(':', $record->delta);
-    $facet_name = array_pop($parts);
-    $realm_name = array_pop($parts);
-    $searcher = implode(':', $parts);
-
-    // We are viewing the current search block.
-    if (!$searcher && 'current_search' == $facet_name) {
-      $current_search = TRUE;
-    }
-
-    // If we don't have a searcher and we aren't viewing the current search
-    // block, delta is probably hashed and we should continue to the next one.
-    if (!$current_search && !$searcher) {
-      // Let's do some block cleanup. Anything less that 32 chars is NOT a hash
-      // and doesn't need to be in the database.
-      if (strlen($record->delta) == 32) {
-        continue;
-      }
-      else {
-        db_delete('block')
-          ->condition('bid', $record->bid)
-          ->execute();
-      }
-    }
-
-    // Hashes the delta and updates.
-    $delta = substr(drupal_hash_base64($record->delta), 0, 32);
-    db_update('block')
-      ->fields(array('delta' => $delta))
-      ->condition('module', 'facetapi')
-      ->condition('delta', $record->delta)
-      ->execute();
-  }
-}
-
-/**
- * Ensures hashes are alpha-numeric.
- */
-function facetapi_update_7002() {
-
-  // Updates the block table with alpha-numeric hashes.
-  $result = db_query("SELECT delta, bid FROM {block} WHERE module = 'facetapi'");
-  foreach ($result as $record) {
-    $hash = strtr($record->delta, array('-' => '0', '_' => '1'));
-    db_update('block')
-      ->fields(array('delta' => $hash))
-      ->condition('module', 'facetapi')
-      ->condition('delta', $record->delta)
-      ->execute();
-  }
-
-  // Clears the delta cache.
-  cache_clear_all('facetapi:delta_map', 'cache');
-}
-
-/**
- * Increase the length of the facetapi.facet column.
- */
-function facetapi_update_7101() {
-  // Change the length of the facet field.
-  db_change_field('facetapi', 'facet', 'facet', array(
-    'description' => 'The machine readable name of the facet.',
-    'type' => 'varchar',
-    'length' => 255,
-    'not null' => TRUE,
-    'default' => '',
-  ));
+  // Remove tables.
+  drupal_uninstall_schema('facetapi');
 }
diff --git a/facetapi.module b/facetapi.module
index c11218f..2602323 100644
--- a/facetapi.module
+++ b/facetapi.module
@@ -68,6 +68,10 @@ define('FACETAPI_REGEX_DATE_RANGE', '/^\[(' . trim(FACETAPI_REGEX_DATE, '/^$') .
 // Calls block specific hooks and overrides.
 require_once dirname(__FILE__) . '/facetapi.block.inc';
 
+function facetapi_init() {
+  module_load_include('inc', 'facetapi', 'facetapi.facetapi');
+}
+
 /**
  * Implements hook_facetapi_hook_info().
  */
@@ -328,7 +332,7 @@ function facetapi_permission() {
  *   The adapter object, FALSE if the object can't be loaded.
  */
 function facetapi_adapter_load($searcher) {
-  $adapters = &drupal_static(__FUNCTION__, array());
+  static $adapters = array();
   if (!isset($adapters[$searcher])) {
     $searcher_info = facetapi_get_searcher_info();
     if (isset($searcher_info[$searcher]['adapter'])) {
@@ -553,7 +557,7 @@ function facetapi_get_searcher_info() {
  *   An associative array of active adapters
  */
 function facetapi_get_active_searchers() {
-  $searchers = &drupal_static('facetapi_active_searchers', array());
+  static $searchers = array();
   return $searchers;
 }
 
@@ -566,7 +570,7 @@ function facetapi_get_active_searchers() {
  *   facetapi_realm_load() function for the structure of the definitions.
  */
 function facetapi_get_realm_info() {
-  $realm_info = &drupal_static(__FUNCTION__);
+  static $realm_info;
   if (NULL === $realm_info) {
     $realm_info = module_invoke_all('facetapi_realm_info');
     foreach ($realm_info as $realm_name => $realm) {
@@ -582,7 +586,7 @@ function facetapi_get_realm_info() {
       );
     }
     drupal_alter('facetapi_realm_info', $realm_info);
-    uasort($realm_info, 'drupal_sort_weight');
+    uasort($realm_info, 'facetapi_sort_weight');
   }
   return $realm_info;
 }
@@ -599,7 +603,7 @@ function facetapi_get_realm_info() {
  *   facetapi_facet_load() function for the structure of the definitions.
  */
 function facetapi_get_facet_info($searcher) {
-  $facet_info = &drupal_static(__FUNCTION__, array());
+  static $facet_info = array();
 
   // Gets facet info if we haven't gotten it already.
   if (!isset($facet_info[$searcher])) {
@@ -666,7 +670,7 @@ function facetapi_get_facet_info($searcher) {
     // Invokes alter hook, sorts and returns.
     drupal_alter('facetapi_facet_info', $facet_info[$searcher], $searcher_info[$searcher]);
     array_walk($facet_info[$searcher], 'facetapi_map_assoc', 'field api bundles');
-    uasort($facet_info[$searcher], 'drupal_sort_weight');
+    uasort($facet_info[$searcher], 'facetapi_sort_weight');
   }
 
   return $facet_info[$searcher];
@@ -701,7 +705,7 @@ function facetapi_map_assoc(&$array, $name, $key) {
  *   - weight: The default weight of the sort specifying its processing order.
  */
 function facetapi_get_sort_info() {
-  $sort_info = &drupal_static(__FUNCTION__);
+  static $sort_info;
   if (NULL === $sort_info) {
     $sort_info = module_invoke_all('facetapi_sort_info');
     foreach ($sort_info as $sort_name => $info) {
@@ -775,7 +779,7 @@ function facetapi_get_filters(array $facet) {
  *   facetapi_facet_load() function for the structure of the definitions.
  */
 function facetapi_get_enabled_facets($searcher, $realm_name = NULL) {
-  $enabled_facets = &drupal_static(__FUNCTION__, array());
+  static $enabled_facets = array();
   $cid = $searcher . ':' . (string) $realm_name;
   if (!isset($enabled_facets[$cid])) {
     // Builds array of aruments to pass to ctools_export_load_object().
@@ -932,7 +936,7 @@ function facetapi_is_active_searcher($searcher) {
  * @see facetapi_get_active_searchers();
  */
 function facetapi_add_active_searcher($searcher) {
-  $searchers = &drupal_static('facetapi_active_searchers', array());
+  static $searchers = array();
   $searchers[$searcher] = $searcher;
 }
 
@@ -1018,16 +1022,19 @@ function facetapi_check_requirements(array $requirements, array $realm, array $f
  *   TRUE, the list of enabled facets won't be rebuild and the active items
  *   won't be re-processed.  Note that these tasks will have to be performed
  *   manually in order for the status to be properly set.
+ * @todo Make sure we convert this static logic
  */
 function facetapi_set_facet_status($searcher, $realm_name, $facet_name, $status, $batch_process) {
   // Rebuild static if not batch processing.
   if (!$batch_process) {
-    drupal_static('facetapi_get_enabled_facets', array(), TRUE);
+    static $enabled_facets;
+    $enabled_facets = NULL;
+    //drupal_static('facetapi_get_enabled_facets', array(), TRUE);
   }
 
   // Pulls the list of enabled facets so we can modify it here.
   facetapi_get_enabled_facets($searcher, $realm_name);
-  $enabled_facets = &drupal_static('facetapi_get_enabled_facets', array());
+  static $enabled_facets = array();
 
   // Performs the operation by setting or unsetting the facet.
   $cid = $searcher . ':' . (string) $realm_name;
@@ -1124,8 +1131,9 @@ function facetapi_set_facet_disabled($searcher, $realm_name, $facet_name, $batch
  * @param $batch_process
  *   A boolean flagging whether batch processing is being performed.  If set to
  *   TRUE, the caches and statics won't be reset.
+ * @todo Make sure we clear this static
  *
- * @reutrn
+ * @return
  *   TRUE if the operation succeeded, FALSE otherwise.
  */
 function facetapi_save_facet_status(FacetapiAdapter $adapter, array $realm, array $facet, $status, $weight, $batch_process) {
@@ -1142,7 +1150,9 @@ function facetapi_save_facet_status(FacetapiAdapter $adapter, array $realm, arra
 
   // Clears caches and statics if we are not batch processing.
   if ($success && !$batch_process) {
-    drupal_static('facetapi_get_enabled_facets', array(), TRUE);
+    //drupal_static('facetapi_get_enabled_facets', array(), TRUE);
+    static $enabled_facets;
+    $enabled_facets = NULL;
     if ('block' == $realm['name']) {
       cache_clear_all(NULL, 'cache_block');
       cache_clear_all('facetapi:delta_map', 'cache');
@@ -1195,3 +1205,19 @@ function facetapi_save_facet_enabled(FacetapiAdapter $adapter, array $realm, arr
 function facetapi_save_facet_disabled(FacetapiAdapter $adapter, array $realm, array $facet, $weight = FALSE, $batch_process = FALSE) {
   return facetapi_save_facet_status($adapter, $realm, $facet, FALSE, $weight, $batch_process);
 }
+
+/**
+ * Sorts array items on their weight
+ *
+ * @param array item $a
+ * @param array item $b
+ * @return boolean true if lighter
+ */
+function facetapi_sort_weight($a, $b) {
+  $a_weight = (is_array($a) && isset($a['weight'])) ? $a['weight'] : 0;
+  $b_weight = (is_array($b) && isset($b['weight'])) ? $b['weight'] : 0;
+  if ($a_weight == $b_weight) {
+    return 0;
+  }
+  return ($a_weight < $b_weight) ? -1 : 1;
+}
\ No newline at end of file
diff --git a/plugins/facetapi/adapter.inc b/plugins/facetapi/adapter.inc
index 162cf7f..b9cdb69 100644
--- a/plugins/facetapi/adapter.inc
+++ b/plugins/facetapi/adapter.inc
@@ -405,7 +405,7 @@ abstract class FacetapiAdapter {
   /**
    * Allows for backend specific overrides to the settings form.
    */
-  public function settingsForm(&$form, &$form_state) {
+  public function settingsForm(&$form_state) {
     // Nothing to do...
   }
 
@@ -991,7 +991,7 @@ class FacetapiFacet implements ArrayAccess {
     // Executes filter plugins.
     // @todo Defensive coding here for filters?
     $enabled_filters = array_filter($settings->settings['filters'], 'facetapi_filter_disabled_filters');
-    uasort($enabled_filters, 'drupal_sort_weight');
+    uasort($enabled_filters, 'facetapi_sort_weight');
     foreach ($enabled_filters as $filter_id => $filter_settings) {
       if ($class = ctools_plugin_load_class('facetapi', 'filters', $filter_id, 'handler')) {
         $filter_plugin = new $class($filter_id, $this->adapter, $settings);
diff --git a/plugins/facetapi/url_processor_standard.inc b/plugins/facetapi/url_processor_standard.inc
index 2444c08..1c8c2ec 100644
--- a/plugins/facetapi/url_processor_standard.inc
+++ b/plugins/facetapi/url_processor_standard.inc
@@ -79,7 +79,7 @@ class FacetapiUrlProcessorStandard extends FacetapiUrlProcessor {
     // Adds the current search to the query.
     if ($keys) {
       // The last item should be text, not a link.
-      $breadcrumb[] = $active_items ? l($keys, current_path(), array('query' => $query)) : check_plain($keys);
+      $breadcrumb[] = $active_items ? l($keys, $_GET['q'], array('query' => $query)) : check_plain($keys);
     }
 
     // Adds filters to the breadcrumb trail.
@@ -96,7 +96,7 @@ class FacetapiUrlProcessorStandard extends FacetapiUrlProcessor {
       }
       else {
         // Appends the filter to the breadcrumb trail.
-        $breadcrumb[] = l($value['#markup'], current_path(), array('query' => $query, 'html' => !empty($value['#html'])));
+        $breadcrumb[] = l($value['#markup'], $_GET['q'], array('query' => $query, 'html' => !empty($value['#html'])));
       }
     }
 
diff --git a/plugins/facetapi/widget.inc b/plugins/facetapi/widget.inc
index 19aba59..9f102d4 100644
--- a/plugins/facetapi/widget.inc
+++ b/plugins/facetapi/widget.inc
@@ -208,7 +208,7 @@ abstract class FacetapiWidget {
     }
 
     // Orders the sorts, applies sorting algorithms in that order.
-    uasort($this->sorts, 'drupal_sort_weight');
+    uasort($this->sorts, 'facetapi_sort_weight');
     $this->applySorts($build[$this->facet['field alias']]);
   }
 
diff --git a/tests/facetapi.test b/tests/facetapi.test
index db97a74..9102708 100644
--- a/tests/facetapi.test
+++ b/tests/facetapi.test
@@ -84,7 +84,9 @@ class FacetapiTestCase extends DrupalWebTestCase {
     // We have to clear the static cache otherwise this test won't work. This is
     // OK because the script execution persists when the form is submitted by
     // the test unlike a real form post where the page has to reload.
-    drupal_static('facetapi_get_enabled_facets', array(), TRUE);
+    static $enabled_facets;
+    $enabled_facets = NULL;
+    //drupal_static('facetapi_get_enabled_facets', array(), TRUE);
 
     // Tests the status of the enabled facet.
     $value = facetapi_facet_enabled('facetapi_test', $realm_name, $facet_name);
