diff --git a/view_alias.info b/view_alias.info
index 485a401..1a6d5f9 100644
--- a/view_alias.info
+++ b/view_alias.info
@@ -1,6 +1,12 @@
-name = ViewAlias
-description = enhance pathauto to create path alias based on views and term arguments.
-core = 6.x
-package = Other
+name = View Alias
+description = Enhance pathauto to create path alias based on views with term arguments.
+core = 7.x
+package = Views
+
+
 dependencies[] = pathauto
-dependencies[] = views 
+dependencies[] = views
+
+
+; Handlers
+files[] = view_alias.module
diff --git a/view_alias.module b/view_alias.module
index 991da75..605e39c 100644
--- a/view_alias.module
+++ b/view_alias.module
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * Hook implementations for view alias module integration.
@@ -8,41 +7,35 @@
  */
 
 /**
- * Implementation of hook_pathauto().
+ * Implements hook_pathauto().
  */
 function view_alias_pathauto($op) {
   switch ($op) {
     case 'settings':
+
       $settings = array();
       $settings['module'] = 'view_alias';
-      $settings['token_type'] = 'view_alias';
-      $settings['groupheader'] = t('View Alias settings');
-      $settings['patterndescr'] = t('Default View Alias pattern (applies to all views with a term argument and page display)');
-      $settings['patterndefault'] = t('');
-      $settings['bulkname'] = t('Bulk generate aliases for views with term arguments that are not aliased');
-      $settings['bulkdescr'] = t('Generate aliases for all existing views with term arguments which do not already have aliases.');
-      
-      // left out patterns since we dont use them.
-      $settings['placeholders'] = array( t('[cat-raw]'), t('The View argument taxonomy name'));
+      $settings['token_type'] = 'term'; //view_alias
       
-      $settings['patternitems'] = array();
-      return (object) $settings;
+      $settings['groupheader'] = t('View Alias Paths');
+      $settings['patterndescr'] = t('Default View Alias pattern (applies to all views with a term argument and page display)');
+      $settings['patterndefault'] = ''; // Not used
+            
+      $settings['batch_update_callback'] = 'view_alias_bulk_update_batch_process';
 
-    default:
+      return (object) $settings;
       break;
   }
 }
 
 /**
- * 
- * Do the bulk updating for view aliases
- *
+ * Batch processing callback; Generate aliases for taxonomy terms.
  */
-function view_alias_pathauto_bulkupdate() {
+function view_alias_bulk_update_batch_process(&$context) {
   $aliasable = _get_aliasable_displays();
   foreach ($aliasable as $alias) {
-    if (variable_get("pathauto_view_alias_{$alias->path}", FALSE)) {
-      $terms = taxonomy_get_tree($alias->varg);
+    if (variable_get('pathauto_view_alias_' . $alias->path, FALSE)) {
+      $terms = taxonomy_get_tree($alias->vid);
       foreach ($terms as $term) {
         view_alias_create_alias($term, $alias, 'bulkupdate');
       }
@@ -51,68 +44,76 @@ function view_alias_pathauto_bulkupdate() {
 }
 
 /**
- *
- * Implementation of hook_path_alais_types from pathauto
+ * Implements hook_path_alias_types().
  * allows me to hook into the bulk delete
- *
  */
 function view_alias_path_alias_types() {
   $aliasable = _get_aliasable_displays();
-  foreach($aliasable as $alias) {
-    $objects["$alias->path"] = t("View page displays having a path of '$alias->path'");
+  foreach ($aliasable as $alias) {
+    $objects[$alias->path] = t("View page displays having a path of '" . $alias->path . "'");
   }
 
-  return $objects;  
+  return $objects;
 }
 
 /**
- *
- * Implementation of hook_form_alter
- * remove the default form settings and add our own since view alias are different from the regular
- * alaises
- *
+ * Implements hook_form_alter().
+ * remove the default form settings and add our own since view alias are different from the regular aliases
  */
-function view_alias_form_alter(&$form, $form_state, $form_id) {
-  if($form_id == 'pathauto_admin_settings') {
-    
-    unset($form['view_alias']['pathauto_view_alias_pattern']);
+function view_alias_form_alter(&$form, &$form_state, $form_id) {
+
+  if ($form_id == 'pathauto_patterns_form') {
     unset($form['view_alias']['token_help']);
+    unset($form['view_alias']['pathauto_view_alias_pattern']);
+    
     $form['view_alias']['views_to_alias'] = array(
       '#type' => 'fieldset',
-      '#title' => t('Views available for aliasing'),
-      '#description' => t('Check the views for which aliases should be bulk generated.'),
+      '#title' => 'Views available for aliasing',
+      '#description' => 'Check the views for which aliases should be bulk generated.',
       '#weight' => -1,
     );
 
     $aliasable = _get_aliasable_displays();
-    foreach($aliasable as $alias) {
-      $voc = taxonomy_vocabulary_load($alias->varg);
-      $form['view_alias']['views_to_alias']["pathauto_view_alias_{$alias->path}"] = array(
+    foreach ($aliasable as $alias) {
+      $voc = taxonomy_vocabulary_load($alias->vid);
+      $form['view_alias']['views_to_alias']['pathauto_view_alias_' . $alias->path] = array(
         '#type' => 'checkbox',
-        '#title' => t("View $alias->view_name, display $alias->display_name, on path $alias->path, with $voc->name arguments."),
+        '#title' => 'View <strong>' . $alias->view_name . '</strong>, display <strong>' . $alias->display_name . '</strong>, on path <strong>' . $alias->path . '</strong>, with <strong>' . $voc->name . '</strong> arguments.',
         '#weight' => -1,
-        '#default_value' => variable_get("pathauto_view_alias_{$alias->path}", 0),
+        '#default_value' => variable_get("pathauto_view_alias_" . $alias->path, 0),
       );
     }
   }
 }
 
 /**
- * Implementation of hook_taxonomy().
+ * Implements hook_taxonomy_term_insert().
  */
-function view_alias_taxonomy($op, $type, $array = NULL) {
-  if ($type == 'term') {
-    $term = (object) $array;
-    $aliasable = _get_aliasable_displays();
-    foreach ($aliasable as $alias) {
-      if ($alias->varg == $term->vid) {
-        if ($op == 'delete') {
-          view_alias_delete_alias($term, $alias);
-        }
-        else {
-          view_alias_create_alias($term, $alias, $op);
-        }
-      }
+function view_alias_taxonomy_term_insert($term) {
+  $aliasable = _get_aliasable_displays();
+  foreach ($aliasable as $alias) {
+    if ($alias->vid == $term->vid) {
+      view_alias_create_alias($term, $alias, $op);
+    }
+  }
+}
+
+/**
+ * Implements hook_taxonomy_term_update().
+ */
+function view_alias_taxonomy_term_update($term) {
+  view_alias_taxonomy_term_delete($term);
+  view_alias_taxonomy_term_insert($term);
+}
+
+/**
+ * Implements hook_taxonomy_term_delete().
+ */
+function view_alias_taxonomy_term_delete($term) {
+  $aliasable = _get_aliasable_displays();
+  foreach ($aliasable as $alias) {
+    if ($alias->vid == $term->vid) {
+      view_alias_delete_alias($term, $alias);
     }
   }
 }
@@ -122,24 +123,22 @@ function view_alias_taxonomy($op, $type, $array = NULL) {
  */
 function view_alias_create_alias($term, $alias, $op) {
   module_load_include('inc', 'pathauto');
-  
+
   // switch around the pattern based on if the term id is contained within the new alias
-  if (strpos($alias->path, '%') === FALSE) {    
-    $source = "$alias->path/$term->tid";
-    $GLOBALS['conf']['pathauto_view_alias_pattern'] = $alias->path."/[cat-raw]";
+  if (strpos($alias->path, '%') === FALSE) {
+    $source = $alias->path . '/' . $term->tid;
+    variable_set('pathauto_view_alias_pattern', $alias->path . '/[term:name]');
   }
   else {
     $source = str_replace('%', $term->tid, $alias->path);
-    $GLOBALS['conf']['pathauto_view_alias_pattern'] = str_replace('%', '[cat-raw]', $alias->path);
+    /*
+      TODO Be more accurate with which url param gets swapped out for the term argument based on index on the view
+    */
+    variable_set('pathauto_view_alias_pattern', str_replace('%', '[term:name]', $alias->path));
   }
-  
-  $placeholders = array(
-    'tokens' => array(t('[cat-raw]')),
-    'values' => array(pathauto_cleanstring($term->name)),
-  );
-  
-  $alias_path = pathauto_create_alias('view_alias', $op, $placeholders, $source, $alias->path);
-  unset($GLOBALS['conf']['pathauto_view_alias_pattern']);
+
+  $data = array('term' => $term);
+  $alias_path = pathauto_create_alias('view_alias', $op, $source, $data);
   return $alias_path;
 }
 
@@ -155,52 +154,60 @@ function view_alias_delete_alias($term, $alias) {
  *
  * find the views that can be aliased.
  * that means have a path url and use a term id as an argument
- * build and array of objects, keyed with the view name, having the view path, and the vocab id for the terms used
+ * build and array of objects, keyed with the view name, having the view path, and the vocabulary id for the terms used
  * array(
- *   0 => 
- *     object ( 
+ *   0 =>
+ *     object (
  *       'view_name' -> 'viewname'
  *       'display_name' -> 'display name'
  *       'path' -> 'view url path'
- *       'varg' -> 'vocabulary id'
- *     ) 
+ *       'vid' -> 'vocabulary id'
+ *     )
  * )
  */
 function _get_aliasable_displays() {
   $aliasable_views = array();
 
-  $sql = "SELECT DISTINCT(vv.name) FROM {views_view} vv JOIN {views_display} vd ";
-  $sql .= "ON vv.vid = vd.vid where vd.display_plugin = 'page'";
-  
-  $result = db_query($sql);
-  while($row = db_fetch_object($result)) {
+  $query = db_select('views_view', 'vv');
+  $query->join('views_display', 'vd', 'vv.vid = vd.vid');
+  $query->fields('vv', array('name'));
+  //$query->condition('vd.display_plugin', 'page', '=');
+  $results = $query->execute();
+
+  while ($row = $results->fetchObject()) {
+
     $aview = views_get_view($row->name);
-    $alias = NULL;
+    $alias = new stdClass;
     $alias->view_name = $row->name;
     $default_vocab_arg;
-    
-    foreach($aview->display as $key => $display) {
-      // check default for args and save for later
+
+    foreach ($aview->display as $key => $display) {
+      
       $alias->display_name = $key;
       
-      if($key == 'default') {
-        $alias->varg = _find_view_arguments($display);
+        // check default for args and save for later
+      if ($key == 'default') {
+        $alias->vid = _find_view_arguments($display);
         continue;
       }
       // its some sort of page cause the query says so.
       else {
-        //dpr($display);
+        // Skip of display doesn't have a path
+        if (empty($display->display_options['path'])) {
+          continue;
+        }
+
         // add the page and replace overridden args.
-        $alias->path = $display->display_options['path'];       
+        $alias->path = $display->display_options['path'];
         $overridden = _find_view_arguments($display);
-        if($overridden) { 
-          $alias->varg = $overridden;
+        if ($overridden) {
+          $alias->vid = $overridden;
         }
       }
-      if(!empty($alias->path) && !empty($alias->varg))   
-        $aliasable_views[] = drupal_clone($alias);
+      if (!empty($alias->path) && !empty($alias->vid)) {
+        $aliasable_views[] = clone($alias);
+      }
     }
-
   }
 
   return $aliasable_views;
@@ -210,14 +217,24 @@ function _get_aliasable_displays() {
  * helper to dig out the view arguments.
  */
 function _find_view_arguments($display) {
-  $dis_args = $display->display_options['arguments']['tid'];
-  // array_sum is used since if no vocabularies are selected, the sum of the argumets will be 0
-  // and we need to make sure there is a vocabular set.
-
-  if($dis_args['validate_argument_type'] == 'tid' && array_sum($dis_args['validate_argument_vocabulary']) > 0) {
-    // remove zero entries
-    $no_zeroes = array_diff($dis_args['validate_argument_vocabulary'], array(0));
-    return implode(",", $no_zeroes);
+  
+  if (empty($display->display_options['arguments'])) 
+    return FALSE;
+  $view_args = $display->display_options['arguments'];
+  
+  $vids = array();
+  foreach ($view_args as $view_arg) {
+    if (isset($view_arg['validate']['type']) && $view_arg['validate']['type'] == 'taxonomy_term') {
+      if (!empty($view_arg['validate_options']['vocabularies']) && is_array($view_arg['validate_options']['vocabularies'])) {
+        foreach ($view_arg['validate_options']['vocabularies'] as $vocab_name) {
+          $vocab = taxonomy_vocabulary_machine_name_load($vocab_name);
+          $vids[] = $vocab->vid;
+        }
+      }
+    }
+  }
+  if (!empty($vids)) {
+    return implode(',', $vids);
   }
-  return FALSE; 
+  return FALSE;
 }
