diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..2c095c8
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,274 @@
+GNU GENERAL PUBLIC LICENSE
+
+              Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
+Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
+verbatim copies of this license document, but changing it is not allowed.
+
+                  Preamble
+
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users. This General Public License
+applies to most of the Free Software Foundation's software and to any other
+program whose authors commit to using it. (Some other Free Software
+Foundation software is covered by the GNU Library General Public License
+instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the
+freedom to distribute copies of free software (and charge for this service if
+you wish), that you receive source code or can get it if you want it, that you
+can change the software or use pieces of it in new free programs; and that
+you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to
+deny you these rights or to ask you to surrender the rights. These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have. You must make
+sure that they, too, receive or can get the source code. And you must show
+them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients
+to know that what they have is not the original, so that any problems
+introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will individually
+obtain patent licenses, in effect making the program proprietary. To prevent
+this, we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+           GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
+               MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms
+of this General Public License. The "Program", below, refers to any such
+program or work, and a "work based on the Program" means either the
+Program or any derivative work under copyright law: that is to say, a work
+containing the Program or a portion of it, either verbatim or with
+modifications and/or translated into another language. (Hereinafter, translation
+is included without limitation in the term "modification".) Each licensee is
+addressed as "you".
+
+Activities other than copying, distribution and modification are not covered
+by this License; they are outside its scope. The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made
+by running the Program). Whether that is true depends on what the Program
+does.
+
+1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you
+may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it,
+thus forming a work based on the Program, and copy and distribute such
+modifications or work under the terms of Section 1 above, provided that you
+also meet all of these conditions:
+
+a) You must cause the modified files to carry prominent notices stating that
+you changed the files and the date of any change.
+
+b) You must cause any work that you distribute or publish, that in whole or in
+part contains or is derived from the Program or any part thereof, to be
+licensed as a whole at no charge to all third parties under the terms of this
+License.
+
+c) If the modified program normally reads commands interactively when run,
+you must cause it, when started running for such interactive use in the most
+ordinary way, to print or display an announcement including an appropriate
+copyright notice and a notice that there is no warranty (or else, saying that
+you provide a warranty) and that users may redistribute the program under
+these conditions, and telling the user how to view a copy of this License.
+(Exception: if the Program itself is interactive but does not normally print such
+an announcement, your work based on the Program is not required to print
+an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be
+reasonably considered independent and separate works in themselves, then
+this License, and its terms, do not apply to those sections when you distribute
+them as separate works. But when you distribute the same sections as part
+of a whole which is a work based on the Program, the distribution of the
+whole must be on the terms of this License, whose permissions for other
+licensees extend to the entire whole, and thus to each and every part
+regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to
+work written entirely by you; rather, the intent is to exercise the right to
+control the distribution of derivative or collective works based on the
+Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of a
+storage or distribution medium does not bring the other work under the scope
+of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1
+and 2 above provided that you also do one of the following:
+
+a) Accompany it with the complete corresponding machine-readable source
+code, which must be distributed under the terms of Sections 1 and 2 above
+on a medium customarily used for software interchange; or,
+
+b) Accompany it with a written offer, valid for at least three years, to give
+any third party, for a charge no more than your cost of physically performing
+source distribution, a complete machine-readable copy of the corresponding
+source code, to be distributed under the terms of Sections 1 and 2 above on
+a medium customarily used for software interchange; or,
+
+c) Accompany it with the information you received as to the offer to distribute
+corresponding source code. (This alternative is allowed only for
+noncommercial distribution and only if you received the program in object
+code or executable form with such an offer, in accord with Subsection b
+above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source code
+means all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation and
+installation of the executable. However, as a special exception, the source
+code distributed need not include anything that is normally distributed (in
+either source or binary form) with the major components (compiler, kernel,
+and so on) of the operating system on which the executable runs, unless that
+component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to
+copy from a designated place, then offering equivalent access to copy the
+source code from the same place counts as distribution of the source code,
+even though third parties are not compelled to copy the source along with the
+object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy,
+modify, sublicense or distribute the Program is void, and will automatically
+terminate your rights under this License. However, parties who have received
+copies, or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the
+Program or its derivative works. These actions are prohibited by law if you
+do not accept this License. Therefore, by modifying or distributing the
+Program (or any work based on the Program), you indicate your acceptance
+of this License to do so, and all its terms and conditions for copying,
+distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these terms and
+conditions. You may not impose any further restrictions on the recipients'
+exercise of the rights granted herein. You are not responsible for enforcing
+compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose
+that choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original copyright
+holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In such
+case, this License incorporates the limitation as if written in the body of this
+License.
+
+9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will be
+similar in spirit to the present version, but may differ in detail to address new
+problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies
+a version number of this License which applies to it and "any later version",
+you have the option of following the terms and conditions either of that
+version or of any later version published by the Free Software Foundation. If
+the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software
+Foundation, write to the Free Software Foundation; we sometimes make
+exceptions for this. Our decision will be guided by the two goals of
+preserving the free status of all derivatives of our free software and of
+promoting the sharing and reuse of software generally.
+
+               NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
+PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
+WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
+AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
+ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
+SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
+OR DATA BEING RENDERED INACCURATE OR LOSSES
+SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
+PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
+IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.
+
+          END OF TERMS AND CONDITIONS
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..e4f22cc
--- /dev/null
+++ b/README.txt
@@ -0,0 +1 @@
+This is a port of the Drupal 6 module term_queue to Drupal 7
diff --git a/term_queue.admin.inc b/term_queue.admin.inc
index 38eb083..4367837 100644
--- a/term_queue.admin.inc
+++ b/term_queue.admin.inc
@@ -1,4 +1,7 @@
 <?php
+// $Id$
+
+
 /**
  * @file
  * Administrative page callbacks for the term_queue module.
@@ -6,29 +9,55 @@
 
 /**
  * Render the listing of all available term queues.
+ *
+ * @return
+ * 	An HTML table containing details of term queues on the system
  */
 function term_queue_admin_list() {
-  $queues = term_queue_list();  
-  
+  $queues = term_queue_list();
+
   $rows = array();
-  foreach ( $queues as $obj ) {
-    $row = array();
+  foreach ($queues as $obj) {
+    $row   = array();
     $row[] = check_plain($obj->title);
     $row[] = check_plain($obj->description);
-    $row[] = l(t('Edit Queue'), 'admin/build/term_queue/'. $obj->qid . '/edit'); 
-    $row[] = l(t('Edit Terms'), 'admin/build/term_queue/'. $obj->qid); 
-    $row[] = l(t('Delete'), 'admin/build/term_queue/'. $obj->qid . '/delete');         
+    $row[] = l(t('Edit Queue'), 'admin/structure/term_queue/' . $obj->qid . '/edit');
+    $row[] = l(t('Edit Terms'), 'admin/structure/term_queue/' . $obj->qid);
+    $row[] = l(t('Delete'), 'admin/structure/term_queue/' . $obj->qid . '/delete');
 
     $row = array('data' => $row);
     $rows[] = $row;
   }
-  
+
   if (empty($rows)) {
-    $rows[] = array(array('data' => t('No queues have been created'), 'colspan' => '3'));
+    $rows[] = array(
+      array(
+        'data' => t('No queues have been created'),
+        'colspan' => '3',
+      ),
+    );
   }
-  
-  $header = array(t('Title'), t('Description'), array('data' => t('Operations'), 'colspan' => '3'));
-  $output = theme('table', $header, $rows, array('id' => 'term-queue'));
+
+  $header = array(
+    array(
+      'data' => t('Title'),
+    ),
+    array(
+      'data' => t('Description'),
+    ),
+    array(
+      'data' => t('Operations'),
+      'colspan' => '3',
+    ),
+  );
+
+  $output = theme('table', array(
+      'header' => $header,
+      'rows' => $rows,
+      'sticky' => FALSE,
+      'empty' => 'There are no term queues to display yet',
+    ));
+
   return $output;
 }
 
@@ -38,27 +67,30 @@ function term_queue_admin_list() {
  * @ingroup forms
  * @see term_queue_form_submit()
  */
-function term_queue_form(&$form_state, $edit = array()) {
+function term_queue_form($form, $form_state, $edit = array()) {
   if (isset($edit['qid'])) {
-    $form['qid'] = array('#type' => 'value', '#value' => $edit['qid']);
+    $form['qid'] = array(
+      '#type' => 'value',
+      '#value' => $edit['qid'],
+    );
   }
   $form['title'] = array('#type' => 'textfield',
     '#title' => t('Title'),
-    '#default_value' => $edit['title'],
+    '#default_value' => !empty($edit['title']) ? $edit['title'] : '',
     '#maxlength' => 255,
     '#description' => t('The name for this term queue, e.g., <em>"Top 10"</em>.'),
     '#required' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
-    '#default_value' => $edit['description'],
+    '#default_value' => !empty($edit['description']) ? $edit['description'] : '',
     '#description' => t('Description of the term queue; can be used by modules.'),
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
   $form['cancel'] = array(
-    '#type' => 'markup', 
-    '#value' => l(t('Cancel'), 'admin/build/term_queue'), 
-    '#weight' => 21
+    '#type' => 'markup',
+    '#value' => l(t('Cancel'), 'admin/structure/term_queue'),
+    '#weight' => 21,
   );
 
   return $form;
@@ -71,7 +103,7 @@ function term_queue_form(&$form_state, $edit = array()) {
  */
 function term_queue_form_submit($form, &$form_state) {
   term_queue_save($form_state['values']);
-  $form_state['redirect'] = 'admin/build/term_queue/list';
+  $form_state['redirect'] = 'admin/structure/term_queue/list';
   return;
 }
 
@@ -80,7 +112,7 @@ function term_queue_form_submit($form, &$form_state) {
  *
  * @ingroup forms
  */
-function term_queue_settings_form(&$form_state, $edit = array()) {
+function term_queue_settings_form($form, &$form_state) {
   $form = array();
 
   $form['global_settings'] = array('#type' => 'fieldset', '#title' => t('Global Settings'));
@@ -92,9 +124,7 @@ function term_queue_settings_form(&$form_state, $edit = array()) {
     '#description' => t('Enable this when you have a large number of vocabularies'),
   );
 
-  // TODO: Add filter for vocabularies
-
-  return system_settings_form($form); 
+  return system_settings_form($form);
 }
 
 /**
@@ -112,15 +142,17 @@ function term_queue_edit_form($edit = array()) {
  * @ingroup forms
  * @see term_queue_delete_form_submit()
  */
-function term_queue_delete_form(&$form_state, $queue) {
+function term_queue_delete_form($form, $form_state, $queue) {
+
   $form['qid'] = array('#type' => 'value', '#value' => $queue->qid);
 
   return confirm_form($form,
-    t('Are you sure you want to delete the queue %field?', array('%field' => $queue->title)), 
-    'admin/build/term_queue/list',
+    t('Are you sure you want to delete the queue %field?', array('%field' => $queue->title)),
+    'admin/structure/term_queue/list',
     NULL,
-    t('Delete'), 
-    t('Cancel'));
+    t('Delete'),
+    t('Cancel')
+  );
 }
 
 /**
@@ -130,7 +162,7 @@ function term_queue_delete_form(&$form_state, $queue) {
  */
 function term_queue_delete_form_submit($form, &$form_state) {
   term_queue_delete($form_state['values']);
-  $form_state['redirect'] = 'admin/build/term_queue/list';
+  $form_state['redirect'] = 'admin/structure/term_queue/list';
   return;
 }
 
@@ -140,17 +172,19 @@ function term_queue_delete_form_submit($form, &$form_state) {
  * @ingroup forms
  * @see term_queue_add_term_form_submit()
  */
-function term_queue_add_term_form(&$form_state, $queue) {
+function term_queue_add_term_form($form, &$form_state, $queue) {
 
-  drupal_set_title(t('%queue', array('%queue' => $queue->title)));
+  drupal_set_title(t('@queue', array('@queue' => $queue->title)));
 
   $vocab_terms = array();
   $vocabs = taxonomy_get_vocabularies();
+
   foreach ($vocabs as $vid => $vocab) {
     $vocab_terms[$vid] = taxonomy_get_tree($vid);
   }
-  
+
   $options = array();
+
   foreach ($vocab_terms as $vid => $terms) {
     $vocab_name = $vocabs[$vid]->name;
     $option[$vocab_name] = array();
@@ -166,13 +200,13 @@ function term_queue_add_term_form(&$form_state, $queue) {
     '#value' => $queue->qid,
   );
 
-  // use a different form field for autocomplete 
-  if(is_autocomplete()) {
+  // use a different form field for autocomplete
+  if (is_autocomplete()) {
     $form['tid'] = array(
       '#type' => 'textfield',
       '#title' => t('Term'),
       '#autocomplete_path' => 'term_queue/autocomplete',
-      '#description' => t('Begin typing the term name and choices will appear.  Terms are displayed as "termname (category)"'),
+      '#description' => t('Begin typing the term name and choices will appear. Terms are displayed as "termname (category)"'),
     );
   }
   else {
@@ -182,15 +216,16 @@ function term_queue_add_term_form(&$form_state, $queue) {
       '#options' => $options,
       '#description' => t('Select a term to be added to the queue.'),
       '#weight' => -15,
-      '#theme' => 'taxonomy_term_select',
+      // No longer in D7
+      //'#theme' => 'taxonomy_term_select',
     );
   }
-  
+
   $form['submit'] = array('#type' => 'submit', '#value' => 'Add Term');
   $form['cancel'] = array(
-    '#type' => 'markup', 
-    '#value' => l(t('Cancel'), 'admin/build/term_queue/' . $queue->qid), 
-    '#weight' => 21
+    '#type' => 'markup',
+    '#value' => l(t('Cancel'), 'admin/structure/term_queue/' . $queue->qid),
+    '#weight' => 21,
   );
 
   return $form;
@@ -203,24 +238,23 @@ function term_queue_add_term_form(&$form_state, $queue) {
  */
 function term_queue_add_term_form_submit($form, &$form_state) {
   $qid = $form_state['values']['qid'];
-  
+
   // handle the tid value if using autocomplete
-  if(is_autocomplete()) {
+  if (is_autocomplete()) {
     // value comes in as 'Charterhouse Group (Company) [tid:5193]', parse the tid.
-    $value = preg_match("/tid:\d+/", $form_state['values']['tid'], $matches);
+    $value     = preg_match("/tid:\d+/", $form_state['values']['tid'], $matches);
     $tid_array = explode(":", $matches[0]);
-    $tid = $tid_array[1];
+    $tid       = $tid_array[1];
   }
-  else  
-    $tid = $form_state['values']['tid'];
+  else $tid = $form_state['values']['tid'];
 
   term_queue_add_term($qid, $tid);
-  $form_state['redirect'] = "admin/build/term_queue/$qid/add";
-  
+  $form_state['redirect'] = "admin/structure/term_queue/$qid/add";
+
   $term_queue = term_queue_load($qid);
-  $term = taxonomy_get_term($tid);
-  
-  
+  //$term = taxonomy_get_term($tid);
+  $term = taxonomy_term_load($tid);
+
   drupal_set_message(t('%term has been saved to %queue.', array('%term' => $term->name, '%queue' => $term_queue->title)));
   return;
 }
@@ -232,12 +266,11 @@ function term_queue_add_term_form_submit($form, &$form_state) {
  * each one. The form is made drag and drop by the theme function.
  *
  * @ingroup forms
- * @see term_queue_term_form_submit()
- * @see theme_term_queue_term_form()
+ * @see term_queue_edit_terms_form_submit()
+ * @see theme_term_queue_edit_terms_form()
  */
-function term_queue_term_form(&$form_state, $queue) {
-  
-  drupal_set_title(t('%queue', array('%queue' => $queue->title)));
+function term_queue_terms_form($form, &$form_state, $queue) {
+  drupal_set_title(t('@queue', array('@queue' => $queue->title)));
 
   $form = array(
     '#queue' => (array)$queue,
@@ -245,7 +278,8 @@ function term_queue_term_form(&$form_state, $queue) {
   );
 
   $qterms = term_queue_get_terms($queue->qid);
-  foreach ($qterms as $qterm){
+
+  foreach ($qterms as $qterm) {
     $form[$qterm->tid]['#qterm'] = (array)$qterm;
     $form[$qterm->tid]['name'] = array(
       '#value' => $qterm->name,
@@ -256,15 +290,19 @@ function term_queue_term_form(&$form_state, $queue) {
       '#default_value' => $qterm->weight,
     );
     $form[$qterm->tid]['delete'] = array(
-      '#value' => l(t('Delete'), "admin/build/term_queue/{$qterm->qid}/{$qterm->tid}/delete"),
+      '#value' => l(t('Delete'), "admin/structure/term_queue/{$qterm->qid}/{$qterm->tid}/delete"),
     );
   }
 
-  $form['#empty_text'] = t('No terms have been added.');  
-  
+  $form['#empty_text'] = t('No terms have been added.');
+
   if (count($qterms) > 0) {
-    $form['submit'] = array('#type' => 'submit', '#value' => 'Save');
-  }  
+    $form['submit'] = array(
+      '#type' => 'submit',
+      '#value' => 'Save',
+    );
+  }
+
   return $form;
 }
 
@@ -273,45 +311,68 @@ function term_queue_term_form(&$form_state, $queue) {
  *
  * @see taxonomy_overview_terms()
  */
-function term_queue_term_form_submit($form, &$form_state) {
+function term_queue_terms_form_submit($form, &$form_state) {
+
   $queue = $form['#queue'];
-  foreach ($form_state['values'] as  $tid => $qterm) {
+  foreach ($form_state['values'] as $tid => $qterm) {
     if (is_numeric($tid) && $form[$tid]['#qterm']['weight'] != $qterm['weight']) {
       term_queue_update_term($queue['qid'], $tid, $qterm['weight']);
     }
   }
+
+  drupal_set_message('Term queue saved');
+
   return;
 }
 
-
 /**
  * Theme the terms overview as a sortable list of terms.
- *
  * @ingroup themeable
  * @see term_queue_term_form()
  */
-function theme_term_queue_term_form($form) {
+function theme_term_queue_terms_form($form) {
+
+  //For some reason the '$form' array seems to contain a single element that contains the whole form array.
+  $form = $form['form'];
+
   $rows = array();
-  foreach (element_children($form) as $key) {
+  $element_children = element_children($form);
+  foreach ($element_children as $key) {
     if (isset($form[$key]['#qterm'])) {
-      $element = &$form[$key];
+      $element = $form[$key];
+
       $row = array();
-      $row[] = drupal_render($element['name']);
-      $element['weight']['#attributes']['class'] = 'term-queue-weight';
+      $row[] = $element['name']['#value'];
+      $element['weight']['#attributes']['class'] = array('term-queue-weight');
       $row[] = drupal_render($element['weight']);
-      $row[] = drupal_render($element['delete']);
-      $rows[] = array('data' => $row, 'class' => 'draggable');
-    }    
+      $row[] = $element['delete']['#value'];
+      $rows[] = array('data' => $row, 'class' => array('draggable'));
+    }
+    else {
+      //Stick all the element's keys that we're not rendering here (submit button, hidden fields etc) in an array so that we can render
+      //the rest of them later.
+      $remaining_elements[] = $key;
+    }
   }
-  
+
   if (empty($rows)) {
     $rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '3'));
   }
 
-  drupal_add_tabledrag('term-queue', 'order', 'sibling', 'term-queue-weight');
   $header = array(t('Name'), t('Weight'), t('Operations'));
-  $output = theme('table', $header, $rows, array('id' => 'term-queue'));
-  $output .= drupal_render($form);
+
+  $output = theme('table', array(
+      'header' => $header,
+      'rows' => $rows,
+      'sticky' => FALSE,
+      'empty' => $form['#empty_text'],
+      'attributes' => array('id' => 'term-queue'),
+    ));
+
+  drupal_add_tabledrag('term-queue', 'order', 'sibling', 'term-queue-weight');
+
+  $output .= drupal_render_children($form, $remaining_elements);
+
   return $output;
 }
 
@@ -321,17 +382,18 @@ function theme_term_queue_term_form($form) {
  * @ingroup forms
  * @see term_queue_delete_term_form_submit()
  */
-function term_queue_delete_term_form(&$form_state, $queue, $tid) {
+function term_queue_delete_term_form($form, &$form_state, $queue, $tid) {
   $form['qid'] = array('#type' => 'value', '#value' => $queue->qid);
   $form['tid'] = array('#type' => 'value', '#value' => $tid);
-  $term = taxonomy_get_term($tid);
+  $term        = taxonomy_term_load($tid);
 
   return confirm_form($form,
-    t('Are you sure you want to remove %term from the queue %queue?', array('%term' => $term->name, '%queue' => $queue->title)), 
-    "admin/build/term_queue/$queue->qid",
+    t('Are you sure you want to remove %term from the queue %queue?', array('%term' => $term->name, '%queue' => $queue->title)),
+    "admin/structure/term_queue/$queue->qid",
     NULL,
-    t('Delete'), 
-    t('Cancel'));
+    t('Delete'),
+    t('Cancel')
+  );
 }
 
 /**
@@ -342,7 +404,7 @@ function term_queue_delete_term_form(&$form_state, $queue, $tid) {
 function term_queue_delete_term_form_submit($form, &$form_state) {
   $values = $form_state['values'];
   term_queue_delete_term($values['qid'], $values['tid']);
-  $form_state['redirect'] = 'admin/build/term_queue/' . $values['qid'];
+  $form_state['redirect'] = 'admin/structure/term_queue/' . $values['qid'];
   return;
 }
 
@@ -352,21 +414,21 @@ function term_queue_delete_term_form_submit($form, &$form_state) {
  */
 function term_queue_autocomplete_term($string = '') {
   $matches = array();
-  if($string) {
-    $sql = "SELECT td.tid, td.name as termname, v.name as category FROM {term_data} td ";
-    $sql .= "JOIN {vocabulary} v ON v.vid = td.vid ";
-    $sql .= "WHERE td.name LIKE '%s%' LIMIT 20";
-    $params = array("$string");
+  if ($string) {
+    $sql = 'SELECT td.tid, td.name as termname, v.name as category FROM {taxonomy_term_data} td ';
+    $sql .= 'JOIN {taxonomy_vocabulary} v ON v.vid = td.vid ';
+    $sql .= 'WHERE td.name LIKE :name LIMIT 20';
 
-    $result = db_query($sql, $params);
+    $result = db_query($sql, array(':name' => $string . '%'));
 
-    while($term = db_fetch_object($result)) {
+    //while($term = db_fetch_object($result)) {
+    foreach ($result as $term) {
       $key = "$term->termname ($term->category) [tid:$term->tid]";
       $matches[$key] = "$term->termname (<b>$term->category</b>)";
     }
   }
 
-  drupal_json($matches); 
+  drupal_json_output($matches);
 }
 
 /**
@@ -374,4 +436,4 @@ function term_queue_autocomplete_term($string = '') {
  */
 function is_autocomplete() {
   return variable_get('term_queue_use_autocomplete', FALSE);
-}
+}
\ No newline at end of file
diff --git a/term_queue.info b/term_queue.info
index ce2a90a..4c2e3f2 100644
--- a/term_queue.info
+++ b/term_queue.info
@@ -1,10 +1,5 @@
 name = "Term Queue"
 description = "Creates ordered lists of Taxonomy Terms"
-core = 6.x
+core = 7.x
 dependencies[] = taxonomy
-; Information added by drupal.org packaging script on 2008-09-25
-version = "6.x-0.9"
-core = "6.x"
-project = "term_queue"
-datestamp = "1222365924"
 
diff --git a/term_queue.install b/term_queue.install
index f79eee7..29cd6cc 100644
--- a/term_queue.install
+++ b/term_queue.install
@@ -1,26 +1,15 @@
 <?php
-/**
- * @file
- */
- 
-/**
- * hook_install implementation
- *
- * Create the vocabularies for all know Calais Entities.
- */
-function term_queue_install() {
-  drupal_install_schema('term_queue');
-}
+// $Id$
 
-/**
- * Implementation of hook_uninstall().
- */
-function term_queue_uninstall() {
-  drupal_uninstall_schema('term_queue');
-}
 
 /**
  * Implementation of hook_schema().
+ * Define the current version of the database schema.
+ *
+ * @return
+ * 	A schema definition structure array.  For each element of the
+ * array, the key is a table name and the value is a table structure
+ * definition.
  */
 function term_queue_schema() {
 
@@ -28,22 +17,22 @@ function term_queue_schema() {
     'description' => 'Holds the various term queues',
     'fields' => array(
       'qid' => array(
-        'type' => 'serial', 
-        'unsigned' => TRUE, 
+        'type' => 'serial',
+        'unsigned' => TRUE,
         'not null' => TRUE,
-        'description' => t('Identifier for a queue')
+        'description' => t('Identifier for a queue'),
       ),
       'title' => array(
-        'type' => 'varchar', 
-        'length' => 255, 
+        'type' => 'varchar',
+        'length' => 255,
         'not null' => TRUE,
-        'description' => t('The name of the queue')
+        'description' => t('The name of the queue'),
       ),
       'description' => array(
-        'type' => 'text', 
-        'length' => 255, 
+        'type' => 'text',
+        'length' => 255,
         'not null' => TRUE,
-        'description' => t('The description of a queue')
+        'description' => t('The description of a queue'),
       ),
     ),
     'primary key' => array('qid'),
@@ -53,47 +42,39 @@ function term_queue_schema() {
     'description' => 'Holds terms and ordering associated with terms in a queue',
     'fields' => array(
       'qid' => array(
-        'type' => 'int', 
-        'unsigned' => TRUE, 
-        'not null' => TRUE, 
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
         'default' => 0,
-        'description' => t('The queue identifier')
+        'description' => t('The queue identifier'),
       ),
       'tid' => array(
-        'type' => 'int', 
-        'unsigned' => TRUE, 
-        'not null' => TRUE, 
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
         'default' => 0,
-        'description' => t('The term identifier')
+        'description' => t('The term identifier'),
       ),
       'vid' => array(
-        'type' => 'int', 
-        'unsigned' => TRUE, 
-        'not null' => TRUE, 
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
         'default' => 0,
-        'description' => t('The term vocabulary')
+        'description' => t('The term vocabulary'),
       ),
       'weight' => array(
-        'type' => 'int', 
-        'not null' => TRUE, 
-        'default' => 0, 
-        'description' => t('The ordering for a term/queue combination')
-        ),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => t('The ordering for a term/queue combination'),
+      ),
     ),
     'indexes' => array(
-      'qid'    => array('qid'),
-      'tid'    => array('tid'),
-      'vid'    => array('vid'),
+      'qid' => array('qid'),
+      'tid' => array('tid'),
+      'vid' => array('vid'),
     ),
     'primary key' => array('tid', 'qid'),
   );
   return $schema;
-}
-
-// Add a missing index on vocabulary id
-function term_queue_update_6000() {
-  $ret = array();
-  db_add_index($ret, 'term_queue_term', 'vid', array('vid'));
-  return $ret;
-}
-
+}
\ No newline at end of file
diff --git a/term_queue.module b/term_queue.module
index 2c8923b..8505be8 100644
--- a/term_queue.module
+++ b/term_queue.module
@@ -1,20 +1,16 @@
 <?php
-/**
- * @file
- * TODO: 
- *  - Add a queue name (unique) for lookups, ahah check on creation/edit
- *  - Views integration?
- *  - Caching the queues in DB instead of statically?
- *  - more to come...
- */
+// $Id$
 
 
 /**
- * Implementation of hook_perm().
+ * Implementation of hook_permission().
  */
-function term_queue_perm() {
+function term_queue_permission() {
   return array(
-    'administer term queue',
+    'administer term queue' => array(
+      'title' => t('Administer Term Queue'),
+      'description' => t('Perform administration tasks for Term Queue.'),
+    ),
   );
 }
 
@@ -23,26 +19,18 @@ function term_queue_perm() {
  */
 function term_queue_theme() {
   $themes = array(
-	  'term_queue' => array(
-		  'arguments' => array('queue' => NULL, 'terms' => array()),
-		  'pattern' => 'term_queue__',
+    'term_queue' => array(
+      'arguments' => array('queue' => NULL, 'terms' => array()),
+      'pattern' => 'term_queue__',
     ),
-    'term_queue_term_form' => array(
-      'arguments' => array('form' => array()),
+    'term_queue_terms_form' => array(
+      'render element' => 'form',
+      //'arguments' => array('form' => NULL),
     ),
   );
-  
+
   $all_queues = term_queue_list();
-		
-	/*foreach($all_queues as $i=>$queue){
-	  $key = 'term_queue_'. $queue->qid;
-		$themes[$key] = array(
-		  'arguments' => array('queue' => NULL, 'terms' => array()),
-		  'template' => $key,
-		  'function' => $key,
-		);
-	}*/
-		  
+
   return $themes;
 }
 
@@ -50,30 +38,34 @@ function term_queue_theme() {
  * Implementation of hook_menu().
  */
 function term_queue_menu() {
-  
-  $items['admin/build/term_queue'] = array(
+
+  $items['admin/structure/term_queue'] = array(
     'title' => 'Term Queues',
-    'description' => 'Configure lists of taxonomy terms to we used on your site.',
+    'description' => 'Configure lists of taxonomy terms to be used on your site.',
     'page callback' => 'term_queue_admin_list',
     'access arguments' => array('administer term queue'),
     'file' => 'term_queue.admin.inc',
   );
-  $items['admin/build/term_queue/list'] = array(
+
+  $items['admin/structure/term_queue/list'] = array(
     'title' => 'List',
     'type' => MENU_DEFAULT_LOCAL_TASK,
+    'page callback' => 'term_queue_admin_list',
+    'access arguments' => array('administer term queue'),
+    'file' => 'term_queue.admin.inc',
     'weight' => -10,
   );
 
-  $items['admin/build/term_queue/add'] = array(
+  $items['admin/structure/term_queue/add'] = array(
     'title' => 'Add Term Queue',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('term_queue_form'),
     'access arguments' => array('administer term queue'),
-    'type' => MENU_LOCAL_TASK,
+    'type' => MENU_LOCAL_ACTION,
     'file' => 'term_queue.admin.inc',
   );
 
-  $items['admin/build/term_queue/settings'] = array(
+  $items['admin/structure/term_queue/settings'] = array(
     'title' => 'Settings',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('term_queue_settings_form'),
@@ -82,7 +74,7 @@ function term_queue_menu() {
     'file' => 'term_queue.admin.inc',
   );
 
-  $items['admin/build/term_queue/%term_queue/edit'] = array(
+  $items['admin/structure/term_queue/%term_queue/edit'] = array(
     'title' => 'Edit Term Queue',
     'page callback' => 'term_queue_edit_form',
     'page arguments' => array(3),
@@ -90,7 +82,7 @@ function term_queue_menu() {
     'type' => MENU_CALLBACK,
     'file' => 'term_queue.admin.inc',
   );
-  $items['admin/build/term_queue/%term_queue/delete'] = array(
+  $items['admin/structure/term_queue/%term_queue/delete'] = array(
     'title' => 'Delete Term Queue',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('term_queue_delete_form', 3),
@@ -98,29 +90,29 @@ function term_queue_menu() {
     'type' => MENU_CALLBACK,
     'file' => 'term_queue.admin.inc',
   );
-  $items['admin/build/term_queue/%term_queue'] = array(
+  $items['admin/structure/term_queue/%term_queue'] = array(
     'title' => 'Queue Terms',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('term_queue_term_form', 3),
+    'page arguments' => array('term_queue_terms_form', 3),
     'access arguments' => array('administer term queue'),
     'type' => MENU_CALLBACK,
     'file' => 'term_queue.admin.inc',
   );
-  $items['admin/build/term_queue/%term_queue/list'] = array(
+  $items['admin/structure/term_queue/%term_queue/list'] = array(
     'title' => 'List',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
-  $items['admin/build/term_queue/%term_queue/add'] = array(
+  $items['admin/structure/term_queue/%term_queue/add'] = array(
     'title' => 'Add Term to Queue',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('term_queue_add_term_form', 3),
     'access arguments' => array('administer term queue'),
-    'parent' => 'admin/build/term_queue/%term_queue',
-    'type' => MENU_LOCAL_TASK,
+    'parent' => 'admin/structure/term_queue/%term_queue',
+    'type' => MENU_LOCAL_ACTION,
     'file' => 'term_queue.admin.inc',
   );
-  $items['admin/build/term_queue/%term_queue/%/delete'] = array(
+  $items['admin/structure/term_queue/%term_queue/%/delete'] = array(
     'title' => 'Delete Term Queue',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('term_queue_delete_term_form', 3, 4),
@@ -136,48 +128,71 @@ function term_queue_menu() {
     'file' => 'term_queue.admin.inc',
     'type' => MENU_CALLBACK,
   );
-  return $items;  
+  return $items;
 }
 
 /**
- * Implementation of hook_block()
+ * Implementation of hook_block_info()
+ * Define all blocks provided by the module.
  *
+ * @return
+ *   An associative array whose keys define the delta for each block and whose
+ *   values contain the block descriptions.
  */
-function term_queue_block($op = 'list', $delta = 0)
-{
-	$all_queues = term_queue_list();
-		
-	if($op == 'list'){
-		$blocks = array();
-		foreach($all_queues as $i=>$queue){
-			$name = $i;
-			$blocks[$name]['info'] = $queue->title;
-		}
-		
-		return $blocks;
-	}
-	else if ($op == 'view') {
-		$qid = $all_queues[$delta]->qid;
-		$terms = term_queue_get_terms($qid);
-		$qid_text = 'term_queue__' . $qid;
-		
-		$data['subject'] = check_plain($all_queues[$delta]->title);
-    $data['content'] = theme(array($qid_text, 'term_queue'), $all_queues[$delta], $terms);
-    
-    return $data;
-	}
+function term_queue_block_info() {
+
+  $all_queues = term_queue_list();
+
+  $blocks = array();
+  foreach ($all_queues as $i => $queue) {
+    $name = $i;
+    $blocks[$name]['info'] = $queue->title;
+  }
+
+  return $blocks;
+}
+
+/**
+ * Implementation of hook_block_view()
+ * Return a rendered or renderable view of a block.
+ *
+ * @param $delta
+ *   Which block to render. This is a unique identifier for the block
+ *   within the module, defined in hook_block_info().
+ *
+ * @return
+ *   An array containing the following elements:
+ *   - subject: The default localized title of the block. If the block does not
+ *     have a default title, this should be set to NULL.
+ *   - content: The content of the block's body. This may be a renderable array
+ *     (preferable) or a string containing rendered HTML content.
+ */
+function term_queue_block_view($delta = '') {
+
+  $all_queues = term_queue_list();
+
+  $qid = $all_queues[$delta]->qid;
+  $terms = term_queue_get_terms($qid);
+
+  $qid_text = 'term_queue__' . $qid;
+
+  $data['subject'] = check_plain($all_queues[$delta]->title);
+  $data['content'] = theme($qid_text, $terms);
+
+  return $data;
 }
 
 /**
  * Get all queues.
  *
- * @return 
+ * @return
  *    A list of term queue objects.
  */
 function term_queue_list() {
   $queues = array();
   $result = db_query('SELECT * FROM {term_queue}');
-  while ($q = db_fetch_object($result)) {
+
+  foreach ($result as $q) {
     $queues[] = $q;
   }
   return $queues;
@@ -186,16 +201,18 @@ function term_queue_list() {
 /**
  * Get a queue.
  *
- * @param $qid 
+ * @param $qid
  *    The queue id.
- * @return 
+ *
+ * @return
  *    A list of term queue objects.
  */
 function term_queue_load($qid) {
   static $queues = array();
 
   if (!isset($queues[$qid])) {
-    $queues[$qid] = db_fetch_object(db_query('SELECT * FROM {term_queue} WHERE qid=%d', $qid));
+    $result = db_query('SELECT * FROM {term_queue} WHERE qid=:qid', array(':qid' => $qid));
+    $queues[$qid] = $result->fetchObject();
   }
 
   return $queues[$qid];
@@ -203,7 +220,7 @@ function term_queue_load($qid) {
 
 /**
  * Save a queue.
- * 
+ *
  * @param $queue
  *    A queue as an array with values
  */
@@ -213,45 +230,47 @@ function term_queue_save($queue) {
   }
   else {
     drupal_write_record('term_queue', $queue);
-  }  
+  }
 }
 
 /**
  * Delete a queue.
- * 
+ *
  * @param $queue
  *    A queue with at least the qid set.
  */
 function term_queue_delete($queue) {
   $queue = (array)$queue;
-  db_query('DELETE FROM {term_queue} WHERE qid = %d', $queue['qid']);
-  db_query('DELETE FROM {term_queue_term} WHERE qid = %d', $queue['qid']);
+
+  db_delete('term_queue')->condition('qid', $queue['qid'])->execute();
+
+  db_delete('term_queue_term')->condition('qid', $queue['qid'])->execute();
 }
 
 /**
  * Return the terms for the all the queue id.
- * 
+ *
  * @return
  *    A two-dimensional array of queue terms as objects
  */
-function term_queue_get_all_terms()
-{
-	$queue_list = array();
-	
-	$queues = term_queue_list();
-	
-	foreach($queues as $queue){
-		$queue_list[$queue->qid] = term_queue_get_terms($queue->qid);
-	}
-	
-	return $queue_list;
+function term_queue_get_all_terms() {
+  $queue_list = array();
+
+  $queues = term_queue_list();
+
+  foreach ($queues as $queue) {
+    $queue_list[$queue->qid] = term_queue_get_terms($queue->qid);
+  }
+
+  return $queue_list;
 }
 
 /**
  * Return the terms for the given queue id.
- * 
- * @param $qid 
+ *
+ * @param $qid
  *    The queue id.
+ *
  * @return
  *    An array of queue terms as objects
  */
@@ -259,15 +278,16 @@ function term_queue_get_terms($qid) {
   static $queue_terms = array();
 
   if (!isset($queue_terms[$qid])) {
-    $terms = array();
-    $sql .= 'SELECT qt.*, td.name FROM {term_queue_term} qt';
-    $sql .= ' INNER JOIN {term_data} td ON qt.tid = td.tid ';
-    $sql .= ' WHERE qid = %d ORDER BY qt.weight ASC, td.name ASC';
-    $result = db_query($sql, $qid);
-    while ($term = db_fetch_object($result)) {
+    $terms  = array();
+    $sql    = 'SELECT qt.*, td.name FROM {term_queue_term} qt';
+    $sql   .= ' INNER JOIN {taxonomy_term_data} td ON qt.tid = td.tid ';
+    $sql   .= ' WHERE qid = :qid ORDER BY qt.weight ASC, td.name ASC';
+    $result = db_query($sql, array(':qid' => $qid));
+
+    foreach ($result as $term) {
       $terms[] = $term;
     }
-  
+
     $queue_terms[$qid] = $terms;
   }
 
@@ -276,94 +296,106 @@ function term_queue_get_terms($qid) {
 
 /**
  * Add a term to a queue
- * 
- * @param $qid 
+ *
+ * @param $qid
  *    The queue id.
- * @param $tid 
+ * @param $tid
  *    The taxonomy term id.
  */
 function term_queue_add_term($qid, $tid) {
-  $term = taxonomy_get_term($tid);
-  db_query('INSERT INTO {term_queue_term} (qid, tid, vid) VALUES(%d, %d, %d)', $qid, $tid, $term->vid);
+  $term = taxonomy_term_load($tid);
+  db_insert('term_queue_term')->fields(array(
+      'qid' => $qid,
+      'tid' => $tid,
+      'vid' => $term->vid,
+    ))->execute();
 }
 
 /**
  * Update a term within a queue.
- * 
- * @param $qid 
+ *
+ * @param $qid
  *    The queue id.
- * @param $tid 
+ * @param $tid
  *    The taxonomy term id.
- * @param $weight 
+ * @param $weight
  *    The weight (ordering) within the specified queue.
  */
 function term_queue_update_term($qid, $tid, $weight = 0) {
-  db_query('UPDATE {term_queue_term} SET weight = %d WHERE qid = %d AND tid = %d', $weight, $qid, $tid);
+  db_update('term_queue_term')->fields(array(
+      'weight' => $weight,
+    ))->condition('qid', $qid)->condition('tid', $tid)->execute();
 }
 
 /**
  * Remove a term from a specific queue
- * 
- * @param $qid 
+ *
+ * @param $qid
  *    The queue id.
- * @param $tid 
+ * @param $tid
  *    The taxonomy term id.
  */
 function term_queue_delete_term($qid, $tid) {
-  db_query('DELETE FROM {term_queue_term} WHERE qid = %d AND tid = %d', $qid, $tid);
+  db_delete('term_queue_term')->condition('qid', $qid)->condition('tid', $tid)->execute();
 }
 
 /**
  * Remove a specific term from all queues
- * 
- * @param $tid 
+ *
+ * @param $tid
  *    The taxonomy term id.
  */
 function term_queue_remove_by_term($tid) {
-  db_query('DELETE FROM {term_queue_term} WHERE tid = %d', $tid);
+  db_delete('term_queue_term')->condition('tid', $tid)->execute();
 }
 
 /**
  * Remove all term in a vocabulary from all queues
- * 
- * @param $vid 
+ *
+ * @param $vid
  *    The vocabulary id.
  */
 function term_queue_remove_by_vocab($vid) {
-  db_query('DELETE FROM {term_queue_term} WHERE vid = %d', $vid);
+  db_delete('term_queue_term')->condition('vid', $vid)->execute();
 }
 
 /**
- * Implementation of hook_taxonomy();
- *
+ * Respond to the deletion of taxonomy vocabularies.
  * When a term is removed, make sure we remove it from our queues.
+ *
+ * Modules implementing this hook can respond to the deletion of taxonomy
+ * vocabularies from the database.
+ *
+ * @param $vocabulary
+ *   A taxonomy vocabulary object.
  */
-function term_queue_taxonomy($op, $type, $data) {
-  if ($op == 'delete') {
-    if ($type = 'term') {
-      term_queue_remove_by_term($data['tid']);
-    }
-    else { // A whole vocabulary was removed.
-      term_queue_remove_by_vocab($data['vid']);
-    }
-  }
+function term_queue_taxonomy_term_delete($term) {
+  term_queue_remove_by_term($term->tid);
+}
+
+function term_queue_taxonomy_vocabulary_delete($vocabulary) {
+  term_queue_remove_by_vocab($vocabulary->vid);
 }
 
 /**
  * Default theme function for a Term Queue
  *
- * {Fill In Later}
+ * @param $terms
+ * 	An array of terms that we want to render as links to the respective term pages
  */
-function theme_term_queue($queue = NULL, $terms = array())
-{
+function theme_term_queue($terms = array()) {
   $links = array();
-	foreach($terms as $term){
-	  $link = array(
-	    'href' => 'taxonomy/term/' . $term->tid,
-	    'title' => $term->name
-	  );
-		$links[] = $link;
-	}
-		
-	return theme('links', $links, array('class' => 'term-queue-links'));
-}
+
+  foreach ($terms as $term) {
+    $link = array(
+      'href' => 'taxonomy/term/' . $term->tid,
+      'title' => $term->name,
+    );
+    $links[] = $link;
+  }
+
+  return theme('links', array(
+      'links' => $links,
+      'attributes' => array('class' => array('term-queue-links')),
+    ));
+}
\ No newline at end of file
