diff --git a/userpoints_reset/userpoints_reset.info b/userpoints_reset/userpoints_reset.info
old mode 100755
new mode 100644
diff --git a/userpoints_retroactive/userpoints_retroactive.info b/userpoints_retroactive/userpoints_retroactive.info
old mode 100755
new mode 100644
index 5206778..63e0da8
--- a/userpoints_retroactive/userpoints_retroactive.info
+++ b/userpoints_retroactive/userpoints_retroactive.info
@@ -1,6 +1,6 @@
 name = Userpoints Retroactive
 description = Calculate userpoints for nodes and comments created so far.
 package = Userpoints
-core = 6.x
+core = 7.x
 dependencies[] = userpoints
-dependencies[] = not_compatible_with_d7
+dependencies[] = userpoints_nc
diff --git a/userpoints_retroactive/userpoints_retroactive.module b/userpoints_retroactive/userpoints_retroactive.module
index d24fb4c..4926f20 100644
--- a/userpoints_retroactive/userpoints_retroactive.module
+++ b/userpoints_retroactive/userpoints_retroactive.module
@@ -2,42 +2,71 @@
 
 // Based on a script by Miguel Figueiredo <elmig@debianpt.org>, 2006
 
-define(USERPOINTS_PERM_RETROACTIVE, 'retroactive userpoints');
+define('USERPOINTS_POST', 'userpoints_post_');
 
 function userpoints_retroactive_help($path, $arg) {
   switch ($path) {
-    case 'admin/settings/userpoints/retroactive':
-      $output = t('Award users !points for nodes, comments and votes they created in the past.', userpoints_translation());
-      break;
+    case 'admin/config/people/userpoints/retroactive':
+      return t('Award users !points for nodes, comments and votes they created in the past.', userpoints_translation());
   }
-  return $output;
 }
 
 function userpoints_retroactive_menu() {
-  $items['admin/settings/userpoints/retroactive'] = array(
-    'page callback'    => 'userpoints_retroactive_page',
+  $items['admin/config/people/userpoints/retroactive'] = array(
     'title'            => t('Retroactive'),
-    'access arguments' => array(USERPOINTS_PERM_RETROACTIVE),
-    'type'             => MENU_NORMAL_ITEM
+    'page callback'    => 'drupal_get_form',
+    'page arguments'   => array('userpoints_retroactive_form'),
+    'access arguments' => array('retroactive userpoints'),
+    'type'             => MENU_LOCAL_TASK,
   );
 
   return $items;
 }
 
-function userpoints_retroactive_perm() {
-  return array (USERPOINTS_PERM_RETROACTIVE);
-}
-
-function userpoints_retroactive_page() {
-  return drupal_get_form('userpoints_retroactive', $form);
+function userpoints_retroactive_permission() {
+  return array(
+    'retroactive userpoints' => array(
+      'title' => t('Administer retroactive userpoints module'),
+    ),
+  );
 }
 
-function userpoints_retroactive() {
+function userpoints_retroactive_form($form, $form_state) {
   $form = array();
+
+  $form['retrocactive_node_comment'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Node and comment'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+  
+  $form['retrocactive_node_comment']['retrocactive_node_comment_enable'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enabled.'),
+    '#default_value' => FALSE,
+  );
+  
+  $types = node_type_get_types();
+  foreach ($types as $type) {
+    $node_type_info[] = array(
+      $type->name,
+      // points, category, comment_points, comment_category.
+      userpoints_nc_get_setting('points', $type->type),
+      userpoints_nc_get_setting('category', $type->type),
+      userpoints_nc_get_setting('comment_points', $type->type),
+      userpoints_nc_get_setting('comment_category', $type->type),
+    );
+  }
+  $form['retrocactive_node_comment']['retrocactive_node_comment_info'] = array(
+    '#type' => 'markup',
+    '#markup' => theme('table', array('rows'=>$node_type_info, 'header'=>array('Type', 'Points', 'Category', 'Comment points', 'Comment category'))),
+    '#prefix' => '<div>Below the settings info from <b>User points Nodes and Comments</b> module.</div>',
+  );
   
   $form['confirm'] = array(
     '#type'          => 'textfield',
-    '#title'         => t('Award users !points for nodes, comments and votes they created in the past. Enter YES to reset', userpoints_translation()),
+    '#title'         => t('Please enable which one you want to award users !points, and enter YES to reset.', userpoints_translation()),
     '#default_value' => t('NO'),
     '#size'          => 3,
     '#maxlength'     => 3,
@@ -51,19 +80,41 @@ function userpoints_retroactive() {
   return $form;
 }
 
-function userpoints_retroactive_submit($form, &$form_state) {
+function userpoints_retroactive_form_submit($form, &$form_state) {
   if ($form_state['values']['confirm'] == t('YES')) {
-    userpoints_retroactive_do();
+    if ($form_state['values']['retrocactive_node_comment_enable'] == 1) {
+      $options['node'] = 1;
+      $options['comment'] = 1;
+    }
+    userpoints_retroactive_do($options);
     drupal_set_message(t('Retroactive !points awarded.', userpoints_translation()));
-    drupal_goto('admin/settings/userpoints');
+    drupal_goto('admin/config/people/userpoints');
   }
 }
 
-function userpoints_retroactive_do() {
+function userpoints_retroactive_do($options) {
   set_time_limit(240);
   timer_start('up_retro');
-  $num = userpoints_retroactive_nodes();
-  $num += userpoints_retroactive_comments();
+  
+  $types = node_type_get_types();
+  foreach ($types as $type) {
+    $node_type_point_info[$type->type] = array(
+      // points, category, comment_points, comment_category.
+      'points' => userpoints_nc_get_setting('points', $type->type),
+      'category' => userpoints_nc_get_setting('category', $type->type),
+      'comment_points' => userpoints_nc_get_setting('comment_points', $type->type),
+      'comment_category' => userpoints_nc_get_setting('comment_category', $type->type),
+    );
+  }
+  
+  if(isset($options['node']) && $options['node'] == 1) {
+    $num = userpoints_retroactive_nodes($node_type_point_info);
+  }
+  
+  if(isset($options['comment']) && $options['comment'] == 1){
+    $num += userpoints_retroactive_comments($node_type_point_info);
+  }
+  
   if (module_exists('votingapi')) {
     $num += userpoints_retroactive_votingapi();
   }
@@ -72,16 +123,26 @@ function userpoints_retroactive_do() {
   watchdog('userpoints', t('Userpoints retroactive processed %count items in %ms milliseconds'), array('%ms' => $ms, '%count' => $num));
 }
 
-function userpoints_retroactive_nodes() {
+function userpoints_retroactive_nodes($node_type_point_info) {
   $num = 0;
-  $result = db_query("SELECT uid, type, COUNT(uid) AS val FROM {node} WHERE status = 1 AND uid > 0 GROUP BY uid, type");
-  while($node = db_fetch_object($result)) {
-    $weight = variable_get(USERPOINTS_POST . $node->type, 0);
-    $tid = variable_get(USERPOINTS_POST . $node->type . '_category', 0);
+  $query = db_select('node', 'n');
+  $query->addField('n', 'uid');
+  $query->addField('n', 'type');
+  $query->condition('status', 1, '=');
+  $query->condition('uid', 0, '>');
+  $query->groupBy('uid');
+  $query->groupBy('type');
+  $query->addExpression('COUNT(uid)', 'val');
+  $result = $query->execute();
+  // $result = db_query("SELECT uid, type, COUNT(uid) AS val FROM {node} WHERE status = 1 AND uid > 0 GROUP BY uid, type");
+  foreach ($result as $item) {
+    $points = $node_type_point_info[$item->type]['points'];
+    $tid = $node_type_point_info[$item->type]['category'];
+    
     $params = array(
-      'uid'       => $node->uid,
+      'uid'       => $item->uid,
       'tid'       => $tid,
-      'points'    => ($node->val * $weight),
+      'points'    => ($item->val * $points),
       'moderate'  => FALSE,
       'display'   => FALSE,
       'operation' => t('Retroactive node'),
@@ -92,16 +153,31 @@ function userpoints_retroactive_nodes() {
   return $num;
 }
 
-function userpoints_retroactive_comments() {
+function userpoints_retroactive_comments($node_type_point_info) {
   $num = 0;
-  $weight = variable_get(USERPOINTS_POST_COMMENT, 0);
-  $tid = variable_get(USERPOINTS_POST_COMMENT . '_category', 0);
-  $result = db_query('SELECT uid, COUNT(uid) AS val FROM {comments} WHERE status = 0 AND uid > 0 GROUP BY uid');
-  while($comment = db_fetch_object($result)) {
+  $query = db_select('comment', 'c');
+  $query->addField('c', 'uid');
+  $query->addField('n', 'type');
+  $query->leftJoin('node', 'n', 'n.nid = c.nid');
+  $query->condition('c.status', 1, '=');
+  $query->condition('c.uid', 0, '>');
+  $query->groupBy('c.uid');
+  $query->groupBy('n.type');
+  $query->addExpression('COUNT(c.uid)', 'val');
+  $result = $query->execute();
+
+  // SELECT c.uid, n.type, COUNT(c.uid) AS val FROM `comment` c
+  // LEFT JOIN `node` n on n.nid = c.nid
+  // WHERE c.status = 1 AND c.uid > 0 
+  // GROUP BY c.uid, n.type
+  foreach ($result as $item) {
+    $points = $node_type_point_info[$item->type]['comment_points'];
+    $tid = $node_type_point_info[$item->type]['comment_category'];
+
     $params = array(
-      'uid'       => $comment->uid,
+      'uid'       => $item->uid,
       'tid'       => $tid,
-      'points'    => ($comment->val * $weight),
+      'points'    => ($item->val * $points),
       'moderate'  => FALSE,
       'display'   => FALSE,
       'operation' => t('Retroactive comment'),
