diff --git a/handlers/lineage_handler_field.inc b/handlers/lineage_handler_field.inc
new file mode 100644
index 0000000..850213a
--- /dev/null
+++ b/handlers/lineage_handler_field.inc
@@ -0,0 +1,126 @@
+<?php
+
+/**
+ * @file
+ * Views field plugin for lineage's field handler.
+ */
+
+/**
+ * Field handler for Taxonomy: Hierarchy.
+ */
+class lineage_handler_field extends views_handler_field {
+
+  /**
+   *  Make views aware of new options 
+   */
+  function option_definition() {
+    $options = parent::option_definition();
+
+    $options['lineage'] = array();
+    $options['lineage']['strip_weights'] = array('default' => FALSE);
+    $options['lineage']['machine_safe'] = array('default' => FALSE);
+    $options['lineage']['prefix'] = array('default' => '');
+    $options['lineage']['suffix'] = array('default' => '');
+    $options['lineage']['delimiter'] = array('default' => '');
+
+    return $options;
+  }
+
+  /**
+   * Provide formatting options for the field.
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    $field = $this->content_field;
+    $options = $this->options;
+
+    $form['lineage'] = array(
+      '#type' => 'fieldset',
+      '#title' => t("Lineage string formatting options"),
+    );
+
+    $form['lineage']['strip_weights'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Strip weights'),
+      '#default_value' => $options['lineage']['strip_weights'],
+      '#description' => t("The raw lineage entries begin with a number indicating the term weight (for term ordering).  Check to remove weights for display."),
+    );
+
+    $form['lineage']['machine_safe']= array(
+      '#type' => 'checkbox',
+      '#title' => t('Machine-safe'),
+      '#default_value' => $options['lineage']['machine_safe'],
+      '#description' => t("Reformats the lineage strings for use in machine-readable contexts.  Be sure to use an appropriate term delimiter (below) and prefix text (above) if you wish this to be a CSS class name; CSS class names must begin with a letter."),
+    );
+
+    $form['lineage']['prefix'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Term prefix'),
+      '#default_value' => $options['lineage']['prefix'],
+      '#description' => t("Appended before each term name in the lineage.  You may include HTML."),
+    );
+
+    $form['lineage']['suffix'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Term suffix'),
+      '#default_value' => $options['lineage']['suffix'],
+      '#description' => t("Appended before each term name in the lineage.  You may include HTML."),
+    );
+
+    $form['lineage']['delimiter'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Delimiter between terms'),
+      '#default_value' => $options['lineage']['delimiter'],
+      '#description' => t("Use %linebreak_code for line breaks.", array('%linebreak_code' => '\n')),
+    );
+  }
+
+
+  /**
+   * Render the field.
+   */
+  function render($values) {
+    $options = $this->options ? $this->options : array();
+    if ($options['lineage']) {
+        extract($options['lineage']);
+    }
+
+    $lineage_string = $values->{$this->field_alias};
+
+    if ($lineage_string == '') {
+      return '';
+    }
+
+    // Split hierarchy string into hierarchical path pieces.
+    // Term entries are separated by \n; trim so we don't add empty pieces.
+    $term_strings = explode("\n", trim($lineage_string));
+
+    // Compose the rendered hierarchy according to handler form options.
+
+    if ($strip_weights) {
+      $term_strings = array_map("lineage_strip_weight", $term_strings);
+    }
+
+    if ($machine_safe) {
+      // Replace non-alphanumeric characters with a hyphen.
+      $non_alphanumeric = '/[^a-zA-Z0-9]+/ ';
+      $term_strings = preg_replace($non_alphanumeric, '-', $term_strings);
+    }
+
+    if ($prefix || $suffix) {
+      foreach ($term_strings as $key => $term_string) {
+        $term_string = $prefix . $term_string . $suffix;
+        $term_strings[$key] = $term_string;
+      }
+    }
+
+    // The user may enter "\n" for a linebreak delimiter;
+    // replace with actual linebreak character.
+    $delimiter = str_replace("\\n", "\n", $delimiter);
+
+    $rendered = implode($delimiter, $term_strings);
+
+    // Be sure to validate and sanitize markup since we allow HTML.
+    return filter_xss_admin($rendered);
+  }
+}
diff --git a/lineage.info b/lineage.info
index ca31b65..86b8a11 100644
--- a/lineage.info
+++ b/lineage.info
@@ -1,5 +1,13 @@
 name = Taxonomy Lineage
 description = Allows other modules to sort nodes by taxonomy hierarchies
-core = 6.x
+core = 7.x
+package = Views
+
 dependencies[] = taxonomy
 dependencies[] = views
+
+; Views handlers.
+files[] = handlers/lineage_handler_field.inc
+
+; Views plugins.
+files[] = plugins/views_plugin_style_lineage_nested.inc
diff --git a/lineage.install b/lineage.install
index e11c59a..b757e10 100644
--- a/lineage.install
+++ b/lineage.install
@@ -9,7 +9,7 @@
  * Implementation of hook_schema().
  */
 function lineage_schema() {
-  $schema['term_lineage'] = array(
+  $schema['taxonomy_term_lineage'] = array(
     'fields' => array(
       'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'lineage' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
@@ -25,31 +25,11 @@ function lineage_schema() {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_update_N().
+ *
+ * Rename the lineage table to be similar to other Drupal 7 taxonomy table names.
  */
-function lineage_install() {
-  // Create tables.
-  drupal_install_schema('lineage');
-}
-
-/**
- * Implementation of hook_uninstall().
- */
-function lineage_uninstall() {
-  drupal_uninstall_schema('lineage');
-}
-
-function lineage_update_1() {
-  return _system_update_utf8(array('term_lineage'));
-}
-
-function lineage_update_2() {
-  // fixed a bug that left the table in an inconsistent state. This should fix it.
-  return lineage_update_all();
-}
-
-function lineage_update_6000() {
-  // Changed weight string format, so trigger a full update.
-  lineage_update_all();
-  return array();
+function lineage_update_7000() {
+  db_rename_table('term_lineage', 'taxonomy_term_lineage');
+  return t('Changed the lineage data table name to <em>taxonomy_term_lineage</em>.');
 }
diff --git a/lineage.module b/lineage.module
index b7da695..c5ad4b7 100644
--- a/lineage.module
+++ b/lineage.module
@@ -1,31 +1,42 @@
 <?php
+/**
+ * @file lineage.module
+ * Module code for taxonomy term hierarchy lineage.
+ */
 
 /**
- * Implementation of hook_taxonomy().
+ * Define a base starting depth for nesting headers.
+ * We use 3 (for <h3> tags) because <h1> and <h2> are generally page titles.
  */
-function lineage_taxonomy($op, $type, $array = NULL) {
-  // we care not about vocabularies
-  if ($type == 'vocabulary') {
-    return;
+define('LINEAGE_START_DEPTH', 3);
+
+/**
+ * Implements hook_taxonomy_term_delete().
+ */
+function lineage_taxonomy_term_delete($term) {
+  db_delete('taxonomy_term_lineage')->condition('tid', $term->tid)->execute();
+}
+
+/**
+ * Implements hook_taxonomy_term_update().
+ */
+function lineage_taxonomy_term_update($term) {
+  if (arg() != array('admin', 'structure', 'taxonomy', $term->vocabulary_machine_name)) {
+    lineage_update_term($term);
   }
+}
 
-  switch ($op) {
-    case 'delete':
-      lineage_delete_term($array['tid']);
-      break;
-    case 'insert':
-    case 'update':
-      // Skip if we are on the admin reordering pages;
-      // it will happen be triggered by our submit handler after processing.
-      if (arg() != array('admin', 'content', 'taxonomy', $array['vid'])) {
-        lineage_update_term($array);
-      }
-      break;
+/**
+ * Implements hook_taxonomy_term_insert().
+ */
+function lineage_taxonomy_term_insert($term) {
+  if (arg() != array('admin', 'structure', 'taxonomy', $term->vocabulary_machine_name)) {
+    lineage_update_term($term);
   }
 }
 
 /**
- * Implements hook_form_taxonomy_overview_terms_alter().
+ * Implements hook_form_FORM_ID_alter().
  */
 function lineage_form_taxonomy_overview_terms_alter(&$form, &$form_state) {
   // Override submit handler.
@@ -40,10 +51,12 @@ function lineage_form_taxonomy_overview_terms_alter(&$form, &$form_state) {
  * the addition of lineage_update_all calls in the appropriate places.
  */
 function lineage_taxonomy_overview_terms_submit(&$form, &$form_state) {
-  if ($form_state['clicked_button']['#value'] == t('Reset to alphabetical')) {
+  if ($form_state['triggering_element']['#value'] == t('Reset to alphabetical')) {
     // Execute the reset action.
     if ($form_state['values']['reset_alphabetical'] === TRUE) {
       taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, $form_state);
+
+      // Update lineages.
       lineage_update_all($form_state['values']['vid']);
       return;
     }
@@ -53,14 +66,14 @@ function lineage_taxonomy_overview_terms_submit(&$form, &$form_state) {
     return;
   }
 
-  $order = array_flip(array_keys($form['#post'])); // Get the $_POST order.
-  $form_state['values'] = array_merge($order, $form_state['values']); // Update our original form with the new order.
+  // Sort term order based on weight.
+  uasort($form_state['values'], 'drupal_sort_weight');
 
   $vocabulary = $form['#vocabulary'];
   $hierarchy = 0; // Update the current hierarchy type as we go.
 
   $changed_terms = array();
-  $tree = taxonomy_get_tree($vocabulary['vid']);
+  $tree = taxonomy_get_tree($vocabulary->vid);
 
   if (empty($tree)) {
     return;
@@ -120,21 +133,34 @@ function lineage_taxonomy_overview_terms_submit(&$form, &$form_state) {
   }
 
   // Save all updated terms.
-  foreach ($changed_terms as $term) {
-    taxonomy_save_term($term);
+  foreach ($changed_terms as $changed) {
+    $term = (object) $changed;
+    // Update term_hierachy and term_data directly since we don't have a
+    // fully populated term object to save.
+    db_update('taxonomy_term_hierarchy')
+      ->fields(array('parent' => $term->parent))
+      ->condition('tid', $term->tid, '=')
+      ->execute();
+
+    db_update('taxonomy_term_data')
+      ->fields(array('weight' => $term->weight))
+      ->condition('tid', $term->tid, '=')
+      ->execute();
   }
 
   // Update the vocabulary hierarchy to flat or single hierarchy.
-  if ($vocabulary['hierarchy'] != $hierarchy) {
-    $vocabulary['hierarchy'] = $hierarchy;
-    taxonomy_save_vocabulary($vocabulary);
+  if ($vocabulary->hierarchy != $hierarchy) {
+    $vocabulary->hierarchy = $hierarchy;
+    taxonomy_vocabulary_save($vocabulary);
   }
+  drupal_set_message(t('The configuration options have been saved.'));
 
-  lineage_update_all($vocabulary['vid']);
+  // Rebuild lineages.
+  lineage_update_all($vocabulary->vid);
 }
 
 function lineage_enable() {
-  drupal_set_message(t("Updated @number taxonomy records.", array('@number' => lineage_update_all())));
+  drupal_set_message(t("Updated @number taxonomy lineages.", array('@number' => lineage_update_all())));
 }
 
 /**
@@ -143,42 +169,41 @@ function lineage_enable() {
  * @return $count The number of records updated.
  */
 function lineage_update_all($vid = FALSE) {
-  // If we are only updating one vocabulary, select only those terms.
-  $base_q = "SELECT td.tid, td.name, td.weight, td.vid FROM {term_data} td LEFT JOIN {term_hierarchy} th ON th.tid = td.tid WHERE th.parent = 0";
+  $query = db_select('taxonomy_term_data', 'td');
+  $query->join('taxonomy_term_hierarchy', 'th', 'th.tid = td.tid');
+
+  $query->fields('td', array('tid', 'name', 'weight', 'vid'));
+  $query->fields('th', array('parent'));
+  $query->condition('th.parent', 0);
 
+  // If we are only updating one vocabulary, select only those terms.
   if ($vid) {
-    $result = db_query($base_q . " AND td.vid = %d", $vid);
-  }
-  else {
-    $result = db_query($base_q);
+    $query->condition('td.vid', $vid);
   }
+  $result = $query->execute();
 
   $count = 0;
-  while ($term = db_fetch_object($result)) {
+  foreach ($result as $term) {
     $count += lineage_update_term($term, TRUE);
   }
   return $count;
 }
 
 function lineage_update_term($term, $all = FALSE) {
-  if (is_array($term)) {
-    $term = (object) $term;
-  }
-
   // If we are in the middle of updating all lineages, skip this.
   if (!$all) {
     // Select lineage for a different term in this vocab arbitrarily.
-    $r = db_query("
-      SELECT tl.lineage, td.tid, td.name, td.weight, td.vid, th.parent
-        FROM {term_data} td
-          LEFT JOIN {term_lineage} tl ON tl.tid = td.tid
-          LEFT JOIN {term_hierarchy} th ON td.tid = th.tid
-        WHERE td.vid = %d
-          AND td.tid <> %d
-        LIMIT 1;",
-      $term->vid, $term->tid);
-
-    $other_term = db_fetch_object($r);
+    $query = db_select('taxonomy_term_data', 'td');
+    $query->join('taxonomy_term_lineage', 'tl', 'tl.tid = td.tid');
+    $query->join('taxonomy_term_hierarchy', 'th', 'td.tid = th.tid');
+    $query->fields('tl', array('lineage'));
+    $query->fields('td', array('tid', 'name', 'weight', 'vid'));
+    $query->fields('th', array('parent'));
+    $query->condition('td.vid', $term->vid, '=');
+    $query->condition('td.tid', $term->tid, '<>');
+    $query->range(0, 1);
+
+    $other_term = $query->execute()->fetchObject();
 
     // If the lineage string doesn't match what we think it should be,
     // an update is required.
@@ -197,17 +222,30 @@ function lineage_update_term_r($term, $base, $tids = array()) {
   // Extend the base.
   $base['base'] .= lineage_string($term);
 
+  // Table wants NO NULL, so just make sure.
+  $base['depth'] = intval($base['depth']);
+
   // Update the hierarchy for the current tid.
-  db_query("DELETE FROM {term_lineage} WHERE tid = %d", $term->tid);
-  db_query("INSERT INTO {term_lineage} (tid, lineage, depth) VALUES (%d, '%s', %d)", $term->tid, $base['base'], $base['depth']);
+  db_delete('taxonomy_term_lineage')->condition('tid', $term->tid)->execute();
+  db_insert('taxonomy_term_lineage')->fields(array(
+    'tid' => $term->tid,
+    'lineage' => trim($base['base']),
+    'depth' => $base['depth']
+  ))->execute();
 
   $base['depth']++;
   // Mark that we've done this one to prevent looping.
   $tids[$term->tid] = TRUE;
 
   // Update all the children.
-  $result = db_query("SELECT td.tid, td.name, td.weight, td.vid FROM {term_hierarchy} th INNER JOIN {term_data} td ON td.tid = th.tid WHERE th.parent = %d", $term->tid);
-  while ($child = db_fetch_object($result)) {
+  $query = db_select('taxonomy_term_hierarchy', 'th');
+  $query->join('taxonomy_term_data', 'td', 'td.tid = th.tid');
+  $query->fields('td', array('tid', 'name', 'weight', 'vid'));
+  $query->condition('th.parent', $term->tid, '=');
+
+  $result = $query->execute();
+
+  foreach ($result as $child) {
     // loop protection, just in case.
     if (!isset($tids[$child->tid])) {
       $tids = lineage_update_term_r($child, $base, $tids);
@@ -216,12 +254,16 @@ function lineage_update_term_r($term, $base, $tids = array()) {
   return $tids;
 }
 
-function lineage_delete_term($tid) {
-  db_query("DELETE FROM {term_lineage} WHERE tid = %d", $tid);
-}
-
+/**
+ * Ensure positive weights with enough digits so that all sort properly.
+ *
+ * @param $term
+ *   A taxonomy term
+ *
+ * @return
+ *   A term lineage string with weight.
+ */
 function lineage_string($term) {
-  // Ensure positive weights with enough digits so that all sort properly.
   $w = _lineage_weights($term->vid);
   return sprintf("%0" . $w['digits'] . "d", $term->weight + $w['offset'])
     . "-" . $term->name . "\n";
@@ -229,8 +271,12 @@ function lineage_string($term) {
 
 /**
  * Strip the weight from the beginning of a lineage term string.
- * @param term_string one line of a lineage, with weight
- * @return one line of a lineage, with the weight removed
+ *
+ * @param $term_string
+ *   One line of a lineage, with weight
+ *
+ * @return
+ *   One line of a lineage, with the weight removed, or false on error.
  */
 function lineage_strip_weight($term_string) {
   // Remove numbers 0-9 followed by a hyphen, at most once.
@@ -245,9 +291,14 @@ function lineage_strip_weight($term_string) {
   }
 }
 
-/** Get the weight string from the beginning of a lineage term string.
- * @param term_string one line of a lineage, with weight
- * @return The weight from term_string, or false on failure.
+/**
+ * Get the weight string from the beginning of a lineage term string.
+ *
+ * @param $term_string
+ *   One line of a lineage, with weight.
+ *
+ * @return
+ *   The weight from the term_string, or false on failure.
  */
 function lineage_get_weight($term_string) {
   $matches = array();
@@ -262,10 +313,27 @@ function lineage_get_weight($term_string) {
   }
 }
 
+/**
+ * Recursive helper to assemble lineage.
+ *
+ * @param $id
+ *   A taxonomy term id.
+ *
+ * @return
+ *   An keyed array containg the following keys:
+ *   - base
+ *   - depth
+ */
 function _lineage_get_parent_lineage($tid) {
-  $result = db_query("SELECT td.tid, td.name, td.weight, td.vid, th.parent FROM {term_hierarchy} th LEFT JOIN {term_data} td ON td.tid = th.tid WHERE td.tid = %d", $tid);
+  $query = db_select('taxonomy_term_hierarchy', 'th');
+  $query->join('taxonomy_term_data', 'td', 'td.tid = th.tid');
+  $query->fields('td', array('tid', 'name', 'weight', 'vid'));
+  $query->fields('th', array('parent'));
+  $query->condition('td.tid', $tid, '=');
 
-  if ($term = db_fetch_object($result)) {
+  $result = $query->execute();
+
+  foreach ($result as $term) {
     $ret = _lineage_get_parent_lineage($term->parent);
 
     $ret['base'] .= lineage_string($term);
@@ -282,27 +350,34 @@ function _lineage_get_parent_lineage($tid) {
  */
 function lineage_views_api() {
   return array(
-    'api' => 2.0,
+    'api' => 3,
   );
 }
 
 
 /**
  * Determine how many digits to use in weights.
- * @param vid the vocabulary.
- * @return array of min weight, max weight, offset to use, and # digits.
+ *
+ * Use db_query() and not db_select() to keep the code small. Apparently
+ * you can't chain addExpression() into a SelectQuery :-/
+ *
+ * @param vid
+ *   The vocabulary vid.
+ *
+ * @return
+ *   Array of min weight, max weight, offset to use, and # digits.
  */
 function _lineage_weights($vid) {
   // Keep static array with weight info to prevent unneeded queries.
   static $weights = array();
 
   if (!isset($weights[$vid])) {
-    $min_r = db_query("SELECT MIN(weight) FROM {term_data} WHERE vid = %d", $vid);
-    $weights[$vid]['min'] = db_result($min_r);
+    // $weights[$vid]['min'] = db_select('taxonomy_term_data')->addExpression('MIN(weight)')->condition('vid', $vid, '=')->execute()->fetchField();
+    $weights[$vid]['min'] = db_query('SELECT MIN(weight) FROM {taxonomy_term_data} WHERE vid = :vid', array(':vid' => $vid))->fetchField();
     $weights[$vid]['offset'] = ($weights[$vid]['min'] < 0) ? abs($weights[$vid]['min']) : 0;
 
-    $max_r = db_query("SELECT MAX(weight) FROM {term_data} WHERE vid = %d", $vid);
-    $weights[$vid]['max'] = db_result($max_r);
+    // $weights[$vid]['max'] = db_select('taxonomy_term_data')->addExpression('MAX(weight)')->condition('vid', $vid, '=')->execute()->fetchField();
+    $weights[$vid]['max'] = db_query('SELECT MAX(weight) FROM {taxonomy_term_data} WHERE vid = :vid', array(':vid' => $vid))->fetchField();
     $weights[$vid]['digits'] = floor(log($weights[$vid]['max'] + $weights[$vid]['offset'] + 1));
     if ($weights[$vid]['digits'] == 0) {
       $weights[$vid]['digits']++;
@@ -317,8 +392,8 @@ function _lineage_weights($vid) {
  */
 function _lineage_format_warning() {
   drupal_set_message(
-    t("Warning: your lineage data appears to be in an old format.  Try disabling and re-enabling the module, or run update.php."),
+    t('Warning: your lineage data appears to be in an old format. Try disabling and re-enabling the module, or run update.php.'),
     'warning',
     FALSE
   );
-}
\ No newline at end of file
+}
diff --git a/lineage.views.inc b/lineage.views.inc
index e885dc7..638e713 100644
--- a/lineage.views.inc
+++ b/lineage.views.inc
@@ -9,57 +9,58 @@
  * Implementation of hook_views_data().
  */
 function lineage_views_data() {
-  $tables['term_lineage'] = array(
+  $data['taxonomy_term_lineage'] = array(
     'table' => array(
-      'group' => t('Taxonomy'),
+      'group' => t('Taxonomy term'),
       'join' => array(
-        'node' => array(
-          'left_table' => 'term_node',
-          'left_field' => 'tid',
-          'field' => 'tid',
-        ),
-        'term_data' => array(
+        'taxonomy_term_data' => array(
           'left_field' => 'tid',
           'field' => 'tid',
         ),
       ),
     ),
     'lineage' => array(
-      'title' => t("Hierarchy"),
+      'title' => t('Hierarchy'),
+      'help' => t('The taxonomy lineage hierarchy.'),
       'field' => array(
         'handler' => 'lineage_handler_field',
         'click sortable' => TRUE,
-        'help' => t('Taxonomy lineage hierarchy'),
+      ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_string',
+        'help' => t('Taxonomy term lineage hierarchy.'),
       ),
       'sort' => array(
         'handler' => 'views_handler_sort',
       ),
+      'argument' => array(
+        'handler' => 'views_handler_argument_string',
+        'help' => t('Taxonomy term lineage hierarchy.'),
+      ),
     ),
     'depth' => array(
-      'title' => t("Depth"),
+      'title' => t('Depth'),
+      'help' => t('The taxonomy lineage depth.'),
       'field' => array(
-        'handler' => 'views_handler_field',
-        'help' => t('Taxonomy lineage depth'),
+        'handler' => 'views_handler_field_numeric',
+        'click sortable' => TRUE,
       ),
-    ),
-  );
-
-  return $tables;
-}
-
-/**
- * Implementation of hook_views_handlers().
- */
-function lineage_views_handlers() {
-  return array(
-    'handlers' => array(
-      'lineage_handler_field' => array(
-        'parent' => 'views_handler_field',
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_numeric',
+        'help' => t('Taxonomy term lineage depth.'),
+      ),
+      'argument' => array(
+        'handler' => 'views_handler_argument_numeric',
+        'help' => t('Taxonomy term lineage depth.'),
       ),
     ),
   );
-}
 
+  return $data;
+}
 
 /**
  * Implements hook_views_plugins().
@@ -81,4 +82,4 @@ function lineage_views_plugins() {
       ),
     )
   );
-}
\ No newline at end of file
+}
diff --git a/lineage_handler_field.inc b/lineage_handler_field.inc
deleted file mode 100644
index 5284ed5..0000000
--- a/lineage_handler_field.inc
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php
-
-/**
- * @file
- * Views field plugin for lineage's field handler.
- */
-
-/**
- * Field handler for Taxonomy: Hierarchy.
- */
-class lineage_handler_field extends views_handler_field {
-  /**
-   * Provide formatting options for the field.
-   */
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-    $field = $this->content_field;
-    $options = $this->options;
-
-    $form['lineage'] = array(
-      '#type' => 'fieldset',
-      '#title' => t("Lineage string formatting options"),
-    );
-
-    $form['lineage']['strip_weights'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Strip weights'),
-      '#default_value' => $options['lineage']['strip_weights'],
-      '#description' => t("The raw lineage entries begin with a number indicating the term weight (for term ordering).  Check to remove weights for display."),
-    );
-
-    $form['lineage']['machine_safe']= array(
-      '#type' => 'checkbox',
-      '#title' => t('Machine-safe'),
-      '#default_value' => $options['lineage']['machine_safe'],
-      '#description' => t("Reformats the lineage strings for use in machine-readable contexts.  Be sure to use an appropriate term delimiter (below) and prefix text (above) if you wish this to be a CSS class name; CSS class names must begin with a letter."),
-    );
-
-    $form['lineage']['prefix'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Term prefix'),
-      '#default_value' => $options['lineage']['prefix'],
-      '#description' => t("Appended before each term name in the lineage.  You may include HTML."),
-    );
-
-    $form['lineage']['suffix'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Term suffix'),
-      '#default_value' => $options['lineage']['suffix'],
-      '#description' => t("Appended before each term name in the lineage.  You may include HTML."),
-    );
-
-    $form['lineage']['delimiter'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Delimiter between terms'),
-      '#default_value' => $options['lineage']['delimiter'],
-      '#description' => t("Use %linebreak_code for line breaks.", array('%linebreak_code' => '\n')),
-    );
-  }
-
-
-  /**
-   * Render the field.
-   */
-  function render($values) {
-    $options = $this->options ? $this->options : array();
-    if ($options['lineage']) {
-        extract($options['lineage']);
-    }
-
-    $lineage_string = $values->{$this->field_alias};
-
-    if ($lineage_string == '') {
-      return '';
-    }
-
-    // Split hierarchy string into hierarchical path pieces.
-    // Term entries are separated by \n; trim so we don't add empty pieces.
-    $term_strings = explode("\n", trim($lineage_string));
-
-    // Compose the rendered hierarchy according to handler form options.
-
-    if ($strip_weights) {
-      $term_strings = array_map("lineage_strip_weight", $term_strings);
-    }
-
-    if ($machine_safe) {
-      // Replace non-alphanumeric characters with a hyphen.
-      $non_alphanumeric = '/[^a-zA-Z0-9]+/ ';
-      $term_strings = preg_replace($non_alphanumeric, '-', $term_strings);
-    }
-
-    if ($prefix || $suffix) {
-      foreach ($term_strings as $key => $term_string) {
-        $term_string = $prefix . $term_string . $suffix;
-        $term_strings[$key] = $term_string;
-      }
-    }
-
-    // The user may enter "\n" for a linebreak delimiter;
-    // replace with actual linebreak character.
-    $delimiter = str_replace("\\n", "\n", $delimiter);
-
-    $rendered = implode($delimiter, $term_strings);
-
-    // Be sure to validate and sanitize markup since we allow HTML.
-    return filter_xss_admin($rendered);
-  }
-}
-
diff --git a/plugins/views_plugin_style_lineage_nested.inc b/plugins/views_plugin_style_lineage_nested.inc
new file mode 100644
index 0000000..51917b7
--- /dev/null
+++ b/plugins/views_plugin_style_lineage_nested.inc
@@ -0,0 +1,264 @@
+<?php
+
+/**
+ * @file
+ * Views style plugin that allows a view to be rendered as a nested list,
+ * based on Lineage's term hierarchy.
+ */
+
+/**
+ * Implements views_plugin_style.
+ */
+class views_plugin_style_lineage_nested extends views_plugin_style_list {
+  function respond_to_filter($filter) {
+    $allowed = array(
+      'views_handler_filter_term_node_tid',
+      'views_handler_filter_term_node_tid_depth',
+      'views_handler_argument_term_node_tid',
+      'views_handler_argument_term_node_tid_depth',
+    );
+    if (in_array($filter, $allowed)) {
+      return TRUE;
+    }
+    else {
+      return FALSE;
+    }
+  }
+
+  function options_form(&$form, &$form_state) {
+
+    // Assemble a list of Taxonomy Lineage fields.
+    $nesting_options = array('' => '[None]');
+    foreach ($this->display->handler->get_handlers('field') as $field => $handler) {
+      // Only include lineage fields.
+      if ($handler->definition['handler'] == 'lineage_handler_field') {
+        if ($label = $handler->label()) {
+          $nesting_options[$field] = $label;
+        }
+        else {
+          $nesting_options[$field] = $handler->ui_name();
+        }
+      }
+    }
+
+    // Assemble a list of Taxonomy filters and arguments
+    $filter_options = array('' => '[None]');
+    foreach ($this->display->handler->get_handlers('filter') as $filter => $handler) {
+      if ($this->respond_to_filter($handler->definition['handler'])) {
+        $filter_options['Filters']['f_' . $filter] = $handler->ui_name();
+      }
+    }
+    foreach ($this->display->handler->get_handlers('argument') as $arg => $handler) {
+      if ($this->respond_to_filter($handler->definition['handler'])) {
+        $filter_options['Arguments']['a_' . $arg] = $handler->ui_name();
+      }
+    }
+
+
+
+    $options = parent::options_form($form, $form_state);
+    if (sizeof($nesting_options) > 1) { // one option is [None]
+      $form['nesting'] = array(
+        '#type' => 'select',
+        '#title' => t('Nesting Field'),
+        '#options' => $nesting_options,
+        '#default_value' => $this->options['nesting'],
+        '#description' => t(
+          'Select the Lineage field that will control the nesting.'
+        ),
+      );
+
+      $h_options = array(0 => t('default'));
+      for ($i = 1; $i <= 6; $i++) {
+        $h_options[$i] = "<h$i>";
+      }
+
+      $default_header = $this->options['start_depth']
+        ? $this->options['start_depth']
+        : 0;
+
+      $form['start_depth'] = array(
+        '#type' => 'select',
+        '#title' => 'Top-level header',
+        '#options' => $h_options,
+        '#default_value' => $default_header,
+        '#description' => t(
+          'Header tag to use for the top-level term in the nesting.  If %default is selected, the plugin will choose the header level based on the properties of your view.',
+          array('%default' => $h_options[0])
+        ),
+      );
+
+      if (sizeof($filter_options) > 1) { // one option is [None]
+        $form['filter'] = array(
+          '#type' => 'select',
+          '#title' => 'Set top level with filter or argument',
+          '#options' => $filter_options,
+          '#default_value' => $this->options['filter'],
+          '#description' => t(
+            "If selected, the nesting will begin with the term set by this argument or filter, and headers for parent terms will be hidden.  (Filters and arguments are listed in the same order as in your view.)  This feature is experimental."
+          ),
+        );
+      }
+    }
+  }
+
+  function render() {
+    if ($this->uses_row_plugin() && empty($this->row_plugin)) {
+      vpr('views_plugin_style_default: Missing row plugin');
+      return;
+    }
+
+    $output = '';
+
+    // First group the rows according to the grouping field, if specified.
+    $sets = $this->render_grouping($this->view->result, $this->options['grouping']);
+
+    foreach ($sets as $title => $records) {
+      if ($this->uses_row_plugin()) {
+        $rendered = array();
+        foreach ($records as $row_index => $row) {
+          $this->view->row_index = $row_index;
+          $rendered[$row_index] = $this->row_plugin->render($row);
+        }
+      }
+
+      // If the user specified a filter for the nesting, remove other levels.
+      $term_name = FALSE;
+      if ($this->options['filter']) {
+
+        // Option is either a filter or an argument, marked by f and a.
+        // If it's an argument
+        if ($arg_name = strstr($this->options['filter'], "a_")) {
+          $arg_name = substr($arg_name, 2);
+          $arg = $this->display->handler->handlers['argument'][$arg_name];
+          $term = $arg->argument;
+        }
+        // If it's a filter
+        elseif ($filter_name = strstr($this->options['filter'], "f_")) {
+          $filter_name = substr($filter_name, 2);
+          $filter = $this->display->handler->handlers['filter'][$filter_name];
+          $terms = $filter->value;
+          $term = array_pop($terms);
+        }
+
+        if (is_numeric($term)) {
+          $term_obj = taxonomy_get_term($term);
+          $term_name = $term_obj->name;
+        }
+        else {
+          $term_name = $term;
+        }
+      }
+
+     // Now, nest each grouping by the nesting field.
+      $nested_set = $this->render_nesting($records, $rendered, $this->options['nesting'], $term_name);
+
+      // Determine the starting depth of the header.
+      // If the user has defined a start depth, use that.
+      if ($this->options['start_depth']) {
+        $depth = $this->options['start_depth'];
+      }
+      // Otherwise, decide based on default and whether a grouping is set.
+      else {
+        $depth = LINEAGE_START_DEPTH;
+      }
+
+      // @todo Provide theming.
+      $output .=
+        $this->nested_list(
+          $nested_set,
+          $title,
+          $this->options['type'],
+          $depth
+        );
+
+    }
+    unset($this->view->row_index);
+    return $output;
+  }
+
+  function render_nesting($records, $rendered, $nesting_field = '', $term_name = FALSE) {
+    $nested_sets = array();
+    if (isset($this->view->field[$nesting_field])) {
+      $field_alias = $this->view->field[$nesting_field]->field_alias;
+    }
+
+    if ($field_alias) {
+      foreach ($records as $index => $row) {
+        $nesting = '';
+        // @todo Avoid using eval().
+
+        $lineage = $row->$field_alias;
+        // If a filter term was passed, remove the lineage before the term.
+        if ($term_name) {
+          $lineage = strstr($lineage, $term_name);
+          if ($lineage) {
+            $lineage = substr($lineage, strlen($term_name)+1); // +1 for \n
+          }
+        }
+
+        // Strip weights from the lineage, if any.
+        if ($lineage) {
+          $lineage = explode("\n", $lineage);
+          foreach ($lineage as $key => $value) {
+            if ($value) {
+              $lineage[$key] = lineage_strip_weight($value);
+            }
+          }
+          $lineage = implode("\n", $lineage);
+        }
+
+        // Add the row to the array.
+        $eval = "\$nested_sets"
+          . "['"
+          . str_replace("\n", "']['", addslashes($lineage) . $index)
+          . "']"
+          . " = \$rendered[\$index];";
+        eval($eval);
+      }
+    }
+    else {
+      // Create a single group with an empty grouping field.
+      $nested_sets[''] = $records;
+    }
+
+    return $nested_sets;
+  }
+
+  function header($header, $depth) {
+    // Use a header tag if possible; else use a class indicating header depth.
+    if ($depth <= 6) {
+      return "<h$depth>" . stripslashes($header) . "</h$depth>\n";
+    }
+    else {
+      return "<span class=\"h$depth\">$header</span>\n";
+    }
+  }
+
+  function nested_list($rows, $header, $type, $depth = 1) {
+    $output = "";
+    if (!empty($header)) {
+      $output .=  $this->header($header, $depth);
+      $depth++;
+    }
+
+    $output .=  "<$type>\n";
+
+    foreach ($rows as $key => $row) {
+      $output .=  "<li>\n"; // @todo Add classes.
+      // If the next child is an array of rows, recurse.
+      if (is_array($row) || is_object($row)) {
+        // @todo Allow type to vary per list? (And how would we store that?)
+        $output .= $this->nested_list($row, $key, $type, $depth);
+      }
+      else {
+        $output .=  $row;
+      }
+      $output .=  "</li>\n";
+    }
+
+    $output .=  "</$type>\n";
+
+    return $output;
+  }
+}
diff --git a/views_plugin_style_lineage_nested.inc b/views_plugin_style_lineage_nested.inc
deleted file mode 100644
index 04f0427..0000000
--- a/views_plugin_style_lineage_nested.inc
+++ /dev/null
@@ -1,272 +0,0 @@
-<?php
-
-/**
- * @file
- * Views style plugin that allows a view to be rendered as a nested list,
- * based on Lineage's term hierarchy.
- */
-
-
-/**
- * Define a base starting depth for nesting headers.
- * We use 3 (for <h3> tags) because <h1> and <h2> are generally page titles.
- */
-define('LINEAGE_START_DEPTH', 3);
-
-
-/**
- * Implements views_plugin_style.
- */
-class views_plugin_style_lineage_nested extends views_plugin_style_list {
-  function respond_to_filter($filter) {
-    $allowed = array(
-      'views_handler_filter_term_node_tid',
-      'views_handler_filter_term_node_tid_depth',
-      'views_handler_argument_term_node_tid',
-      'views_handler_argument_term_node_tid_depth',
-    );
-    if (in_array($filter, $allowed)) {
-      return TRUE;
-    }
-    else {
-      return FALSE;
-    }
-  }
-
-  function options_form(&$form, &$form_state) {
-
-    // Assemble a list of Taxonomy Lineage fields.
-    $nesting_options = array('' => '[None]');
-    foreach ($this->display->handler->get_handlers('field') as $field => $handler) {
-      // Only include lineage fields.
-      if ($handler->definition['handler'] == 'lineage_handler_field') {
-        if ($label = $handler->label()) {
-          $nesting_options[$field] = $label;
-        }
-        else {
-          $nesting_options[$field] = $handler->ui_name();
-        }
-      }
-    }
-
-    // Assemble a list of Taxonomy filters and arguments
-    $filter_options = array('' => '[None]');
-    foreach ($this->display->handler->get_handlers('filter') as $filter => $handler) {
-      if ($this->respond_to_filter($handler->definition['handler'])) {
-        $filter_options['Filters']['f_' . $filter] = $handler->ui_name();
-      }
-    }
-    foreach ($this->display->handler->get_handlers('argument') as $arg => $handler) {
-      if ($this->respond_to_filter($handler->definition['handler'])) {
-        $filter_options['Arguments']['a_' . $arg] = $handler->ui_name();
-      }
-    }
-
-
-
-    $options = parent::options_form($form, $form_state);
-    if (sizeof($nesting_options) > 1) { // one option is [None]
-      $form['nesting'] = array(
-        '#type' => 'select',
-        '#title' => t('Nesting Field'),
-        '#options' => $nesting_options,
-        '#default_value' => $this->options['nesting'],
-        '#description' => t(
-          'Select the Lineage field that will control the nesting.'
-        ),
-      );
-
-      $h_options = array(0 => t('default'));
-      for ($i = 1; $i <= 6; $i++) {
-        $h_options[$i] = "<h$i>";
-      }
-
-      $default_header = $this->options['start_depth']
-        ? $this->options['start_depth']
-        : 0;
-
-      $form['start_depth'] = array(
-        '#type' => 'select',
-        '#title' => 'Top-level header',
-        '#options' => $h_options,
-        '#default_value' => $default_header,
-        '#description' => t(
-          'Header tag to use for the top-level term in the nesting.  If %default is selected, the plugin will choose the header level based on the properties of your view.',
-          array('%default' => $h_options[0])
-        ),
-      );
-
-      if (sizeof($filter_options) > 1) { // one option is [None]
-        $form['filter'] = array(
-          '#type' => 'select',
-          '#title' => 'Set top level with filter or argument',
-          '#options' => $filter_options,
-          '#default_value' => $this->options['filter'],
-          '#description' => t(
-            "If selected, the nesting will begin with the term set by this argument or filter, and headers for parent terms will be hidden.  (Filters and arguments are listed in the same order as in your view.)  This feature is experimental."
-          ),
-        );
-      }
-    }
-  }
-
-  function render() {
-    if ($this->uses_row_plugin() && empty($this->row_plugin)) {
-      vpr('views_plugin_style_default: Missing row plugin');
-      return;
-    }
-
-    $output = '';
-
-    // First group the rows according to the grouping field, if specified.
-    $sets = $this->render_grouping($this->view->result, $this->options['grouping']);
-
-    foreach ($sets as $title => $records) {
-      if ($this->uses_row_plugin()) {
-        $rendered = array();
-        foreach ($records as $row_index => $row) {
-          $this->view->row_index = $row_index;
-          $rendered[$row_index] = $this->row_plugin->render($row);
-        }
-      }
-
-      // If the user specified a filter for the nesting, remove other levels.
-      $term_name = FALSE;
-      if ($this->options['filter']) {
-
-        // Option is either a filter or an argument, marked by f and a.
-        // If it's an argument
-        if ($arg_name = strstr($this->options['filter'], "a_")) {
-          $arg_name = substr($arg_name, 2);
-          $arg = $this->display->handler->handlers['argument'][$arg_name];
-          $term = $arg->argument;
-        }
-        // If it's a filter
-        elseif ($filter_name = strstr($this->options['filter'], "f_")) {
-          $filter_name = substr($filter_name, 2);
-          $filter = $this->display->handler->handlers['filter'][$filter_name];
-          $terms = $filter->value;
-          $term = array_pop($terms);
-        }
-
-        if (is_numeric($term)) {
-          $term_obj = taxonomy_get_term($term);
-          $term_name = $term_obj->name;
-        }
-        else {
-          $term_name = $term;
-        }
-      }
-
-     // Now, nest each grouping by the nesting field.
-      $nested_set = $this->render_nesting($records, $rendered, $this->options['nesting'], $term_name);
-
-      // Determine the starting depth of the header.
-      // If the user has defined a start depth, use that.
-      if ($this->options['start_depth']) {
-        $depth = $this->options['start_depth'];
-      }
-      // Otherwise, decide based on default and whether a grouping is set.
-      else {
-        $depth = LINEAGE_START_DEPTH;
-      }
-
-      // @todo Provide theming.
-      $output .=
-        $this->nested_list(
-          $nested_set,
-          $title,
-          $this->options['type'],
-          $depth
-        );
-
-    }
-    unset($this->view->row_index);
-    return $output;
-  }
-
-  function render_nesting($records, $rendered, $nesting_field = '', $term_name = FALSE) {
-    $nested_sets = array();
-    if (isset($this->view->field[$nesting_field])) {
-      $field_alias = $this->view->field[$nesting_field]->field_alias;
-    }
-
-    if ($field_alias) {
-      foreach ($records as $index => $row) {
-        $nesting = '';
-        // @todo Avoid using eval().
-
-        $lineage = $row->$field_alias;
-        // If a filter term was passed, remove the lineage before the term.
-        if ($term_name) {
-          $lineage = strstr($lineage, $term_name);
-          if ($lineage) {
-            $lineage = substr($lineage, strlen($term_name)+1); // +1 for \n
-          }
-        }
-
-        // Strip weights from the lineage, if any.
-        if ($lineage) {
-          $lineage = explode("\n", $lineage);
-          foreach ($lineage as $key => $value) {
-            if ($value) {
-              $lineage[$key] = lineage_strip_weight($value);
-            }
-          }
-          $lineage = implode("\n", $lineage);
-        }
-
-        // Add the row to the array.
-        $eval = "\$nested_sets"
-          . "['"
-          . str_replace("\n", "']['", addslashes($lineage) . $index)
-          . "']"
-          . " = \$rendered[\$index];";
-        eval($eval);
-      }
-    }
-    else {
-      // Create a single group with an empty grouping field.
-      $nested_sets[''] = $records;
-    }
-
-    return $nested_sets;
-  }
-
-  function header($header, $depth) {
-    // Use a header tag if possible; else use a class indicating header depth.
-    if ($depth <= 6) {
-      return "<h$depth>" . stripslashes($header) . "</h$depth>\n";
-    }
-    else {
-      return "<span class=\"h$depth\">$header</span>\n";
-    }
-  }
-
-  function nested_list($rows, $header, $type, $depth = 1) {
-    $output = "";
-    if (!empty($header)) {
-      $output .=  $this->header($header, $depth);
-      $depth++;
-    }
-
-    $output .=  "<$type>\n";
-
-    foreach ($rows as $key => $row) {
-      $output .=  "<li>\n"; // @todo Add classes.
-      // If the next child is an array of rows, recurse.
-      if (is_array($row) || is_object($row)) {
-        // @todo Allow type to vary per list? (And how would we store that?)
-        $output .= $this->nested_list($row, $key, $type, $depth);
-      }
-      else {
-        $output .=  $row;
-      }
-      $output .=  "</li>\n";
-    }
-
-    $output .=  "</$type>\n";
-
-    return $output;
-  }
-}
\ No newline at end of file
