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 838c2b8..c8570f3 100644
--- a/view_alias.module
+++ b/view_alias.module
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * Hook implementations for view alias module integration.
@@ -7,47 +6,41 @@
  * @ingroup pathauto
  */
 
-
 /**
- * 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'] = '';
-      $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.');
+      $settings['token_type'] = 'term'; //view_alias
       
-      // left out patterns since we dont use them.
-      $settings['placeholders'] = array( t('[cat-raw]'), t('The View argument taxonomy name'));
+      $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';
 
-      $settings['patternitems'] = array();
       return (object) $settings;
-
-    default:
       break;
   }
 }
 
+
+function view_alias_siple_path($path) {
+  return str_replace(array('%/', '%'), '', $path);
+}
+//function view_alias_create_multiple($vid,$alias,$op) {
 /**
- * 
- * 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 = _gather_terms_for_alias($alias->varg);
-
+    if (variable_get('pathauto_view_alias_' . view_alias_siple_path($alias->path), FALSE)) {
+      $terms = taxonomy_get_tree(view_alias_first_vid($alias->vid));
       foreach ($terms as $term) {
         view_alias_create_alias($term, $alias, 'bulkupdate');
       }
@@ -55,91 +48,176 @@ function view_alias_pathauto_bulkupdate() {
   }
 }
 
-function _gather_terms_for_alias($validator_vocab_ids) {
-  $vocabs = explode(",", $validator_vocab_ids);
-
-  $terms_to_alias = array();
-
-  foreach($vocabs as $vocab) {
-    $terms = taxonomy_get_tree($vocab);
-    $terms_to_alias = array_merge($terms_to_alias, $terms);
-  }
-
-  return $terms_to_alias;
-}
-
 /**
- *
- * 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 %path', array('%path' => $alias->path));
+  foreach ($aliasable as $alias) {
+    $objects[view_alias_siple_path($alias->path)] = t("View page displays having a path of '" . $alias->path . "'");
   }
 
   return $objects;
 }
 
+function view_alias_first_vid($vids) {
+  foreach ($vids as $id => $vid) {
+    return $id;
+  }
+  return FALSE;
+}
+
+function view_alias_vids_tail($vids) {
+  $newvids = array();
+  $first = TRUE;
+  foreach ($vids as $key => $val) {
+    if ($first) {
+      $first = FALSE;
+      continue; //skip the first
+    }
+    $newvids[$key] = $val;
+  }
+  return $newvids;
+}
 /**
- *
- * 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') {
+function view_alias_form_alter(&$form, &$form_state, $form_id) {
 
-    unset($form['view_alias']['pathauto_view_alias_pattern']);
+  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(view_alias_first_vid($alias->vid));
+      $form['view_alias']['views_to_alias']['pathauto_view_alias_' . view_alias_siple_path($alias->path)] = array(
         '#type' => 'checkbox',
-        '#title' => t('View %view, display %display, on path %path, with %vocab arguments.',
-          array(
-            '%view'     => $alias->view_name,
-            '%display'  => $alias->display_name,
-            '%path'     => $alias->path,
-            '%vocab'    => $voc->name
-          )
-        ),
+        '#title' => t('View <strong> @view_name' . '</strong>, display <strong> @display_name' . '</strong>, on path <strong>@path' . '</strong>, with <strong>@name' . '</strong> arguments.', array('@view_name' => $alias->view_name, '@display_name' => $alias->display_name, '@path' => $alias->path, '@name' => $voc->name)),
         '#weight' => -1,
-        '#default_value' => variable_get("pathauto_view_alias_{$alias->path}", 0),
+        '#default_value' => variable_get("pathauto_view_alias_" . view_alias_siple_path($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);
+function view_alias_taxonomy_term_insert($term) {
+  $aliasable = _get_aliasable_displays();
+  foreach ($aliasable as $alias) {
+    if (in_array($term->vid, array_keys($alias->vid))) {
+      view_alias_create_alias($term, $alias, 'update');
+    }
+  }
+}
+
+/**
+ * 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 (in_array($term->vid, array_keys($alias->vid))) {
+      view_alias_delete_alias($term, $alias);
+    }
+  }
+}
+
+function view_alias_generate_multiple($vids, $term, $op, $pattern, $data, &$alias_path) {    
+    if (count($vids) == 0) { //Generate aliases as we are in the end level of all args.
+      $langs = array_keys(language_list());
+      $langs[] = LANGUAGE_NONE;
+
+      $source = str_replace(array_keys($data['ids']), array_values($data['ids']), $pattern);
+      
+      foreach ($langs as $lang) {
+        $parts = explode('/', $pattern);
+        $viewpath = $parts[0];
+        $parts[0] = t($parts[0], array(), array('context' => 'view_alias', 'langcode' => $lang)); //translate the first part of the view
+        $translatedPattern = implode('/', $parts);
+
+        variable_set('pathauto_view_alias_pattern', $translatedPattern);
+                      
+        $translatedData = array();;
+        foreach ($data['data'] as $key => $title) {
+          if (intval($data['ids'][$key]) == 0) { //All exception.
+            $translatedData[$key] = t($title, array(), array('context' => 'view_alias', 'langcode' => $lang)); //translate the first part of the view
+          }
+          else{
+            $translatedData[$key] = i18n_string("taxonomy:term:{$data['ids'][$key]}:name", $title, array('langcode' => $lang));
+          }
         }
-        else {
-          view_alias_create_alias($term, $alias, $op);
+
+        $ap = pathauto_create_alias('view_alias', 
+                                            $op, 
+                                            $source, 
+                                            $translatedData,
+                                            'view_alias_' . $viewpath, 
+                                            $lang);
+         if ($ap) {
+           $alias_path[] = $ap;
+         }
+      }      
+    }
+    else {
+      $vid = view_alias_first_vid($vids);      
+            
+      if (isset($vids[$vid]['exception']['value'])) {
+        $all = new stdClass();      
+        $all->tid = $vids[$vid]['exception']['value'];
+        $all->vid = $vid;
+        $all->name = $vids[$vid]['exception']['value'];        
+      }
+      if ($vid != $term->vid) {        
+        $terms = taxonomy_get_tree($vid);
+        if (isset($all)) {
+          $terms = array_merge_recursive(array(0 => $all), $terms);
+        }
+      }
+      else {
+        $terms = array($term->tid => $term);
+        if ($op == 'bulkupdate' && isset($all)) {
+          $terms = array_merge_recursive(array(0 => $all), $terms); //Generete terms also for all.
         }
       }
+      
+      foreach ($terms as $t) {    
+        $data['ids']['[view_alias:name' . $vid . ']']   = $t->tid;        
+        $data['data']['[view_alias:name' . $vid . ']']  = $t->name;           
+        view_alias_generate_multiple(view_alias_vids_tail($vids), $term, $op, $pattern, $data, $alias_path);
+      }
     }
-  }
+    return $alias_path;
+}
+
+function view_alias_tokens($type, $tokens, $data = array(), $options = array()) {
+    $replacements = array();
+    $sanitize = !empty($options['sanitize']);
+
+    if (substr($type, 0, 10) == 'view_alias') {
+      return $data;
+    }
+
+    return $replacements;
 }
 
 /**
@@ -147,24 +225,35 @@ 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]";
+    $source = $alias->path . '/' . $term->tid;
+    variable_set('pathauto_view_alias_pattern', $alias->path . '/[term:name]');
+    $data = array('term' => $term);
+    $alias_path = array( 0 => pathauto_create_alias('view_alias', $op, $source, $data, NULL, LANGUAGE_NONE));
+    return $alias_path;    
   }
-  else {
-    $source = str_replace('%', $term->tid, $alias->path);
-    $GLOBALS['conf']['pathauto_view_alias_pattern'] = str_replace('%', '[cat-raw]', $alias->path);
+  else {    
+    /**IDYNAMIC PATCHED for multiple terms*/
+    $pattern = $alias->path;
+    foreach ($alias->vid as $vid => $vargs) {      
+      $pattern = preg_replace('/\%/', '[view_alias:name' . $vid . ']', $pattern, 1);
+    }
+    if ($pattern == '') {
+      exit('empty pattern');  
+    }
+    $data = $alias_path = array();
+    view_alias_generate_multiple($alias->vid, $term, $op, $pattern, $data, $alias_path);
+    
+//    $source = str_replace('%', $term->tid, $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));   
+//    $data = array('term' => $term);
+//    $alias_path = pathauto_create_alias('view_alias', $op, $source, $data, NULL, LANGUAGE_NONE);
   }
-
-  $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']);
   return $alias_path;
 }
 
@@ -172,60 +261,70 @@ function view_alias_create_alias($term, $alias, $op) {
  * Delete an alias set by View Alias.
  */
 function view_alias_delete_alias($term, $alias) {
-  $alias_path = view_alias_create_alias($term, $alias, 'update');
-  path_set_alias(NULL, $alias_path);
+  $alias_path = view_alias_create_alias($term, $alias, 'return');
+  /**IDYNAMIC PATCHED*/
+  foreach ($alias_path as $alias) {
+    path_delete(array('alias' => $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 {
+        // 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'];
         $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[$alias->path] = clone($alias);
+      }
     }
-
   }
 
   return $aliasable_views;
@@ -235,16 +334,21 @@ 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));
-
-    $view_args = implode(",", $no_zeroes);
-    return $view_args;
+  
+  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] = $view_arg;
+        }
+      }
+    }
   }
-  return FALSE; 
-}
+  return $vids;
+}
\ No newline at end of file
