diff --git a/includes/views/smartqueue_og.views_default.inc b/includes/views/smartqueue_og.views_default.inc
deleted file mode 100644
index 7ab6b27..0000000
--- a/includes/views/smartqueue_og.views_default.inc
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-function smartqueue_og_views_default_views() {
-  $qid = smartqueue_og_get_qid();
-  $view = new view;
-  $view->name = 'smartqueue_og_default';
-  $view->description = 'Displays the nodes in a group\'s queue';
-  $view->tag = 'nodequeue';
-  $view->view_php = '';
-  $view->base_table = 'node';
-  $view->is_cacheable = FALSE;
-  $view->api_version = 2;
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-  $handler = $view->new_display('default', 'Defaults', 'default');
-  $handler->override_option('relationships', array(
-    'nodequeue_rel' => array(
-      'label' => 'queue',
-      'required' => 1,
-      'limit' => 1,
-      'qids' => array(
-        $qid => $qid,
-      ),
-      'id' => 'nodequeue_rel',
-      'table' => 'node',
-      'field' => 'nodequeue_rel',
-      'relationship' => 'none',
-    ),
-  ));
-  $handler->override_option('fields', array(
-    'title' => array(
-      'label' => '',
-      'link_to_node' => 1,
-      'exclude' => 0,
-      'id' => 'title',
-      'table' => 'node',
-      'field' => 'title',
-      'override' => array(
-        'button' => 'Override',
-      ),
-      'relationship' => 'none',
-    ),
-    'body' => array(
-      'label' => '',
-      'exclude' => 0,
-      'id' => 'body',
-      'table' => 'node_revisions',
-      'field' => 'body',
-      'override' => array(
-        'button' => 'Override',
-      ),
-      'relationship' => 'none',
-    ),
-  ));
-  $handler->override_option('sorts', array(
-    'position' => array(
-      'id' => 'position',
-      'table' => 'nodequeue_nodes',
-      'field' => 'position',
-    ),
-  ));
-  $handler->override_option('arguments', array(
-    'reference' => array(
-      'default_action' => 'not found',
-      'style_plugin' => 'default_summary',
-      'style_options' => array(),
-      'wildcard' => 'all',
-      'wildcard_substitution' => '',
-      'title' => '',
-      'default_argument_type' => 'fixed',
-      'default_argument' => '',
-      'validate_type' => 'none',
-      'validate_fail' => 'not found',
-      'glossary' => 0,
-      'limit' => '0',
-      'case' => 'none',
-      'path_case' => 'none',
-      'transform_dash' => 0,
-      'id' => 'reference',
-      'table' => 'nodequeue_subqueue',
-      'field' => 'reference',
-      'relationship' => 'nodequeue_rel',
-      'default_options_div_prefix' => '',
-      'default_argument_user' => 0,
-      'default_argument_fixed' => '',
-      'default_argument_php' => '',
-      'validate_argument_node_type' => array(
-        'blog' => 0,
-        'poll' => 0,
-        'book' => 0,
-        'page' => 0,
-        'story' => 0,
-      ),
-      'validate_argument_node_access' => 0,
-      'validate_argument_nid_type' => 'nid',
-      'validate_argument_vocabulary' => array(
-      ),
-      'validate_argument_type' => 'tid',
-      'validate_argument_php' => '',
-      'override' => array(
-        'button' => 'Override',
-      ),
-    ),
-  ));
-  $handler->override_option('access', array(
-    'type' => 'none',
-    'role' => array(),
-    'perm' => '',
-  ));
-  $handler->override_option('empty', 'This group does not have a queue that contains and nodes.');
-  $handler->override_option('empty_format', '1');
-  $handler->override_option('use_pager', '1');
-  $handler->override_option('style_plugin', 'list');
-  $handler->override_option('row_options', array(
-    'inline' => array(),
-    'separator' => '',
-  ));
-  $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->override_option('path', 'smartqueue-og');
-  $handler->override_option('menu', array(
-    'type' => 'none',
-    'title' => '',
-    'weight' => 0,
-    'name' => 'navigation',
-  ));
-  $handler->override_option('tab_options', array(
-    'type' => 'none',
-    'title' => '',
-    'weight' => 0,
-  ));
-  $views[$view->name] = $view;
-  return $views;
-}
\ No newline at end of file
diff --git a/smartqueue_og.info b/smartqueue_og.info
index c8e45c4..6357a06 100644
--- a/smartqueue_og.info
+++ b/smartqueue_og.info
@@ -1,6 +1,6 @@
-name = Smartqueues for Organic Groups
-description = Provides a Node queue for individual organic groups
+name = Smartqueue OG
+description = Creates a node queue for each OG group.
 package = Nodequeue
-dependencies[] = nodequeue
+core = 7.x
+dependencies[] = smartqueue
 dependencies[] = og
-core = 6.x
\ No newline at end of file
diff --git a/smartqueue_og.module b/smartqueue_og.module
index d8b25e2..5026d67 100644
--- a/smartqueue_og.module
+++ b/smartqueue_og.module
@@ -1,402 +1,232 @@
 <?php
 
 /**
- * Implementation of hook_views_api()
+ * Implements hook_nodequeue_info().
  */
-
-function smartqueue_og_views_api() {
+function smartqueue_og_nodequeue_info() {
   return array(
-    'api' => 2,
-    'path' => drupal_get_path('module', 'smartqueue_og') .'/includes/views',
+    'smartqueue_og' => array(
+      'title' => t('OG queue'),
+      'description' => t('Each OG group has its own unique subqueue. You can place nodes into any of these subqueues based on which OG groups that node belongs to.'),
+    ),
   );
 }
-function smartqueue_og_block($op = 'list', $delta = 0, $edit = array()) {
- if (module_exists('views')) {
-    switch ($op) {
-      case 'list':
-        $blocks[0]['info'] = t("Group Queue");
-        return $blocks; 
-        break;
-      case 'view':
-        if ($delta == 0) {
-          //try not to get grossed out:
-          if ($node = menu_get_object('node')) {
-            if (og_is_group_type($node->type)) {
-              $view = views_embed_view('smartqueue_og_default');
-              $block = array(
-                'subject' => t("@title's Queue", array('@title' => $node->title)),
-                'content' => $view,
-              );
-            }
-          }
-        }
-        return $block;
-        break;
+
+/**
+ * Implements hook_nodequeue_form().
+ */
+function smartqueue_og_nodequeue_form($queue, &$form) {
+  // Load data about OG group fields.
+  $options = array();
+  $fields = field_info_fields();
+  foreach ($fields as $field_name => $field) {
+    if ($field['type'] == 'group') {
+      $options[$field_name] = t('Group audience field %field-name', array('%field-name' => $field_name));
     }
   }
-}
-function smartqueue_og_menu() {
-  $items['admin/content/nodequeue/smartqueue_og/batch_delete'] = array(
-    'title' => 'Confirm Smartque OG Batch Queue Deletion',
-    'access callback' => 'smartqueue_og_batch_delete_access',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('smartqueue_og_batch_delete_subqueues_confirm'),
-    'type' => MENU_CALLBACK
-  );
-  return $items;
-}
-
-function smartqueue_og_batch_delete_access() {
-  return user_access('manipulate all queues') || user_access('manipulate all og queues');
-}
-function smartqueue_og_perm() {
-  return array('manipulate og queues', 'manipulate all og queues');
-}
-function smartqueue_og_nodequeue_info() {
-  return array('smartqueue_og' =>
-    array(
-      'title' => t('Smartqueues for Organic Groups'),
-      'description' => t('Provides a Nodequeue for each Organic Group'),
-    )
-  );
-}
 
-function smartqueue_og_nodequeue_form($queue, &$form) {
-  
-  $og_types = array_flip(og_get_types('group'));
-  $og_types = array_intersect_key(node_get_types('names'), $og_types);
-  $form['eligible_group_types'] = array(
+  $form['placeholder']['og_fields'] = array(
     '#type' => 'checkboxes',
-    '#title' => t("Group types which are eligible for a Nodequeue"),
-    '#description' => t("Select the Organic Group types for which Nodequeues should be automatically created."),
-    '#options' => $og_types,
-    '#default_value' => variable_get('smartqueue_og_'. smartqueue_og_get_qid() .'_eligible_group_types', array()),
-    '#weight' => 1,
-  );
-  $form['manipulate_restrict'] = array(
-    '#type' => 'radios',
-    '#title' => t('Who can manipulate this Nodequeue?'),
-    '#options' => array(
-      'members' => t('All Groups Members can manipulate this Nodequeue.'),
-      'admins' => t('Only Group Administrators can manipulate this Nodequeue.'),
-    ),
-    '#default_value' => variable_get('smartqueue_og_manipulate_restrict_'. $queue->qid, 'admins'),
-  );
-  $form['node_restrict'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Restrict to posts within a group'),
-    '#description' => t("When checked, only posts which are part of the Organic Group can be added to the group's Nodequeue."),
-    '#default_value' => variable_get('smartqueue_og_node_restrict_'. $queue->qid, 0),
-  );
-  $form['auto_add'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Automatically add to group queues'),
-    '#description' => t("When checked, posts will automatically be added to applicable group Nodequeues when they are submitted."),
-    '#default_value' => variable_get('smartqueue_og_auto_add_'. $queue->qid, 0),
-  );
-  $form['submit_actions'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Batch operations to perform when this form is submitted:'),
-    '#weight' => 8,
-    '#tree' => TRUE,
-  );
-  $form['submit_actions']['destroy'] = array(
-    '#type' => 'radios',
-    '#title' => 'For Organic Groups that should no longer have Nodequeues',
-    '#options' => array(
-      //'disable' => t('Disable these NodeQueues'), This isn't possible on a per-SubQueue basis with the current Nodequeue API.
-      'delete' => t('Delete these Nodequeues'),
-      'nothing' => t('Take no action on these Nodequeues'),
-    ),
+    '#title' => t('OG fields'),
+    '#description' => t('Select which OG group fields to use; each unique combination of groups from all of these fields will have a subqueue.'),
+    '#options' => $options,
   );
-  $form['submit_actions']['create'] = array(
-    '#prefix' => "<label>". t("For eligible groups that do not yet have Queues:") ."</label>",
-    '#type' => 'checkbox',
-    '#title' => t('Create new Nodequeues'),
-    '#default_value' => 1,
+
+  $form['subqueue_title'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Subqueue title'),
+    '#default_value' => $queue->subqueue_title,
+    '#size' => 50,
+    '#maxlength' => 64,
+    '#description' => t('What to display for the subqueue title; use %subqueue to embed the actual subqueue title. This is used to distinguish multiple nodequeues with subqueues from each other, as internal subqueue title is filled automatically.'),
   );
-}
 
-function smartqueue_og_nodequeue_form_submit(&$queue, &$form_state) {
-  variable_set('smartqueue_og_'. $queue->qid .'_eligible_group_types', $form_state['values']['eligible_group_types']);
-  variable_set('smartqueue_og_node_restrict_'. $queue->qid, $form_state['values']['node_restrict']);
-  variable_set('smartqueue_og_manipulate_restrict_'. $queue->qid, $form_state['values']['manipulate_restrict']);
-  variable_set('smartqueue_og_auto_add_'. $queue->qid, $form_state['values']['auto_add']);
+  // Fields can be selected just when creating a new smartqueue.
+  // Disable it after that.
+  if (!empty($queue->qid)) {
+    $form['placeholder']['og_fields']['#disabled'] = TRUE;
+    $form['placeholder']['og_fields']['#default_value'] = explode('-', $queue->reference);
+  }
 }
 
-function smartqueue_og_nodequeue_form_submit_finish(&$queue, &$form_state) {
-  if ($form_state['values']['submit_actions']['create'] == 1) {
-    $eligible_groups = smartqueue_og_eligible_groups();
-    $existing_subqueues = smartqueue_og_existing_subqueues();
-    if (!empty($eligible_groups)) {
-      $groups_without_subqueues = array_diff_key($eligible_groups, $existing_subqueues);
-      smartqueue_og_batch_add_subqueues($groups_without_subqueues, $queue->qid);
+/**
+ * Implements hook_nodequeue_form_validate().
+ */
+function smartqueue_og_nodequeue_form_validate($queue, &$form_state, &$form) {
+  if (!isset($queue->qid)) {
+    $field_names = array_keys(array_filter($form_state['values']['og_fields']));
+    if (empty($field_names)) {
+      form_error($form['placeholder']['og_fields'], t('You must select at least one field.'));
     }
-  }
 
-  switch ($form_state['values']['submit_actions']['destroy']) {
-    case 'delete':
-      drupal_goto('admin/content/nodequeue/smartqueue_og/batch_delete');
-      break;
+    // Convert this to our reference.
+    form_set_value($form['reference'], implode('-', $field_names), $form_state);
   }
 }
-function smartqueue_og_batch_delete_subqueues_confirm() {
-  $qid = smartqueue_og_get_qid();
-  
-    $eligible_groups = smartqueue_og_eligible_groups();
-    $existing_subqueues = smartqueue_og_existing_subqueues();
-    $extra_subqueues = array_diff_key($existing_subqueues, $eligible_groups);
 
-  if (empty($extra_subqueues)) {
-    drupal_set_message(t("There are no extra OG Nodequeues to delete."));
-    drupal_goto('admin/content/nodequeue/'. $qid .'/edit');
-  }
-  
-  $form['extra_subqueues'] = array(
-    '#type' => 'value',
-    '#value' => $extra_subqueues,
-  );
-  return confirm_form($form, t("Are you sure you wish to batch delete extra OG Nodequeues ?"), 'admin/content/nodequeue/'. $qid .'/edit', NULL, 'Confirm', 'Cancel', 'smartqueue_og_batch_delete_confirm');
-}
-
-function smartqueue_og_batch_delete_subqueues_confirm_submit($form, &$form_state) {
-  smartqueue_og_batch_delete_subqueues($form_state['values']['extra_subqueues']);
-  $form_state['redirect'] = 'admin/content/nodequeue';
-}
+/**
+ * Implements hook_nodequeue_form_submit_finish().
+ */
+function smartqueue_og_nodequeue_form_submit_finish($queue, $form_state) {
+  // Check if queue already exists.
+  $qid = db_select('smartqueue', 's')
+    ->fields('s', array('qid'))
+    ->condition('qid', $queue->qid)
+    ->execute()
+    ->fetchField();
 
-function smartqueue_og_batch_delete_subqueues($sq_ids = array()) {
-  //get sqids from the form
-  if (count($sq_ids) > 0) {
-    $in = implode(', ', array_fill(0, count($sq_ids), "%d"));
-    db_query("DELETE FROM {nodequeue_subqueue} WHERE sqid IN($in)", $sq_ids);
-    db_query("DELETE FROM {nodequeue_nodes} WHERE sqid IN($in)", $sq_ids);
-  }
-  else {
-    drupal_set_message(t("No subqueues to delete."));
+  if (!$qid) {
+    // Insert new queue.
+    db_insert('smartqueue')
+      ->fields(array(
+        'qid' => $queue->qid,
+      ))
+      ->execute();
   }
 }
 
-function smartqueue_og_batch_add_subqueues($groups, $qid = NULL) {
-  if (!$qid) {
-    $qid = smartqueue_og_get_qid();
-  }
-  if (!$qid) {
-    //TODO: Move this to smartqueue_og_get_qid().
-    drupal_set_message(t("Couldn't establish qid "), 'error');
-    return;
-  }
-  
-  $queue->qid = $qid;
-  $count = 0;
-  foreach ($groups as $nid => $title) {
-    $sq = nodequeue_add_subqueue($queue, $title ."'s Nodequeue", $nid);
-    $node = node_load($nid);
-    if (node_access('view', $node)) {
-      drupal_set_message(t("Added Nodequeue: @title", array('@title' => $title ."'s Nodequeue")));
-    }
-    else {
-      $restricted ++;
+/**
+ * Implements hook_nodequeue_subqueues().
+ *
+ * Returns list of references for subqueues that can host a given node.
+ */
+function smartqueue_og_nodequeue_subqueues(&$queue, $node) {
+  $field_names = array();
+
+  // Check if at least one supported field exists in node and load
+  // selected tids.
+  foreach (explode('-', $queue->reference) as $field_name) {
+    // Save tids.
+    if ($field_values = field_get_items('node', $node, $field_name)) {
+      $field_names[$field_name] = array();
+      foreach ($field_values as $field_value) {
+        $field_names[$field_name][] = $field_value['gid'];
+      }
     }
   }
-  if (count($restricted > 0)) {
-    drupal_set_message(t("Added Nodequeues for %count restricted groups.", array('%count' => count($restricted))));
-  }
-}
-function smartqueue_og_existing_subqueues() {
-  $subqueues = array();
-  //returns an array keyed on the subqueue reference with the sq id as the value
-  $qid = smartqueue_og_get_qid();
-  $query = db_query("SELECT sqid, reference FROM {nodequeue_subqueue} WHERE qid = %d", $qid);
-  while ($result = db_fetch_array($query)) {
-    $subqueues[$result['reference']] = $result['sqid'];
-  }
-  return $subqueues;
-}
-function smartqueue_og_eligible_groups() {
-  $groups = array();
-  if ($eligible_types = smartqueue_og_eligible_group_types()) {
-    $in = 'IN ('. implode(', ', array_fill(0, count($eligible_types), "'%s'")) .')';
-    $query = db_query("SELECT nid, title FROM {node} WHERE type $in", $eligible_types);
-    while ($result = db_fetch_object($query)) {
-      $groups[$result->nid] = $result->title;
+
+  // Forbid NO terms being set, but allow
+  // various non-terms to be set.
+  $empty = TRUE;
+  foreach ($field_names as $field_name => $gids) {
+    if (!empty($gids)) {
+      $empty = FALSE;
+    }
+    if (!count($field_names[$field_name])) {
+      $field_names[$field_name][] = 0;
     }
-    
   }
-  return $groups;
-}
 
-function smartqueue_og_all_group_subqueues() {
-  $subqueues = array();
-  //returns an array keyed on the subqueue reference with the sq id as the value
-  $qid = smartqueue_og_get_qid();
-  $query = db_query("SELECT sqid, reference FROM {nodequeue_subqueue} WHERE qid = %d", $qid);
-  while ($result = db_fetch_array($query)) {
-    $subqueues[$result['reference']] = $result['sqid'];
+  if ($empty) {
+    return;
   }
-  return $subqueues;
-}
 
-function smartqueue_og_eligible_group_types() {
- 
-  $var = variable_get('smartqueue_og_'. smartqueue_og_get_qid() .'_eligible_group_types', array());
-  return array_intersect($var, og_get_types('group'));
-}
+  // Build reference strings for all subqueues.
+  $references = smartqueue_og_build_string(array_filter($field_names));
 
-function smartqueue_og_eligible_group_type($type) {
-   //TODO: verify this syntax when I get an internet conectio
-  if (in_array($type, variable_get('smartqueue_og_'. smartqueue_og_get_qid() .'_eligible_group_types', array()))) {
-    return TRUE;
+  // We're returning an array of references for efficiency, but we also have
+  // to check to see if the references we've generated exist. If they don't,
+  // we have to create them.
+  $exists = array();
+  $subqueues = nodequeue_load_subqueues_by_reference(array($queue->qid => $references));
+  foreach ($subqueues as $subqueue) {
+    $exists[$subqueue->reference] = TRUE;
   }
-  else {
-    return FALSE;
-  }
-}
 
-function smartqueue_og_form_alter(&$form, &$form_state, $form_id) {
-  switch ($form_id) {
-    case 'nodequeue_edit_queue_form':
-      if ($form['owner']['#value'] == 'smartqueue_og') {
-        $form['description']['#weight'] = -1;
-        $form['title']['#weight'] = -1;
-        $form['submit']['#weight'] = 9;
-        $form[0]['#weight'] = 9; // the Delete button.
-        if (smartqueue_og_get_qid() && empty($form['title']['#default_value'])) {
-          drupal_set_message(t("Only one OG Smartqueue can exist at a time."));
-          drupal_goto('admin/content/nodequeue'); 
-        }
-      }
-      break;
-    
+  // Create subqueues if needed.
+  foreach ($references as $reference) {
+    if (empty($exists[$reference])) {
+      nodequeue_add_subqueue($queue, smartqueue_og_nodequeue_subqueue_title($queue, $reference), $reference);
+    }
   }
-}
 
-function smartqueue_og_nodequeue_subqueues(&$queue, $node) {
-  global $user;
-  $manipulate_restrict = variable_get('smartqueue_og_manipulate_restrict_'. $queue->qid, 'admins');
-  $node_restrict = variable_get('smartqueue_og_node_restrict_'. $queue->qid, 0);
+  return $references;
+}
 
-  if (empty($user->og_groups) || !user_access('manipulate og queues')) {
-    return;
-  }
-  $user_group_nids = array_keys($user->og_groups);
-  $groups = array_combine($user_group_nids, $user_group_nids);
-  
-  if ($manipulate_restrict == 'admins') {
-    foreach ($user->og_groups as $nid => $this_group) {
-      if ($this_group['is_admin'] != 1) {
-        unset($groups[$nid]);
-      }
-    }
+/**
+ * Build an array of strings that represents all of the possible OG group
+ * combinations.
+ */
+function smartqueue_og_build_string($arrays) {
+  $array = array_shift($arrays);
+  $term = '';
+  if (empty($arrays)) {
+    return $array;
   }
 
-  //only add posts already in an organic group
-  if ($node_restrict) {
-    if (!is_array($node->og_groups) || empty($node->og_groups)) {
-      return;
+  $substrings = smartqueue_og_build_string($arrays);
+  $strings = array();
+
+  foreach ($array as $term) {
+    foreach ($substrings as $string) {
+      $strings[] = "$term-$string";
     }
-    $groups = array_intersect_key($groups, $node->og_groups);
   }
 
-  return $groups;
+  return $strings;
 }
 
-/*
- * Implementation of the hook nodequeue_api_queue_access
+/**
+ * Form title for a new taxonomy subqueue.
+ *
+ * @param $queue Queue object.
+ * @param $reference Subqueue reference string (tids imploded with '-').
  */
-function smartqueue_og_queue_access($queue, $account = NULL) {
-  if (!$account) {
-    global $user;
-    $account = $user;
-  }
-  if (user_access("manipulate all queues", $account) || user_access('manipulate all og queues', $account) || user_access("manipulate og queues", $account)) {
-    return TRUE;
-  }
-  else {
-    return FALSE;
+function smartqueue_og_nodequeue_subqueue_title($queue, $reference) {
+  $gids = explode('-', $reference);
+  $titles = array();
+  foreach ($gids as $gid) {
+    // $gid can be 0, specifically meaning this term is unset.
+    if ($gid) {
+      $titles[$gid] = og_label($gid);
+    }
   }
+
+  // Create name using names of all term names. This could be
+  // done better, but is OK for now.
+  return implode('-', $titles);
 }
 
-/*
- * Implementation of the hook nodequeue_api_subqueue_access
+/**
+ * Implements hook_group_update().
+ *
+ * Updates subqueue title if a group name changes.
  */
-function smartqueue_og_subqueue_access($subqueue, $account = NULL) {
-  if (!$account) {
-    global $user;
-    $account = $user;
-  }
-
-  if (user_access("manipulate all queues", $account) || user_access('manipulate all og queues', $account)) {
-    return TRUE;
-  }
-  
-  if (!user_access('manipulate og queues', $account)) {
-    return FALSE;
-  }
-  if (variable_get('smartqueue_og_manipulate_restrict_'. $subqueue->qid, 'admins') == 'admins' && $account->og_groups[$subqueue->reference]['is_admin'] != 1) {
-    return FALSE;
-  }
-  
-  if (!isset($account->og_groups[$subqueue->reference])) {
-    return FALSE;
-  }
-} 
-
-function smartqueue_og_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
-  switch ($op) {
-    case 'insert':
-    case 'update':
-      if (smartqueue_og_eligible_group_type($node->type)) {
-        if ($subqueue = !smartqueue_og_load_group_subqueue($node->nid)) {
-          $queue->qid = smartqueue_og_get_qid();
-          nodequeue_add_subqueue($queue, "$node->title's Nodequeue", $node->nid);
-          if (node_access('view', $node)) {
-            drupal_set_message(t("Created a Nodequeue for @title .", array('@title' => $node->title)));
-          }
-        }
-        else {
-          if ($subqueue->title != "$node->title's Subqueue  ") {
-            nodequeue_subqueue_update_title($subqueue->sqid, $node->title ."'s Queue'");
-          }
-        }
-      }
-      if (!empty($node->og_groups)) {
-        //Automatically add this node to applicable group subqueues.
-        foreach ($node->og_groups as $key => $group_nid) {
-          if ($subqueue = smartqueue_og_load_group_subqueue($group_nid)) {
-            $subqueue = array_shift($subqueue);
-            //If this setting is disabled, no need to proceed with further database queries.
-            if (variable_get('smartqueue_og_auto_add_'. $subqueue->qid, 0)) {
-              $queue = nodequeue_load($subqueue->qid);
-              //If this type of node is allowed in this queue:
-              if (in_array($node->type, $queue->types)) {
-                //If this node is not already in the subqueue:
-                if (!nodequeue_get_subqueue_position($subqueue->sqid, $node->nid)) {
-                  nodequeue_subqueue_add($queue, $subqueue, $node->nid);
-                }
-              }
-            }
-          }
-          unset($queue);
-          unset($subqueue);
-        }
-      }
-      break;
-    case 'delete':
-      if ($subqueue = smartqueue_og_load_group_subqueue($node->nid)) {
-        nodequeue_remove_subqueue($subqueue->sqid);
-        drupal_set_message(t("Deleted Nodequeue @title", array('@title' => $subqueue->title)));
-      }
+function smartqueue_og_group_update(OgGroup $og_group) {
+  if (!empty($og_group->etid) && !empty($og_group->original->label) && !empty($og_group->label) && $og_group->original->label != $og_group->label) {
+    // Find subqueues that use this group.
+    $result = db_query("SELECT nq.reference AS reference, sq.reference AS sqref, sq.sqid
+      FROM {nodequeue_queue} nq
+      INNER JOIN {nodequeue_subqueue} sq ON nq.qid = sq.qid
+      WHERE nq.owner = 'smartqueue_og'
+      AND sq.reference = :sqref",
+      array(':sqref' => $og_group->etid)
+    )->fetchAll();
+    foreach ($result as $row) {
+      // Note that $row already contains the needed $row->reference.
+      $title = smartqueue_taxonomy_nodequeue_subqueue_title($row, $row->sqref);
+      nodequeue_subqueue_update_title($row->sqid, $og_group->label);
+    }
   }
 }
 
-function smartqueue_og_get_qid() {
-  static $qid;
-  if (!isset($qid)) {
-    $qid = db_result(db_query("SELECT qid FROM {nodequeue_queue} WHERE owner = 'smartqueue_og'"));
+/**
+ * Implements hook_group_delete().
+ *
+ * Deletes subqueue if term is removed
+ */
+function smartqueue_og_group_delete(OgGroup $og_group) {
+  if (!empty($og_group->etid)) {
+    // Find subqueues that use this group.
+    $result = db_query("SELECT nq.reference AS reference, sq.reference AS sqref, sq.sqid
+      FROM {nodequeue_queue} nq
+      INNER JOIN {nodequeue_subqueue} sq ON nq.qid = sq.qid
+      WHERE nq.owner = 'smartqueue_og'
+      AND sq.reference = :sqref",
+      array(':sqref' => $og_group->etid)
+    )->fetchAll();
+    foreach ($result as $row) {
+      nodequeue_remove_subqueue($row->sqid);
+    }
   }
-  return $qid;
 }
-
-function smartqueue_og_load_group_subqueue($nid) {
-  return nodequeue_load_subqueues_by_reference(array(smartqueue_og_get_qid() => array($nid)));
-}
\ No newline at end of file
