diff --git a/userpoints_cap/userpoints_cap.info b/userpoints_cap/userpoints_cap.info
index 4ef1930..00f58c9 100644
--- a/userpoints_cap/userpoints_cap.info
+++ b/userpoints_cap/userpoints_cap.info
@@ -1,5 +1,6 @@
 name = Userpoints Cap
 description = Limit the number of points a user can earn.
 package = Userpoints
+configure = admin/config/people/userpoints/settings
 dependencies[] = userpoints
-core = 6.x
\ No newline at end of file
+core = 7.x
diff --git a/userpoints_cap/userpoints_cap.install b/userpoints_cap/userpoints_cap.install
new file mode 100644
index 0000000..5991991
--- /dev/null
+++ b/userpoints_cap/userpoints_cap.install
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * @file
+ * Provides for uninstall cleanup of userpoints_cap variables.
+ */
+
+/**
+ * Implements hook_uninstall().
+ */
+function userpoints_nodelimit_uninstall() {
+  variable_del('userpoints_cap_enabled');
+  $categories = userpoints_get_categories();
+  foreach ($categories as $tid => $category) {
+    variable_del('userpoints_cap_maximum_' . $tid);
+    variable_del('userpoints_cap_message_' . $tid);
+  }
+}
diff --git a/userpoints_cap/userpoints_cap.js b/userpoints_cap/userpoints_cap.js
new file mode 100644
index 0000000..d46ac4f
--- /dev/null
+++ b/userpoints_cap/userpoints_cap.js
@@ -0,0 +1,14 @@
+(function ($) {
+  Drupal.behaviors.userpointsCapFieldsetSummaries = {
+    attach: function (context) {
+      $('fieldset#edit-userpoints-cap', context).drupalSetSummary(function (context) {
+        if ($('#edit-userpoints-cap-enabled').is(':checked')) {
+          return Drupal.t('Enabled');
+        }
+        else {
+          return Drupal.t('Disabled');
+        }
+      })
+    }
+  };
+})(jQuery);
diff --git a/userpoints_cap/userpoints_cap.module b/userpoints_cap/userpoints_cap.module
index 6d58438..25a0a3b 100644
--- a/userpoints_cap/userpoints_cap.module
+++ b/userpoints_cap/userpoints_cap.module
@@ -6,49 +6,76 @@
  * Limit the number of points a user can earn.
  * @author Mike Smullin (http://www.mikesmullin.com), D6 update by fred0
  * @license GNU General Public License (http://www.gnu.org/copyleft/gpl.html)
+ *
+ * Updated to Drupal 7 by Bastlynn (bastlynn@gmail.com)
  */
 
-define('USERPOINTS_CAP_MAXIMUM', 'userpoints_cap_maximum');
-define('USERPOINTS_CAP_MAXIMUM_DEFAULT', 1000000);
-define('USERPOINTS_CAP_MESSAGE', 'userpoints_cap_message');
-define('USERPOINTS_CAP_MESSAGE_DEFAULT', '!Points are limited to a maximum; you must spend to earn more.');
-
+/**
+ * Implements hook_userpoints().
+ */
 function userpoints_cap_userpoints($op, $params = array()) {
-  switch($op) {
+  switch ($op) {
     case 'setting':
-      $group = 'userpoints_cap';
-      $form[$group] = array(
+      $form['userpoints_cap'] = array(
         '#type' => 'fieldset',
-        '#title' => t('!Points Cap', userpoints_translation()),
-        '#description' =>  t('Maximum number of !points allowed for each user.', userpoints_translation()),
         '#collapsible' => TRUE,
         '#collapsed' => TRUE,
+        '#title' => t('!Points cap', userpoints_translation()),
+        '#group' => 'settings_additional',
+        '#weight' => 25,
+        '#attached' => array(
+          'js' => array(
+            'userpoints_cap' => drupal_get_path('module', 'userpoints_cap') . '/userpoints_cap.js',
+          ),
+        ),
       );
-
-      $form[$group][USERPOINTS_CAP_MAXIMUM] = array(
-        '#type' => 'textfield',
-        '#title' => t('Maximum !Points per User', userpoints_translation()),
-        '#default_value' => t(variable_get(USERPOINTS_CAP_MAXIMUM, USERPOINTS_CAP_MAXIMUM_DEFAULT), userpoints_translation()),
-      );
-      $form[$group][USERPOINTS_CAP_MESSAGE] = array(
-        '#type' => 'textarea',
-        '#title' => t('Maximum !Points Exceeded Message', userpoints_translation()),
-        '#default_value' => t(variable_get(USERPOINTS_CAP_MESSAGE, USERPOINTS_CAP_MESSAGE_DEFAULT), userpoints_translation()),
-        '#description' =>  t('The message a user will see if they exceed the cap. Insert '.'<b>!</b>'.'<b>Points</b> to use the branded name of your points.', userpoints_translation()),
+      $form['userpoints_cap']['userpoints_cap_enabled'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Enabled by default'),
+        '#default_value' => variable_get('userpoints_cap_enabled', TRUE),
+        '#description' => t('If checked, all transactions will be checked for caps before awarding !points.', userpoints_translation()),
       );
-
+      $categories = userpoints_get_categories();
+      foreach ($categories as $tid => $category) {
+        $form['userpoints_cap']['userpoints_cap_maximum_' . $tid] = array(
+          '#type' => 'textfield',
+          '#title' => t('Maximum !points for category ' . $category, userpoints_translation()),
+          '#default_value' => variable_get('userpoints_cap_maximum_' . $tid, -1),
+          '#description' =>  t('Maximum number of !points allowed for each user. Set to -1 to allow unlimted !points.', userpoints_translation()),
+        );
+        $form['userpoints_cap']['userpoints_cap_message_' . $tid] = array(
+          '#type' => 'textarea',
+          '#title' => t('Maximum !points message for category ' . $category, userpoints_translation()),
+          '#default_value' => variable_get('userpoints_cap_message_' . $tid, '!Category !points are limited to a maximum number of !cap. You must spend !points to earn more.'),
+          '#description' => t('The message a user will see if they exceed the cap. ' .
+            'The replacement values of !Points, !points, !Point, !point are available. '.
+            'In addition, !Category, !category, and !cap are available as well for you to construct a useful message for your users.'),
+        );
+      }
       return $form;
       break;
-
     case 'points before':
-      $current_points = userpoints_get_current_points($uid, 'all');
-      $new_points = $params['points'];
-      $max_points = variable_get(USERPOINTS_CAP_MAXIMUM, USERPOINTS_CAP_MAXIMUM_DEFAULT);
-      if ($current_points + $new_points > $max_points) {
-        drupal_set_message(variable_get(USERPOINTS_CAP_MESSAGE, USERPOINTS_CAP_MESSAGE_DEFAULT));
-        return FALSE; // DO NOT add points
-      } else {
-        return TRUE; // OK to add points
+      if (variable_get('userpoints_cap_enabled', TRUE)) {
+        $current_points = userpoints_get_current_points($params['uid'], $params['tid']);
+        $categories = userpoints_get_categories();
+        $category = $categories[$params['tid']];
+        $new_points = $params['points'];
+        $max_points = variable_get('userpoints_cap_maximum_' . $params['tid'], -1);
+        if (($max_points != -1) && ($current_points + $new_points > $max_points)) {
+          $message = strtr(variable_get('userpoints_cap_message_' . $params['tid'], '!Category !points are limited to a maximum number of !cap. You must spend !points to earn more.'),
+            array_merge(userpoints_translation(), array(
+              '!Category' => ucfirst($category),
+              '!category' => $category,
+              '!cap' => $max_points
+            ))
+          );
+          /* Not using t() here is deliberate. See conversation at: http://drupal.org/node/1133828 */
+          drupal_set_message($message);
+          return FALSE; // DO NOT add points
+        }
+        else {
+          return TRUE; // OK to add points
+        }
       }
       break;
   }
