diff --git a/taxonomy_filter/taxonomy_filter.module b/taxonomy_filter/taxonomy_filter.module
index 07af49e..bdbf42f 100644
--- a/taxonomy_filter/taxonomy_filter.module
+++ b/taxonomy_filter/taxonomy_filter.module
@@ -521,7 +521,21 @@ function taxonomy_filter_get_link_tids($url_tids, $item_tid, $context = NULL) {
   drupal_alter('tf_link_tids', $link_tids, $item_tid, $context);
   return $link_tids;
 }
-
+function taxonomy_filter_taxonomy_filter_format_path($tids=array(),$depth = 0,$op = '') {
+  return array(
+    '%tids'=> implode(',', $tids),
+    '%depth'=> ($depth) ? $depth : '',
+    '%op'=> ($op) ? $op : '',
+    '//'=>'/'
+  );
+}
+function taxonomy_filter_taxonomy_filter_format_path_args() {
+  return array(
+    'tids'=>'%tids',
+    'depth'=>'%depth',
+    'op'=>'%op',
+  );
+}
 /**
  * generates paths for items.
  */
@@ -529,17 +543,11 @@ function _taxonomy_filter_format_path($tids, $depth, $op = NULL) {
   // if no tids return empty path (TODO do we need this check?)
   if (!$tids) return '';
   $template = variable_get('taxonomy_filter_output', TAXONOMY_FILTER_OUTPUT);
-  $tid_str = implode(',', $tids);
-  $depth_str = ($depth) ? $depth : '';
-  $op_str = ($op) ? $op : '';
-
-  $raw_url = str_replace('%tids', $tid_str, $template);
-  $raw_url = str_replace('%depth', $depth_str, $raw_url);
-  $raw_url = str_replace('%op', $op_str, $raw_url);
-  $raw_url = str_replace('//', '/', $raw_url);
+  $replacements = module_invoke_all('taxonomy_filter_format_path',$tids,$depth,$op);
+  $raw_url = str_ireplace(array_keys($replacements),$replacements,$template);
   $raw_url = trim($raw_url, '/');
-
-  $url = drupal_get_path_alias(str_replace('%2C', ',', url($raw_url)));
+  list($path,$query) = explode('?',$raw_url);
+  $url = drupal_get_path_alias(str_replace('%2C', ',', url($path, array('query'=>$query))));
   return $url;
 }
 
@@ -564,6 +572,7 @@ function taxonomy_filter_get_url_tokens() {
     $args[] = $arg;
     $argnum++;
   }
+  $filters = array_flip(module_invoke_all('taxonomy_filter_format_path_args'));
   foreach ($filter_array as $filter_line) {
     $tids = NULL; // reset url variables
     $depth = NULL;
@@ -582,19 +591,14 @@ function taxonomy_filter_get_url_tokens() {
           break;
         }
       }
-      if ($filter_bit == '%tids') {
-        $tids = $args[$i];
-      }
-      elseif ($filter_bit == '%depth') {
-        $depth = $args[$i];
-      }
-      elseif ($filter_bit == '%op') {
-        $op = $args[$i];
+      if ($filters[$filter_bit]){
+        $tokens[$filters[$filter_bit]] = $args[$i];
       }
     }
-    if ($tids) {
-      $tokens = array('tids' => $tids, 'depth' => $depth, 'op' => $op);
-      return $tokens;
+    
+    drupal_alter('taxonomy_filter_format_path_token_arg',$tokens,$filter_line);
+    if ($tokens['tids']) {
+     return $tokens;
     }
   }
   $tokens = array('tids' => NULL, 'depth' => NULL, 'op' => NULL);
