--- userpoints_retroactive.module.orig	2007-04-13 07:02:48.000000000 -0700
+++ userpoints_retroactive.module	2007-09-11 19:50:07.000000000 -0700
@@ -64,7 +64,15 @@ function userpoints_retroactive_do() {
 function userpoints_retroactive_initalize() {
   $u_result = db_query('SELECT uid FROM {users} WHERE uid > 0');
   while ($user = db_fetch_object($u_result)) {
-    db_query('INSERT INTO {userpoints} (uid, last_update, points, max_points) VALUES (%d, %d, 0, 0)', $user->uid, time());
+	  
+	// To prevent the necessity of running 'reset' before 'retroactive'
+	$haspoints = db_fetch_array(db_query('SELECT * FROM {userpoints} WHERE uid = %d LIMIT 1', $user->uid));
+	if($haspoints){
+		db_query('UPDATE {userpoints} SET last_update = %d, points = 0 WHERE uid = %d', time(), $user->uid);
+	}else{
+		db_query('INSERT INTO {userpoints} (uid, last_update, points, max_points) VALUES (%d, %d, 0, 0)', $user->uid, time());
+	}
+	  
   }
 }
 
@@ -72,7 +80,7 @@ function userpoints_retroactive_nodes() 
 	$n_result = db_query("SELECT uid, type, COUNT(uid) AS val FROM {node} WHERE uid > 0 GROUP BY uid, type");
 	while($node = db_fetch_object($n_result)) {
     $weight = variable_get(USERPOINTS_POST . $node->type, 0);
-		db_query('UPDATE {userpoints} SET points = points + %d WHERE uid = %d', ($node->val * $weight), $node->uid);
+		db_query('UPDATE {userpoints} SET points = points + %d, max_points = points  WHERE uid = %d', ($node->val * $weight), $node->uid);
 	}
 }
 
@@ -80,6 +88,6 @@ function userpoints_retroactive_comments
   $weight = variable_get(USERPOINTS_POST_COMMENT, 0);
 	$c_result = db_query('SELECT uid, COUNT(uid) AS val FROM {comments} WHERE uid > 0 GROUP BY uid');
 	while($comment = db_fetch_object($c_result)) {
-		db_query('UPDATE {userpoints} SET points = points + %d WHERE uid = %d', ($comment->val * $weight), $comment->uid);
+		db_query('UPDATE {userpoints} SET points = points + %d, max_points = points WHERE uid = %d', ($comment->val * $weight), $comment->uid);
 	}
 }
