diff --git a/node_limit.info b/node_limit.info
index fdb8555..e9cfdfa 100644
--- a/node_limit.info
+++ b/node_limit.info
@@ -1,4 +1,7 @@
 name = Node Limit
 description = Allows admins to restrict the number of nodes that may be created.
 package = Node Limit
-core = 6.x
+core = 7.x
+
+files[] = node_limit.install
+files[] = node_limit.module
diff --git a/node_limit.install b/node_limit.install
index 63853ea..6184f00 100644
--- a/node_limit.install
+++ b/node_limit.install
@@ -1,5 +1,5 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Installation functions for module node_limit.
@@ -8,13 +8,6 @@
 define("NODE_LIMIT_NO_LIMIT", -1);
 
 /**
- * Implementation of hook_install().
- */
-function node_limit_install() {
-  drupal_install_schema('node_limit');
-}
-
-/**
  * Implementation of hook_schema().
  */
 function node_limit_schema() {
@@ -22,32 +15,32 @@ function node_limit_schema() {
     'description' => t('The base Node Limit table'),
     'fields' => array(
       'lid' => array(
-        'description' => t('The limit id'),
+        'description' => 'The limit id',
         'type' => 'int',
         'not null' => TRUE
       ),
       'type' => array(
-        'description' => t('The {node}.type to which this limit applies'),
+        'description' => 'The {node}.type to which this limit applies',
         'type' => 'varchar',
         'length' => 32,
         'not null' => TRUE,
         'default' => ''
       ),
       'limit' => array(
-        'description' => t('The node limit for this limit'),
+        'description' => 'The node limit for this limit',
         'type' => 'int',
         'not null' => TRUE,
         'default' => NODE_LIMIT_NO_LIMIT
       ),
       'title' => array(
-        'description' => t('The display name for this limit'),
+        'description' => 'The display name for this limit',
         'type' => 'varchar',
         'length' => 255,
         'not null' => TRUE,
         'default' => ''
       ),
       'weight' => array(
-        'description' => t('The weight of this limit'),
+        'description' => 'The weight of this limit',
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0
@@ -69,11 +62,4 @@ function node_limit_update_6001() {
   db_query("INSERT INTO {node_limit_type} (SELECT lid, type FROM {node_limit})");
   $ret = update_sql("ALTER TABLE {node_limit} DROP COLUMN `type`");
   return $ret;
-}
-
-/*
- * Implementation of hook_uninstall().
- */
-function node_limit_uninstall() {
-  drupal_uninstall_schema('node_limit');
-}
+}
\ No newline at end of file
diff --git a/node_limit.module b/node_limit.module
index ffdac64..24e5195 100644
--- a/node_limit.module
+++ b/node_limit.module
@@ -1,11 +1,11 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Module to restrict the number of nodes a user or role may create.
  */
 
-define("NODE_LIMIT_NO_LIMIT", -1);
+define("NODE_LIMIT_NO_LIMIT", 'none');
 
 define("NODE_LIMIT_PERM_ADMIN", "administer node limits");
 
@@ -16,7 +16,7 @@ define("NODE_LIMIT_LIMIT_NEUTRAL", 2);
 /**
  * Implementation of hook_perm().
  */
-function node_limit_perm() {
+function node_limit_permission() {
   return array(NODE_LIMIT_PERM_ADMIN);
 }
 
@@ -25,41 +25,41 @@ function node_limit_perm() {
  */
 function node_limit_menu() {
   $items = array();
-  $items['admin/user/node_limit'] = array(
-    'title' => t('Node Limits'),
+  $items['admin/structure/node_limit'] = array(
+    'title' => 'Node Limits',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('node_limit_list_limits'),
     'access arguments' => array(NODE_LIMIT_PERM_ADMIN)
   );
-  $items['admin/user/node_limit/list'] = array(
-    'title' => t('List'),
+  $items['admin/structure/node_limit/list'] = array(
+    'title' => 'List',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'access arguments' => array(NODE_LIMIT_PERM_ADMIN),
     'weight' => -10
   );
-  $items['admin/user/node_limit/add'] = array(
-    'title' => t('Add Node Limit'),
+  $items['admin/structure/node_limit/add'] = array(
+    'title' => 'Add Node Limit',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('node_limit_limit_form', '0'),
+    'page arguments' => array('node_limit_limit_form'),
     'access arguments' => array(NODE_LIMIT_PERM_ADMIN),
     'type' => MENU_LOCAL_TASK
   );
-  $items['admin/user/node_limit/%node_limit'] = array(
-    'title' => t('Edit Node Limit'),
+  $items['admin/structure/node_limit/%node_limit'] = array(
+    'title' => 'Edit Node Limit',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('node_limit_limit_form', 3),
     'access arguments' => array(NODE_LIMIT_PERM_ADMIN),
     'type' => MENU_LOCAL_TASK
   );
-  $items['admin/user/node_limit/%node_limit/delete'] = array(
-    'title' => t('Delete Node Limit'),
+  $items['admin/structure/node_limit/%node_limit/delete'] = array(
+    'title' => 'Delete Node Limit',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('node_limit_delete_form', 3),
     'access arguments' => array(NODE_LIMIT_PERM_ADMIN),
     'type' => MENU_CALLBACK
   );
-  $items['admin/user/node_limit/%node_limit/clone'] = array(
-    'title' => t('Clone Node Limit'),
+  $items['admin/structure/node_limit/%node_limit/clone'] = array(
+    'title' => 'Clone Node Limit',
     'page callback' => 'node_limit_clone_limit',
     'page arguments' => array(3),
     'access arguments' => array(NODE_LIMIT_PERM_ADMIN),
@@ -73,41 +73,48 @@ function node_limit_menu() {
  * Implementation of hook_theme().
  * Register the two forms that require custom rendering.
  */
+ 
 function node_limit_theme() {
   return array(
     'node_limit_limit_form' => array(
-      'arguments' => array('form' => NULL)
+      'variables' => array('form' => NULL)
     ),
+/*
     'node_limit_list_limits' => array(
-      'arguments' => array('form' => NULL)
+      'variables' => array('form' => NULL)
     )
-  );
+    */
+  );  
 }
 
+
 /**
- * Implementation of hook_nodeapi().
+ * Implementation of hook_node_prepare().
  *
  * This is where we'll determine if the user may create new nodes or not.
  * We'll key off $op == 'prepare', which is sent before the edit/add form
  * is constructed.
- */
-function node_limit_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
-  if ($op == 'prepare') {
-    if ($node->nid == 0 && _node_limit_violates_limit($node)) {
-      //we have a violation!
-      //and this is a new node
-      $nodetypename = node_get_types('name', $node);
-      drupal_set_message(t("You can't create more content of type !type", array('!type' => $nodetypename)), 'error');
-      drupal_goto('node/add');
-    }
-  }
-  else if ($op == 'validate') {
-    print_r($node);
-    die();
+ */ 
+function node_limit_node_prepare($node) {  
+  if ($node->nid == 0 && _node_limit_violates_limit($node)) {
+    //we have a violation!
+    //and this is a new node
+    $nodetypename = node_type_get_name($node);
+    drupal_set_message(check_plain("You can't create more content of type !type", array('!type' => check_plain($nodetypename))), 'error');
+    drupal_goto('node/add');
   }
 }
 
 /**
+ * Implementation of hook_node_prepare().
+ */
+function hook_node_validate($node, $form, &$form_state) {
+  print_r($node);
+  die();
+}
+
+
+/**
  * Helper function to check limit violations for this node.
  * Always returns FALSE for user 1.
  *
@@ -149,9 +156,9 @@ function _node_limit_sql($lid) {
   $limit = node_limit_load($lid);
   
   $joins = (isset($components['join']) ? implode(' ', $components['join']) : '');
-  $wheres = (isset($components['where']) ? 'WHERE '. implode(' AND ', $components['where']) : '');
+  $wheres = (isset($components['where']) ? 'WHERE ' . implode(' AND ', $components['where']) : '');
 
-  return $sql .' '. $joins .' '. $wheres;
+  return $sql . ' ' . $joins . ' ' . $wheres;
 }
 
 /**
@@ -163,7 +170,12 @@ function _node_limit_sql($lid) {
 function node_limit_limits(&$node) {
   $user = user_load($node->uid);
   //get all the limits:
-  $res = db_query("SELECT lid FROM {node_limit} ORDER BY weight ASC");
+  //$query = db_query("SELECT lid FROM {node_limit} ORDER BY weight ASC");  
+  $query = db_select('node_limit', 'nl')
+    ->fields('lid')
+    ->orderBy('weight', 'ASC')
+    ->execute();
+    
   $applicable_limits = array();
   while ($l = db_fetch_array($res)) {
     // This particular limit id.
@@ -191,40 +203,52 @@ function node_limit_limits(&$node) {
  * Theme the node limit list form.
  */
 function theme_node_limit_list_limits($form) {
-  $header = array(
-    t('Title'),
-    t('Limit'),
-    t('Weight'),
-    t('Actions')
-  );
-  $rows = array();
-  foreach (element_children($form['limits']) as $lid) {
-    $row = array();
-    $form['limits'][$lid]['weight']['#attributes']['class'] = 'node_limit-weight';
-    $row[] = drupal_render($form['limits'][$lid]['title']);
-    $row[] = drupal_render($form['limits'][$lid]['limit']);
-    $row[] = drupal_render($form['limits'][$lid]['weight']);
-    $row[] = drupal_render($form['limits'][$lid]['actions']);
-    $rows[] = array(
-      'data' => $row,
-      'class' => 'draggable'
+  dpm($form);
+  /*
+  if (isset($form[0]['limits']))
+  {
+    
+    $header = array(
+      t('Title'),
+      t('Limit'),
+      t('Weight'),
+      t('Actions')
     );
+    $rows = array();
+    foreach (element_children($form['limits']) as $lid) {
+      $row = array();
+      $form['limits'][$lid]['weight']['#attributes']['class'] = 'node_limit-weight';
+      $row[] = drupal_render($form['limits'][$lid]['title']);
+      $row[] = drupal_render($form['limits'][$lid]['limit']);
+      $row[] = drupal_render($form['limits'][$lid]['weight']);
+      $row[] = drupal_render($form['limits'][$lid]['actions']);
+      $rows[] = array(
+        'data' => $row,
+        'class' => 'draggable'
+      );
+    }
+    dpm($rows);
+    if (count($rows) > 0) {
+      $out = theme('table', $header, $rows, array('id' => 'node_limit-table'));
+    } 
+     
+    //$out .= drupal_render($form);
+    /*
+    drupal_add_tabledrag('node_limit-table', 'order', 'sibling', 'node_limit-weight');
+    return $out;
+    */
+  /*
   }
-
-  if (count($rows) > 0) {
-    $out = theme('table', $header, $rows, array('id' => 'node_limit-table'));
-  }
-  $out .= drupal_render($form);
-  drupal_add_tabledrag('node_limit-table', 'order', 'sibling', 'node_limit-weight');
-  return $out;
-
+  */
+    
+  
 }
 
 /**
  * Form for listing the created limits.
  * Created as a form so that the user can adjust the weight.
  */
-function node_limit_list_limits() {
+function node_limit_list_limits($form, &$form_state) {
   $weights = array();
   for ($i = -10; $i <= 10; $i++) {
     $weights[$i] = $i;
@@ -233,9 +257,12 @@ function node_limit_list_limits() {
   $form = array('#tree' => TRUE);
   $form['limits'] = array();
   $sql = "SELECT * FROM {node_limit} ORDER BY weight ASC";
-  $res = db_query($sql);
+  $result = db_query($sql)->fetchAssoc();
   $limit_count = 0;
-  while ($rec = db_fetch_array($res)) {
+  dpm($result);
+  
+  while ($rec = $result) {
+    dpm($rec);
     $limit_count++;
     $form['limits'][$rec['lid']]['weight'] = array(
       '#type' => 'select',
@@ -249,12 +276,12 @@ function node_limit_list_limits() {
       '#value' => $rec['limit']
     );
     $form['limits'][$rec['lid']]['actions'] = array(
-      '#value' => l(t('Edit'), 'admin/user/node_limit/'. $rec['lid']) .' '. 
-                  l(t('Delete'), 'admin/user/node_limit/'. $rec['lid'] .'/delete') .' '.
-                  l(t('Clone'), 'admin/user/node_limit/'.$rec['lid'] .'/clone')
+      '#value' => l(t('Edit'), 'admin/structure/node_limit/' . $rec['lid']) . ' ' . 
+                  l(t('Delete'), 'admin/structure/node_limit/' . $rec['lid'] . '/delete') . ' ' .
+                  l(t('Clone'), 'admin/structure/node_limit/' . $rec['lid'] . '/clone')
     );
   }
-
+  
   if ($limit_count > 0) {
     $form['save'] = array(
       '#type' => 'submit',
@@ -263,10 +290,11 @@ function node_limit_list_limits() {
   }
   else {
     $form['create'] = array(
-      '#value' => l(t('Add a new node limit'), 'admin/user/node_limit/add')
+      '#value' => l(t('Add a new node limit'), 'admin/structure/node_limit/add')
     );
   }
 
+  dpm($form);
   return $form;
 }
 
@@ -285,16 +313,17 @@ function node_limit_list_limits_submit($form_id, &$form_state) {
  * Theme the admin settings form so that we have tables inside fieldsets.
  */
 function theme_node_limit_limit_form($form) {
-  if (!isset($form['info'])) {
-    return;
+  
+  if (!isset($form['info'])) {    
+    return;    
   }
   $rows = array();
-
+  dpm($form);
   foreach ($form['node_limit_elements'] as $module => &$element) {
     if (is_array($element['applies']) && is_array($element['element'])) {
       if ($element['element']['#custom_render'] === TRUE && module_hook($module, 'node_limit_render_element')) {
         // We can't use module_invoke because form elements must be passed byref.
-        $func = $module .'_node_limit_render_element';
+        $func = $module . '_node_limit_render_element';
         $rendered_element = $func($element['element']);
       }
       else {
@@ -312,19 +341,26 @@ function theme_node_limit_limit_form($form) {
     $output .= theme('table', array(t('Applies to:'), ''), $rows);
   }
   $output .= drupal_render($form);
+  dpm($output);
   return $output;
 }
 
 /**
  * The node_limit settings form.
  */
-function node_limit_limit_form(&$form_state, $limit) {
-  if ($limit == FALSE) {
-    $limit = array();
+function node_limit_limit_form($form, &$form_state, $lid = 0) {
+  if (!$lid) {
+//    $limit = ..db_call_here    
+    $limit = array(
+      'lid' => 0,
+      'title' => '',
+      'weight' => 0,
+      'limit' => NODE_LIMIT_NO_LIMIT,
+    );
   }
   $form = array();
   $form['#tree'] = TRUE;
-  if ($limit['lid'] > 0) {
+  if ($lid && isset($limit['lid'])) {
     $form['lid'] = array(
       '#type' => 'hidden',
       '#value' => $limit['lid']
@@ -334,21 +370,21 @@ function node_limit_limit_form(&$form_state, $limit) {
   $form['info']['title'] = array(
     '#title' => t('Description'),
     '#type' => 'textfield',
-    '#default_value' => $limit['title'],
+    '#default_value' => isset($limit['title']) ? $limit['title'] : '',
     '#required' => TRUE,
     '#description' => t('The description for this Node Limit')
   );
   $form['info']['limit'] = array(
     '#title' => t('Limit'),
     '#type' => 'textfield',
-    '#default_value' => (isset($limit['limit']) ? $limit['limit'] : NODE_LIMIT_NO_LIMIT),
+    '#default_value' => isset($limit['limit']) ? $limit['limit'] : NODE_LIMIT_NO_LIMIT,
     '#size' => 10,
     '#required' => TRUE,
     '#description' => t('The number of nodes for this limit.  Must be an integer greater than 0 or %nolimit for no limit', array('%nolimit' => NODE_LIMIT_NO_LIMIT))
   );
   $form['info']['weight'] = array(
     '#type' => 'hidden',
-    '#value' => $limit['weight']
+    '#value' => isset($limit['weight']) ? $limit['weight'] : 0,
   );
 
   $elements = module_invoke_all('node_limit_element', $limit['lid']);
@@ -356,7 +392,7 @@ function node_limit_limit_form(&$form_state, $limit) {
   foreach ($elements as $module => $element) {
     $form['node_limit_elements'][$module]['applies'] = array(
       '#type' => 'checkbox',
-      '#title' => $element['#title'],
+      '#title' => check_plain($element['#title']),
       '#default_value' => isset($limit[$module])
     );
     $element['#title'] = '';
@@ -379,11 +415,11 @@ function node_limit_limit_form_validate($form_id, &$form_state) {
   if (!is_numeric($form_state['values']['info']['limit'])) {
     form_set_error('info][limit', t('Node limits must be an integer'));
   }
-  else if (intval($form_state['values']['info']['limit']) != floatval($form_state['values']['info']['limit'])) {
+  elseif (intval($form_state['values']['info']['limit']) != floatval($form_state['values']['info']['limit'])) {
     // Can't use is_int because is_int("2") == FALSE.
     form_set_error('info][limit', t('Node limits must be an integer'));
   }
-  else if (intval($form_state['values']['info']['limit']) < NODE_LIMIT_NO_LIMIT) {
+  elseif (intval($form_state['values']['info']['limit']) < NODE_LIMIT_NO_LIMIT) {
     form_set_error('info][limit', t('Node limits cannot be less that %nolimit', array('%nolimit' => NODE_LIMIT_NO_LIMIT)));
   }
 
@@ -395,12 +431,13 @@ function node_limit_limit_form_validate($form_id, &$form_state) {
     if ($element['applies'] === 1) {
       // They checked the box!
       $result = module_invoke($module, 'node_limit_element_validate', $element['element']);
+      //$result = module_
       if (is_array($result) && isset($result['error'])) {
-        $path = $module .'][element';
+        $path = $module . '][element';
         if (isset($result['element'])) {
-          $path .= ']['. $result['element'];
+          $path .= '][' . $result['element'];
         }
-        form_set_error('node_limit_elements]['. $path, $result['error']);
+        form_set_error('node_limit_elements][' . $path, $result['error']);
       }
     }
   }
@@ -432,7 +469,7 @@ function node_limit_limit_form_submit($form_id, &$form_state) {
   
   node_limit_save($limit);
 
-  $form_state['redirect'] = 'admin/user/node_limit';
+  $form_state['redirect'] = 'admin/structure/node_limit';
   drupal_set_message(t('Saved limit "%limit"', array('%limit' => $limit['title'])));
 }
 
@@ -441,7 +478,7 @@ function node_limit_limit_form_submit($form_id, &$form_state) {
  */
 function node_limit_delete_form(&$form_state, $limit) {
   if ($limit == FALSE) {
-    drupal_goto('admin/user/node_limit');
+    drupal_goto('admin/structure/node_limit');
   }
   $form = array(
     'lid' => array(
@@ -449,7 +486,7 @@ function node_limit_delete_form(&$form_state, $limit) {
       '#value' => $limit['lid']
     )
   );
-  return confirm_form($form, t('Are you sure you want to delete %name?', array('%name' => $limit['title'])), 'admin/user/node_limit');
+  return confirm_form($form, t('Are you sure you want to delete %name?', array('%name' => $limit['title'])), 'admin/structure/node_limit');
 }
 
 /**
@@ -458,7 +495,7 @@ function node_limit_delete_form(&$form_state, $limit) {
 function node_limit_delete_form_submit($form_id, &$form_state) {
   $lid = $form_state['values']['lid'];
   node_limit_delete($lid);
-  $form_state['redirect'] = 'admin/user/node_limit';
+  $form_state['redirect'] = 'admin/structure/node_limit';
 }
 
 /**
@@ -470,7 +507,7 @@ function node_limit_clone_limit($limit) {
   $limit['title'] = t('Clone of !title', array('!title' => $old_title));
   node_limit_save($limit);
   drupal_set_message(t('Cloned limit "%limit"', array('%limit' => $old_title)));
-  drupal_goto('admin/user/node_limit');
+  drupal_goto('admin/structure/node_limit');
 }
 
 /**
@@ -478,6 +515,7 @@ function node_limit_clone_limit($limit) {
  */
 function _node_limit_next_limit_id() {
   $next_lid = db_result(db_query("SELECT (MAX(lid)+1) AS lid FROM {node_limit}"));
+  
   return max($next_lid, 1);
 }
 
@@ -507,7 +545,10 @@ function node_limit_load($lid) {
 }
 
 function node_limit_delete($lid) {
-  db_query("DELETE FROM {node_limit} WHERE `lid`='%d'", $lid);
+  $num_deleted = db_delete('node_limit')
+    ->condition('lid', $lid)
+    ->execute();
+  
   module_invoke_all('node_limit_delete', $lid);
 }
 
@@ -517,8 +558,16 @@ function node_limit_delete($lid) {
 function node_limit_save($limit) {
   node_limit_delete($limit['lid']);
 
-  db_query("INSERT INTO {node_limit} VALUES('%d', '%d', '%s', '%d')", $limit['lid'], $limit['limit'], $limit['title'], $limit['weight']);
-  drupal_set_message(print_r($limit, true));
+  db_insert('node_limit')
+    ->fields(array(
+      'lid' => $limit['lid'],
+      'limit' => $limit('limit'),
+      'title' => $limit('title'),
+      'weight' => $limit('weight')
+      ))
+    ->execute();
+  
+  drupal_set_message(check_plain(print_r($limit, TRUE)));
   $modules = module_implements('node_limit_save');
   foreach ($modules as $module) {
     module_invoke($module, 'node_limit_save', $limit['lid'], isset($limit[$module]), $limit[$module]);
diff --git a/node_limit_interval/node_limit_interval.info b/node_limit_interval/node_limit_interval.info
index bd79cef..9fb8f66 100644
--- a/node_limit_interval/node_limit_interval.info
+++ b/node_limit_interval/node_limit_interval.info
@@ -2,4 +2,7 @@ name = Node Limit Interval
 description = Allows admins to apply a Node Limit to a time interval
 package = Node Limit
 dependencies[] = node_limit
-core = 6.x
+core = 7.x
+
+files[] = node_limit_interval.install
+files[] = node_limit_interval.module
\ No newline at end of file
diff --git a/node_limit_interval/node_limit_interval.install b/node_limit_interval/node_limit_interval.install
index fc92566..01acc48 100644
--- a/node_limit_interval/node_limit_interval.install
+++ b/node_limit_interval/node_limit_interval.install
@@ -1,18 +1,11 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Installation functions for module node_limit_interval.
  */
 
 /**
- * Implementation of hook_install().
- */
-function node_limit_interval_install() {
-  drupal_install_schema('node_limit_interval');
-}
-
-/**
  * Implementation of hook_schema().
  */
 function node_limit_interval_schema() {
@@ -39,12 +32,4 @@ function node_limit_interval_schema() {
   );
 
   return $schema;
-}
-
-
-/*
- * Implementation of hook_uninstall().
- */
-function node_limit_interval_uninstall() {
-  drupal_uninstall_schema('node_limit_interval');
-}
+}
\ No newline at end of file
diff --git a/node_limit_interval/node_limit_interval.module b/node_limit_interval/node_limit_interval.module
index 49c2e5b..a11cd2d 100644
--- a/node_limit_interval/node_limit_interval.module
+++ b/node_limit_interval/node_limit_interval.module
@@ -1,5 +1,5 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Module to restrict the number of nodes within a time interval.
@@ -43,7 +43,7 @@ function node_limit_interval_node_limit_sql($lid) {
   }
   return array(
     'where' => array(
-      sprintf('n.created + %d >= %d', $interval, time())
+      sprintf('n.created + %d >= %d', $interval, REQUEST_TIME)
     )
   );
 }
diff --git a/node_limit_og/node_limit_og.info b/node_limit_og/node_limit_og.info
index c691b1f..68fbda2 100644
--- a/node_limit_og/node_limit_og.info
+++ b/node_limit_og/node_limit_og.info
@@ -3,4 +3,7 @@ description = Allows admins to apply a Node Limit to an organic group
 package = Node Limit
 dependencies[] = node_limit
 dependencies[] = og
-core = 6.x
+core = 7.x
+
+files[] = node_limit_og.install
+files[] = node_limit_og.module
\ No newline at end of file
diff --git a/node_limit_og/node_limit_og.install b/node_limit_og/node_limit_og.install
index fa38901..fc081ff 100644
--- a/node_limit_og/node_limit_og.install
+++ b/node_limit_og/node_limit_og.install
@@ -1,18 +1,11 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Installation functions for module node_limit_og.
  */
 
 /**
- * Implementation of hook_install().
- */
-function node_limit_og_install() {
-  drupal_install_schema('node_limit_og');
-}
-
-/**
  * Implementation of hook_schema().
  */
 function node_limit_og_schema() {
@@ -34,12 +27,4 @@ function node_limit_og_schema() {
   );
 
   return $schema;
-}
-
-
-/*
- * Implementation of hook_uninstall().
- */
-function node_limit_og_uninstall() {
-  drupal_uninstall_schema('node_limit_og');
-}
+}
\ No newline at end of file
diff --git a/node_limit_og/node_limit_og.module b/node_limit_og/node_limit_og.module
index 44028dd..d2c07c4 100644
--- a/node_limit_og/node_limit_og.module
+++ b/node_limit_og/node_limit_og.module
@@ -1,10 +1,8 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Module to restrict the number of nodes within an organic group.
-
-/**
  * Implementation of hook_node_limit_applies_in_context().
  */
 function node_limit_og_node_limit_applies_in_context($lid, &$node, &$user) {
diff --git a/node_limit_role/node_limit_role.info b/node_limit_role/node_limit_role.info
index 3d34ce1..612c826 100644
--- a/node_limit_role/node_limit_role.info
+++ b/node_limit_role/node_limit_role.info
@@ -2,4 +2,7 @@ name = Node Limit Role
 description = Allows admins to apply a Node Limit to a role
 package = Node Limit
 dependencies[] = node_limit
-core = 6.x
+core = 7.x
+
+files[] = node_limit_role.install
+files[] = node_limit_role.module
diff --git a/node_limit_role/node_limit_role.install b/node_limit_role/node_limit_role.install
index 4d23df0..7e873a6 100644
--- a/node_limit_role/node_limit_role.install
+++ b/node_limit_role/node_limit_role.install
@@ -1,19 +1,11 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Installation functions for module node_limit_role.
  */
 
 /**
- * Implementation of hook_install().
- */
-function node_limit_role_install() {
-  db_query("DROP TABLE IF EXISTS {node_limit_role}");
-  drupal_install_schema('node_limit_role');
-}
-
-/**
  * Implementation of hook_schema().
  */
 function node_limit_role_schema() {
@@ -41,12 +33,4 @@ function node_limit_role_schema() {
   );
 
   return $schema;
-}
-
-
-/**
- * Implementation of hook_uninstall().
- */
-function node_limit_role_uninstall() {
-  drupal_uninstall_schema('node_limit_role');
-}
+}
\ No newline at end of file
diff --git a/node_limit_role/node_limit_role.module b/node_limit_role/node_limit_role.module
index 112f981..6e75450 100644
--- a/node_limit_role/node_limit_role.module
+++ b/node_limit_role/node_limit_role.module
@@ -1,5 +1,5 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Module to restrict the number of nodes by role.
@@ -36,7 +36,7 @@ function node_limit_role_node_limit_sql($lid) {
       )
     );
   }
-  else if ($limit['node_limit_role']['rid'] == DRUPAL_ANONYMOUS_RID) {
+  elseif ($limit['node_limit_role']['rid'] == DRUPAL_ANONYMOUS_RID) {
     return array(
       'where' => array(
         'n.uid = 0'
diff --git a/node_limit_type/node_limit_type.info b/node_limit_type/node_limit_type.info
index eade1f3..eb47900 100644
--- a/node_limit_type/node_limit_type.info
+++ b/node_limit_type/node_limit_type.info
@@ -2,4 +2,7 @@ name = Node Limit Type
 description = Allows admins to apply a Node Limit to a content type
 package = Node Limit
 dependencies[] = node_limit
-core = 6.x
+core = 7.x
+
+files[] = node_limit_type.install
+files[] = node_limit_type.module
diff --git a/node_limit_type/node_limit_type.install b/node_limit_type/node_limit_type.install
index 57d9b12..80686f5 100644
--- a/node_limit_type/node_limit_type.install
+++ b/node_limit_type/node_limit_type.install
@@ -1,18 +1,11 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Installation functions for module node_limit_type.
  */
 
 /**
- * Implementation of hook_install().
- */
-function node_limit_type_install() {
-  drupal_install_schema('node_limit_type');
-}
-
-/**
  * Implementation of hook_schema().
  */
 function node_limit_type_schema() {
@@ -41,12 +34,4 @@ function node_limit_type_schema() {
   );
 
   return $schema;
-}
-
-
-/*
- * Implementation of hook_uninstall().
- */
-function node_limit_type_uninstall() {
-  drupal_uninstall_schema('node_limit_type');
-}
+}
\ No newline at end of file
diff --git a/node_limit_type/node_limit_type.module b/node_limit_type/node_limit_type.module
index 25debae..c7209fd 100644
--- a/node_limit_type/node_limit_type.module
+++ b/node_limit_type/node_limit_type.module
@@ -1,5 +1,5 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Module to restrict the number of nodes by content type.
@@ -17,7 +17,7 @@ function node_limit_type_node_type($op, $info) {
       db_query($sql, $info->type);
       $num = db_affected_rows();
       if ($num > 0) {
-        drupal_set_message(t('Deleted !num limit rules.', array('!num' => $num)));
+        drupal_set_message(check_plain(t('Deleted !num limit rules.', array('!num' => $num))));
       }
       break;
   }
@@ -81,7 +81,7 @@ function node_limit_type_node_limit_element_validate($element) {
  * Implementation of hook_node_limit_save().
  */
 function node_limit_type_node_limit_save($lid, $applies, $element) {
-  drupal_set_message(print_r($element, true));
+  drupal_set_message(check_plain(print_r($element, TRUE)));
   if ($applies) {
     db_query("INSERT INTO {node_limit_type} VALUES('%d', '%s')", $lid, $element);
   }
@@ -111,7 +111,7 @@ function node_limit_type_node_limit_load($lid) {
  */
 function _node_limit_type_content_types() {
   $types = array();
-  $content_types = node_get_types('types');
+  $content_types = node_type_get_types();
   foreach ($content_types as $type) {
     $types[$type->type] = $type->name;
   }
diff --git a/node_limit_user/node_limit_user.info b/node_limit_user/node_limit_user.info
index d5a7ed3..50a42f9 100644
--- a/node_limit_user/node_limit_user.info
+++ b/node_limit_user/node_limit_user.info
@@ -2,4 +2,7 @@ name = Node Limit User
 description = Allows admins to apply a Node Limit to an individual user
 package = Node Limit
 dependencies[] = node_limit
-core = 6.x
+core = 7.x
+
+files[] = node_limit_user.install
+files[] = node_limit_user.module
diff --git a/node_limit_user/node_limit_user.install b/node_limit_user/node_limit_user.install
index ef6936d..d4eeed0 100644
--- a/node_limit_user/node_limit_user.install
+++ b/node_limit_user/node_limit_user.install
@@ -1,19 +1,11 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Installation functions for module node_limit_user.
  */
 
 /**
- * Implementation of hook_install().
- */
-function node_limit_user_install() {
-  db_query("DROP TABLE IF EXISTS {node_limit_user}");
-  drupal_install_schema('node_limit_user');
-}
-
-/**
  * Implementation of hook_schema().
  */
 function node_limit_user_schema() {
@@ -41,12 +33,4 @@ function node_limit_user_schema() {
   );
 
   return $schema;
-}
-
-
-/*
- * Implementation of hook_uninstall().
- */
-function node_limit_user_uninstall() {
-  drupal_uninstall_schema('node_limit_user');
-}
+}
\ No newline at end of file
diff --git a/node_limit_user/node_limit_user.module b/node_limit_user/node_limit_user.module
index 4195dd0..8e9ebfb 100644
--- a/node_limit_user/node_limit_user.module
+++ b/node_limit_user/node_limit_user.module
@@ -1,5 +1,5 @@
 <?php
-
+// $Id$
 /**
  * @file
  * Module to restrict the number of nodes by user.
@@ -10,6 +10,7 @@
  *
  * Delete all limit rules related to the deleted user.
  */
+/*
 function node_limit_user($op, &$edit, &$account, $category = NULL) {
   switch ($op) {
     case 'delete':
@@ -17,11 +18,27 @@ function node_limit_user($op, &$edit, &$account, $category = NULL) {
       db_query($sql, $account->uid);
       $num = db_affected_rows();
       if ($num > 0) {
-        drupal_set_message(t('Deleted !num limit rules.', array('!num' => $num)));
+        drupal_set_message(check_plain(t('Deleted !num limit rules.', array('!num' => $num))));
       }
       break;
   }
 }
+*/
+
+/**
+ * Implementation of hook_user_delete().
+ *
+ * Delete all limit rules related to the deleted user.
+ */
+function node_limit_user_delete($account)    
+  $num_deleted = db_delete('node_limit_user')
+    ->condition('uid', $account->uid)
+    ->execute();
+        
+  if ($num_deleted > 0) {
+    drupal_set_message(check_plain(t('Deleted !num limit rules.', array('!num' => $num_deleted))));
+  }  
+}
 
 /**
  * Implementation of hook_node_limit_applies_in_context().
@@ -76,14 +93,14 @@ function node_limit_user_node_limit_element_validate($element) {
    * User cannot be user:1
    * User must be in the {user} table
    */
-  $potential_user = user_load(array('name' => $element));
+  $potential_user = user_load_by_name($element);
   if ($potential_user->uid == 1) {
     //we cannot apply a limit to user:1
     return array(
       'error' => t('Node Limits cannot be applied to User #1')
     );
   }
-  else if ($potential_user === FALSE) {
+  elseif ($potential_user === FALSE) {
     //unknown user
     return array(
       'error' => t('Unknown user "!user"', array('!user' => $element))
@@ -99,7 +116,7 @@ function node_limit_user_node_limit_save($lid, $applies, $element) {
   if ($applies) {
     // $element contains the username of the user
     // user_load based on the name to get the uid
-    $user = user_load(array('name' => $element));
+    $user = user_load_by_name($element);
     $uid = $user->uid;
     db_query("INSERT INTO {node_limit_user} VALUES('%d', '%d')", $lid, $uid);
   }
