diff --git a/userpoints_nodelimit/userpoints_nodelimit.info b/userpoints_nodelimit/userpoints_nodelimit.info
index c9d6ac5..a2dc6f8 100644
--- a/userpoints_nodelimit/userpoints_nodelimit.info
+++ b/userpoints_nodelimit/userpoints_nodelimit.info
@@ -1,5 +1,8 @@
 name = User Points Node Limit
 description = Limits the creation of specific nodes based on the available number of userpoints
 package = Userpoints
-core = 6.x
+core = 7.x
+configure = admin/config/people/userpoints/settings 
 dependencies[] = userpoints
+files[] = userpoints_nodelimit.module
+files[] = userpoints_nodelimit.install
diff --git a/userpoints_nodelimit/userpoints_nodelimit.install b/userpoints_nodelimit/userpoints_nodelimit.install
index fa861da..d574b16 100644
--- a/userpoints_nodelimit/userpoints_nodelimit.install
+++ b/userpoints_nodelimit/userpoints_nodelimit.install
@@ -1,32 +1,35 @@
-<?php
-
-/**
-* Implementation of hook_install().
-*/
-function userpoints_nodelimit_install() {
-	
-	db_query("UPDATE {system} SET weight = 5 WHERE name = 'userpoints_nodelimit'");
-  drupal_set_message(t('User Points Node Limit has been successfully installed.'));
-  drupal_set_message(t('You can configure the User Points Node Limit module on the <a href="@url">Content Types settings page</a>.', array('@url' => url('admin/content/types/list'))));
-}
-
-
-
-/**
- * Implementation of hook_uninstall().
- */
-function userpoints_nodelimit_uninstall() {
-  foreach (node_get_types('names') as $type => $type_name) {
-    variable_del('userpoints_nodelimit_'. $type);
-    variable_del('userpoints_nodelimit_nodepoints_'. $type);
-  }
-}
-
-/**
- * make sure hooks are invoked after cck main hooks
- */
-function userpoints_nodelimit_update_1() {
-  $ret = array();
-  $ret[] = update_sql("UPDATE {system} SET weight = 5 WHERE name = 'userpoints_nodelimit'");
-  return $ret;
-}
\ No newline at end of file
+<?php
+// $Id$
+
+/**
+ * @file
+ * Installs userpoints node limit.
+ */
+
+/**
+ * Implements hook_install().
+ */
+function userpoints_nodelimit_install() {
+  db_query("UPDATE {system} SET weight = 5 WHERE name = 'userpoints_nodelimit'");
+}
+
+
+
+/**
+ * Implements hook_uninstall().
+ */
+function userpoints_nodelimit_uninstall() {
+  foreach (node_type_get_types('names') as $type => $type_name) {
+    variable_del('userpoints_nodelimit_' . $type);
+    variable_del('userpoints_nodelimit_nodepoints_' . $type);
+  }
+}
+
+/**
+ * MAke sure hooks are invoked after cck main hooks
+ */
+function userpoints_nodelimit_update_1() {
+  $ret = array();
+  $ret[] = update_sql("UPDATE {system} SET weight = 5 WHERE name = 'userpoints_nodelimit'");
+  return $ret;
+}
diff --git a/userpoints_nodelimit/userpoints_nodelimit.module b/userpoints_nodelimit/userpoints_nodelimit.module
index e73013a..9d00185 100644
--- a/userpoints_nodelimit/userpoints_nodelimit.module
+++ b/userpoints_nodelimit/userpoints_nodelimit.module
@@ -1,91 +1,112 @@
 <?php
+// $Id$
+
+/**
+ * @file
+ * Implements userpoints node limit.
+ */
 
 /**
  * Enables a limit on node creation based on user's current user points.
  * Can't create the node if the points for the node is negative and would
  * bring the user below 0 points.
  *
- * 
+ *
  * @author Eric Wright, eric.wright@bluevestconsulting.com
- * 
+ *
  * Many thanks to Jesse Mortenson for the original 5.x version &
  * Wolfgang Ziegler for auto_nodetitle which I leaned on heavily
  *
+ * Updated to Drupal 7 by Bastlynn ( bastlynn@gmail.com )
  */
 
 define('USERPOINTS_NODELIMIT_DISABLED', 0);
 define('USERPOINTS_NODELIMIT_ENABLED', 1);
 
 /**
- * Implementation of hook_form_alter().
+ * Implements hook_node_type_delete().
+ */
+function userpoints_nodelimit_node_type_delete($info) {
+  variable_del('userpoints_nodelimit_' . $info->type);
+  variable_del('userpoints_nodelimit_nodepoints_' . $info->type);
+}
+
+/**
+ * Implements hook_node_type_update().
  */
-function userpoints_nodelimit_form_alter(&$form, $form_state, $form_id) {
+function userpoints_nodelimit_node_type_update($info) {
+  if (!empty($info->old_type) && $info->old_type != $info->type) {
+    variable_set('userpoints_nodelimit_' . $info->type, userpoints_nodelimit_get_setting($info->old_type));
+    variable_set('userpoints_nodelimit_nodepoints_' . $info->type, variable_get('userpoints_nodelimit_nodepoints_' . $info->old_type, ''));
+    variable_del('userpoints_nodelimit_' . $info->old_type);
+    variable_del('userpoints_nodelimit_nodepoints_' . $info->old_type);
+  }
+}
 
+/**
+ * Implements hook_form_alter().
+ */
+function userpoints_nodelimit_form_alter(&$form, &$form_state, $form_id) {
   if (isset($form['#node_type']) && 'node_type_form' == $form_id) {
+    // Add configuration options for each node type in configuration.
     userpoints_nodelimit_node_settings_form($form);
   }
   else {
-    if (isset($form['#node']) && isset($form['#method']) && $form['#node']->type .'_node_form' == $form_id) {
-      $type = $form['#node']->type;
+    // Check on content creation page for node limits.
+    if (isset($form['#node']) && isset($form['#method']) && $form['#node']->type . '_node_form' == $form_id) {
       // This is a node form; user is either adding a new node or editing an existing one.
       // Don't check if user is editing node.  Access check has happened already, so user is assumed to have access to edit / create this node type.
-      if (userpoints_nodelimit_get_setting($type) == USERPOINTS_NODELIMIT_ENABLED) {
-        // check the number of available user points against the requirements for this node
+      if (userpoints_nodelimit_get_setting($form['#node']->type) == USERPOINTS_NODELIMIT_ENABLED) {
+        // Check the number of available user points against the requirements for this node
         // Only check when user is adding a new node.  $form['#node']->nid is unset when adding a new node.
-        if (!isset($form['#node']->nid) && !userpoints_nodelimit_check($type)) {
-          $friendly_name = node_get_types('name', $form['#node']); 
-          drupal_set_message(theme('userpoints_nodelimit_insufficent_points_message', $type, $friendly_name), 'error');
-      	  //destroy the form
-      	  $form = NULL;
-      	  //return a simple hidden field so that function doesn't fail
-      	  $form['dummy'] = array(
-       		  '#type' => 'hidden',
-        	  '#default_value' => '',
-      	  );
+        if (!isset($form['#node']->nid) && !userpoints_nodelimit_check($form['#node']->type)) {
+        drupal_set_message(userpoints_nodelimit_insufficent_points_message($form['#node']->type), 'error');
+        // If not allowed, then destroy the form.
+        $form = NULL;
+        // Return a simple hidden field so that the function doesn't fail.
+        $form['dummy'] = array(
+          '#type' => 'hidden',
+          '#default_value' => '',
+          );
         }
         else {
-     		  // add a validate function as the points may change between the opening for the form  
-     		  // and the submission of the form, so we should check again prior to submission
-				  $form['#validate'][] = 'userpoints_nodelimit_validate';
-			  }
+          // Add a validate function as the points may change during submission. (With Rules for example.)
+          $form['#validate'][] = 'userpoints_nodelimit_validate';
+        }
       }
     }
   }
 }
 
 /**
-  * Form validation
-  */ 
+ * Form validation for node submission.
+ */
 function userpoints_nodelimit_validate($form, &$form_state) {
-  // check the user points and confirm they have enough
-  $type = $form['#node']->type;
-  // check the number of available user points against the requirements for this node
+  // Check the number of available user points against the requirements for this node.
   // Only check when user is adding a new node.  $form['#node']->nid is unset when adding a new node.
-  if (!isset($form['#node']->nid) && !userpoints_nodelimit_check($type)) {
-    $friendly_name = node_get_types('name', $form['#node']); 
-    form_set_error('userpoints_nodelimit_details', theme('userpoints_nodelimit_insufficent_points_message',$type, $friendly_name));
+  if (!isset($form['#node']->nid) && !userpoints_nodelimit_check($form['#node']->type)) {
+    form_set_error('userpoints_nodelimit_details', userpoints_nodelimit_insufficent_points_message($form['#node']->type));
   }
 }
 
 /**
-  * Node Limit Error Message
-  */
-function theme_userpoints_nodelimit_insufficent_points_message($node_type, $friendly_name) {
-	$html_message =	t('You do not have enough !points to create @friendly content.<br />You currently have @user_points !points, you need @node_points !points to create a @friendly.', 
-    array_merge(userpoints_translation(), 
-    array('@user_points' => userpoints_get_current_points($user->uid), 
-      '@node_points' => variable_get('userpoints_nodelimit_nodepoints_'.$node_type, '?'),
-      '@friendly' => $friendly_name,
-      '@type' => $node_type
-      ) 
-    )
+ * Return the node limit error mesage.
+ */
+function theme_userpoints_nodelimit_insufficent_points_message($node_type) {
+  $html_message =  t('You do not have enough !points to create @type content.<br />You currently have @user_points !points, you need @node_points !points to create a @type.',
+    array_merge(userpoints_translation(),
+    array('@user_points' => userpoints_get_current_points($user->uid),
+      '@node_points' => variable_get('userpoints_nodelimit_nodepoints_' . $node_type, '?'),
+      '@type' => $node_type,
+      ),
+    ),
   );
   return $html_message;
 }
 
 /**
-  * Helper function for hook_form_alter() renders the settings per node-type.
-  */
+ * Helper function renders the settings per node-type form.
+ */
 function userpoints_nodelimit_node_settings_form(&$form) {
   $form['userpoints_nodelimit'] = array(
     '#type' => 'fieldset',
@@ -94,47 +115,25 @@ function userpoints_nodelimit_node_settings_form(&$form) {
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
-  
   $form['userpoints_nodelimit']['userpoints_nodelimit'] = array(
     '#type' => 'checkbox',
     '#title' => t('Enable User Points Node Limit for this type.'),
     '#description' => t('Node Limit will check to ensure users trying to create this node type have the required number of user points.'),
     '#default_value' => userpoints_nodelimit_get_setting($form['#node_type']->type),
   );
-    
   $form['userpoints_nodelimit']['userpoints_nodelimit_nodepoints'] = array(
     '#type' => 'textfield',
     '#title' => t('User Points Required'),
     '#description' => t('Enter the number of user points required to create a new node of this type.'),
-    '#default_value' => variable_get('userpoints_nodelimit_nodepoints_'. $form['#node_type']->type, '0'),
+    '#default_value' => variable_get('userpoints_nodelimit_nodepoints_' . $form['#node_type']->type, '0'),
   );
 }
 
 /**
- * Gets the userpoints node limit setting associated with the given content type.
+ * Get the userpoints node limit setting associated with the given content type.
  */
 function userpoints_nodelimit_get_setting($type) {
-  return variable_get('userpoints_nodelimit_'. $type, USERPOINTS_NODELIMIT_DISABLED);
-}
-
-/**
- * Implementation of hook_node_type().
- */
-function userpoints_nodelimit_node_type($op, $info) {
-  switch ($op) {
-    case 'delete':
-      variable_del('userpoints_nodelimit_'. $info->type);
-      variable_del('userpoints_nodelimit_nodepoints_'. $info->type);
-      break;
-    case 'update':
-      if (!empty($info->old_type) && $info->old_type != $info->type) {
-        variable_set('userpoints_nodelimit_'. $info->type, userpoints_nodelimit_get_setting($info->old_type));
-        variable_set('userpoints_nodelimit_nodepoints_'. $info->type, variable_get('userpoints_nodelimit_nodepoints_'. $info->old_type, ''));
-        variable_del('userpoints_nodelimit_'. $info->old_type);
-        variable_del('userpoints_nodelimit_nodepoints_'. $info->old_type);
-      }
-      break;
-  }
+  return variable_get('userpoints_nodelimit_' . $type, USERPOINTS_NODELIMIT_DISABLED);
 }
 
 /**
@@ -142,9 +141,8 @@ function userpoints_nodelimit_node_type($op, $info) {
  */
 function userpoints_nodelimit_check($nodetype) {
   global $user;
-
   $current_points = userpoints_get_current_points($user->uid);
-  $node_points = variable_get('userpoints_nodelimit_nodepoints_'. $nodetype, 0);
+  $node_points = variable_get('userpoints_nodelimit_nodepoints_' . $nodetype, 0);
   if ($current_points >= $node_points) {
     return TRUE;
   }
@@ -152,14 +150,3 @@ function userpoints_nodelimit_check($nodetype) {
     return FALSE;
   }
 }
-
-/**
- * Implementation of hook_theme()
- */
-
-function userpoints_nodelimit_theme($existing, $type, $theme, $path) {
-  return array(
-    'userpoints_nodelimit_insufficent_points_message' => array(
-      'arguments' => array('node_type' => NULL, 'friendly_name' => NULL),
-      ));
-}
\ No newline at end of file
