diff --git a/vppr.admin.inc b/vppr.admin.inc
index c97454e..9ad6882 100644
--- a/vppr.admin.inc
+++ b/vppr.admin.inc
@@ -2,73 +2,33 @@
 
 /**
  * @file
- * Vocabulary Permissions Per Role - administration UI
+ * Vocabulary Permissions Per Role - UI
  */
-
-function vppr_form_admin_settings_vppr() {
-  $form = array();
-  $vocabs = taxonomy_get_vocabularies();
-  $roles = user_roles(TRUE); // List of roles without 'anonymous'.
-  $perms = variable_get('vppr_perms', array(array()));
-  foreach ($vocabs as $vocab) {
-    $form['vppr_vocabs'][$vocab->vid] = array(
-      '#value' => $vocab->name,
-    );
-    foreach ($roles as $rid => $role) {
-      $form['vppr_perms'][$vocab->vid][$rid] = array(
-        '#type' => 'checkbox',
-        '#default_value' => (isset($perms[$vocab->vid]) && isset($perms[$vocab->vid][$rid]) ? $perms[$vocab->vid][$rid] : 0),
-      );
-    }
-    $form['vppr_perms']['#tree'] = TRUE;
+function _vppr_taxonomy_overview_vocabularies() {
+  if (user_access('administer taxonomy')) {
+    module_load_include('inc', 'taxonomy', 'taxonomy.admin');
+    return drupal_get_form('taxonomy_overview_vocabularies');
   }
-  foreach ($roles as $rid => $role) {
-    $form['vppr_roles'][$rid] = array(
-      '#value' => $role,
-    );
+  else {
+    return vppr_overview_vocabularies();
   }
-  $form['help'] = array(
-    '#type' => 'item',
-    '#description' => t('Tick a box above to allow editing that vocabulary for that role.'),
-  );
-  $form['buttons']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save'),
-  );
-  return $form;
 }
 
-/**
- * Theme helper for vppr_form_admin_settings_vppr().
- */
-function theme_vppr_form_admin_settings_vppr($form) {
-  $header = array(FALSE);
-  foreach (element_children($form['vppr_roles']) as $rid) {
-    $header[$rid] = drupal_render($form['vppr_roles'][$rid]);
-  }
+function vppr_overview_vocabularies() {
+  $vocabularies = taxonomy_get_vocabularies();
   $rows = array();
-  foreach (element_children($form['vppr_vocabs']) as $vid) {
-    $row = array(drupal_render($form['vppr_vocabs'][$vid]));
-    foreach (element_children($form['vppr_perms'][$vid]) as $rid) {
-      $row[$rid] = drupal_render($form['vppr_perms'][$vid][$rid]);
-    }
-    $rows[$vid] = $row;
-  }
-  $buttons = drupal_render($form['buttons']);
-  return theme('table', $header, $rows) . drupal_render($form) . $buttons;
-}
-
-/**
- * Store VPPR perms to the DB.
- */
-function vppr_form_admin_settings_vppr_submit($form, &$form_state) {
-  $perms = array();
-  foreach ($form_state['values']['vppr_perms'] as $vid => $values) {
-    $values = array_filter($values);
-    if (!empty($values)) {
-      $perms[$vid] = $values;
+  foreach ($vocabularies as $vocabulary) {
+    if (user_access('administer '. $vocabulary->machine_name .' vocabulary terms')) {
+      $row = array();
+      $row[] = check_plain($vocabulary->name);
+      $row[] = l(t('list terms'), "admin/structure/taxonomy/$vocabulary->machine_name");
+      $row[] = l(t('add terms'), "admin/structure/taxonomy/$vocabulary->machine_name/add");
+      $rows[] = $row;
     }
   }
-  variable_set('vppr_perms', $perms);
+  $header = array(t('Vocabulary name'));
+  $header[] = array('data' => t('Operations'), 'colspan' => '2');
+  
+  return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No vocabularies available.'), 'attributes' => array('id' => 'vppr-vocabularies')));
 }
 
diff --git a/vppr.info b/vppr.info
index 129a4e9..96dc866 100644
--- a/vppr.info
+++ b/vppr.info
@@ -1,5 +1,5 @@
 name = Vocabulary Permissions Per Role
 description = "Allow adding to/editing terms of/removing terms from vocabularies per role."
-core = 6.x
+core = 7.x
 dependencies[] = taxonomy
 
diff --git a/vppr.module b/vppr.module
index bc37836..ab73aae 100644
--- a/vppr.module
+++ b/vppr.module
@@ -8,21 +8,24 @@
  */
 
 /**
- * Implementation of hook_menu_alter().
+ * Implements hook_menu_alter().
  */
 function vppr_menu_alter(&$items) {
-  // Taxonomy overview page: http://d6.l/admin/content/taxonomy
-  $items['admin/content/taxonomy']['access callback'] = '_vppr_access_taxonomy';
-  $items['admin/content/taxonomy']['page callback'] = '_vppr_page_taxonomy_overview';
-  // Add terms: http://d6.l/admin/content/taxonomy/$vid/add/term
-  $items['admin/content/taxonomy/%taxonomy_vocabulary/add/term']['access callback'] = '_vppr_access_vocabulary';
-  $items['admin/content/taxonomy/%taxonomy_vocabulary/add/term']['access arguments'] = array(3);
-  // Reorder terms: http://d6.l/admin/content/taxonomy/$vid
-  $items['admin/content/taxonomy/%taxonomy_vocabulary']['access callback'] = '_vppr_access_vocabulary';
-  $items['admin/content/taxonomy/%taxonomy_vocabulary']['access arguments'] = array(3);
-  // Edit and delete terms: http://d6.l/admin/content/taxonomy/edit/term/$tid - warning: there's only a tid arg!
-  $items['admin/content/taxonomy/edit/term']['access callback'] = '_vppr_access_term';
-  $items['admin/content/taxonomy/edit/term']['access arguments'] = array(5);
+  // Taxonomy overview page
+  $items['admin/structure/taxonomy']['access callback'] = 'vppr_access_taxonomy';
+  $items['admin/structure/taxonomy']['page callback'] = '_vppr_taxonomy_overview_vocabularies';
+  $items['admin/structure/taxonomy']['file'] = 'vppr.admin.inc';
+  $items['admin/structure/taxonomy']['file path'] = drupal_get_path('module', 'vppr');
+  unset($items['admin/structure/taxonomy']['page arguments']);
+  // Terms list
+  $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name']['access callback'] = 'vppr_access_vocabulary_terms';
+  $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name']['access arguments'] = array(3);
+  // Add terms
+  $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/add']['access callback'] = 'vppr_access_vocabulary_terms';
+  $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/add']['access arguments'] = array(3);
+  // Term edit
+  $items['taxonomy/term/%taxonomy_term/edit']['access callback'] = 'vppr_access_term_edit';
+  $items['taxonomy/term/%taxonomy_term/edit']['access arguments'] = array(2);
 }
 
 /**
@@ -31,15 +34,13 @@ function vppr_menu_alter(&$items) {
  * Grants access to taxonomy overview page even if $user has access to any of
  * the vocabularies.
  */
-function _vppr_access_taxonomy() {
+function vppr_access_taxonomy() {
   if (user_access('administer taxonomy')) {
     return TRUE;
   }
-  global $user;
-  $perms = variable_get('vppr_perms', array(array()));
+  $perms = array_keys(vppr_permission());
   foreach ($perms as $perm) {
-    $diff = array_intersect(array_keys($perm), array_keys($user->roles));
-    if (!empty($diff)) {
+    if (user_access($perm)) {
       return TRUE;
     }
   }
@@ -47,123 +48,90 @@ function _vppr_access_taxonomy() {
 }
 
 /**
- * VPPR's access callback for vocabularies (add and reorder terms).
+ * VPPR's access callback for terms list.
  */
-function _vppr_access_vocabulary($vocab) {
-  if (user_access('administer taxonomy')) {
+function vppr_access_vocabulary_terms($vocabulary) {
+  if (user_access('administer taxonomy')
+      || user_access('administer '. $vocabulary->machine_name .' vocabulary terms')) {
     return TRUE;
   }
-  global $user;
-  $perms = variable_get('vppr_perms', array(array()));
-  foreach ($user->roles as $rid => $role) {
-    if (isset($perms[$vocab->vid]) && isset($perms[$vocab->vid][$rid]) && $perms[$vocab->vid][$rid]) {
-      return TRUE;
-    }
-  }
   return FALSE;
 }
 
 /**
- * VPPR's access callback for term ID's (edit and delete terms).
+ * Return edit access for a given term.
  */
-function _vppr_access_term($tid) {
-  if (user_access('administer taxonomy')) {
+function vppr_access_term_edit($term) {
+  if (taxonomy_term_edit_access($term)
+      || user_access('administer '. $term->vocabulary_machine_name .' vocabulary terms')) {
     return TRUE;
   }
-  $term = taxonomy_get_term($tid);
-  // Speed up things if there is no such term.
-  if (!$term) {
-    return FALSE;
-  }
-  global $user;
-  $perms = variable_get('vppr_perms', array(array()));
-  foreach ($user->roles as $rid => $role) {
-    if (isset($perms[$vocab->vid]) && isset($perms[$vocab->vid][$rid]) && $perms[$vocab->vid][$rid]) {
-      return TRUE;
-    }
-  }
   return FALSE;
 }
 
 /**
- * Implementation of hook_perm().
+ * Return delete access for a given term.
  */
-function vppr_perm() {
-  return array('administer VPPR');
-}
-
-/**
- * Implementation of hook_menu().
- */
-function vppr_menu() {
-  $items = array();
-  $items['admin/settings/vppr'] = array(
-    'title' => 'Vocabulary permissions',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('vppr_form_admin_settings_vppr'),
-    'access arguments' => array('administer VPPR'),
-    'file' => 'vppr.admin.inc',
-    'type' => MENU_NORMAL_ITEM,
-  );
-  return $items;
+function vppr_access_term_delete($term) {
+  if (user_access("delete terms in $term->vid") 
+      || user_access('administer taxonomy')
+      || user_access('administer '. $term->vocabulary_machine_name .' vocabulary terms')) {
+    return TRUE;
+  }
+  return FALSE;
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_form_alter().
  */
-function vppr_theme() {
-  return array(
-    'vppr_form_admin_settings_vppr' => array(
-      'arguments' => array('form' => array()),
-      'file' => 'vppr.admin.inc',
-    ),
-  );
+function vppr_form_alter(&$form, &$form_state, $form_id) {
+  if ($form_id == 'taxonomy_form_term'
+      && isset($form['tid']['#value'])
+      && isset($form['actions']['delete']['#access'])) {
+    if ($term = taxonomy_term_load($form['tid']['#value'])) {
+      $form['actions']['delete']['#access'] = vppr_access_term_delete($term);
+    }
+  }
 }
 
 /**
- * Page callback for taxonomy overview.
- *
- * Displays the form core ships if $user has 'administer taxonomy' permission,
- * or a simple list that mimics the same otherwise. Rationale: don't display
- * even a stripped-down form if we don't need a form but only a
- * nicely-formatted list.
- *
- * @see taxonomy_overview_vocabularies()
+ * Implements hook_permission().
  */
-function _vppr_page_taxonomy_overview($form_id) {
-  // If $user has 'administer taxonomy', then do not do anything, just bail
-  // out early with the untouched form.
-  if (user_access('administer taxonomy')) {
-    return drupal_get_form($form_id);
-  }
-  $header = array(
-    t('Name'),
-    t('Type'),
-    array(
-      'data' => t('Operations'),
-      'colspan' => '2',
-    ),
-  );
-  $rows = array();
+function vppr_permission() {
+  $perms = array();
   $vocabularies = taxonomy_get_vocabularies();
   foreach ($vocabularies as $vocabulary) {
-    if (!_vppr_access_vocabulary($vocabulary)) {
-      continue;
-    }
-    $types = array();
-    foreach ($vocabulary->nodes as $type) {
-      $node_type = node_get_types('name', $type);
-      $types[] = $node_type ? check_plain($node_type) : check_plain($type);
-    }
-    $rows[] = array(
-      check_plain($vocabulary->name),
-      implode(', ', $types),
-      l(t('list terms'), "admin/content/taxonomy/$vocabulary->vid"),
-      l(t('add terms'), "admin/content/taxonomy/$vocabulary->vid/add/term"),
-    );
+    $perms['administer '. $vocabulary->machine_name .' vocabulary terms'] = array('title' => t('Administer %name vocabulary terms', array('%name' => $vocabulary->name)));
   }
-  if (empty($rows)) {
-    $rows[] = array(array('data' => t('No vocabularies available.'), 'colspan' => '4'));
+  return $perms;
+}
+/**
+ * Implements hook_taxonomy_vocabulary_update().
+ */
+function vppr_taxonomy_vocabulary_update($vocabulary) {
+  if ($vocabulary->old_machine_name != $vocabulary->machine_name) {
+    db_update('role_permission')
+      ->fields(array(
+          'permission' => 'administer '. $vocabulary->machine_name .' vocabulary terms',
+        ))
+      ->condition('permission', 'administer '. $vocabulary->old_machine_name . ' vocabulary terms')
+      ->execute();
+    
+  // Clear the user access cache.
+  drupal_static_reset('user_access');
+  drupal_static_reset('user_role_permissions');
   }
-  return theme('table', $header, $rows);
 }
+
+/**
+ * Implements hook_taxonomy_vocabulary_delete().
+ */
+function vppr_taxonomy_vocabulary_delete($vocabulary) {
+    db_delete('role_permission')
+      ->condition('permission', 'administer ' . $vocabulary->machine_name . ' vocabulary terms')
+      ->execute();
+    
+  // Clear the user access cache.
+  drupal_static_reset('user_access');
+  drupal_static_reset('user_role_permissions');
+}
\ No newline at end of file
