diff -r b50768911dd6 -r 1dba6a7eae1d httproot/sites/all/modules/userpoints/userpoints.install
--- a/httproot/sites/all/modules/userpoints/userpoints.install	Wed Jan 20 14:37:51 2010 -0500
+++ b/httproot/sites/all/modules/userpoints/userpoints.install	Wed Jan 20 16:27:19 2010 -0500
@@ -271,3 +271,22 @@
   $ret[] = update_sql("UPDATE {userpoints_txn} SET changed = time_stamp");
   return $ret;
 }
+
+function userpoints_update_6012() {
+
+  $ret = array();
+
+  // Fix inconsistencies between userpoints and userpoints_txn tables
+  $combinations_res = db_query("SELECT DISTINCT uid, tid FROM {userpoints_txn}");
+  while( $txn = db_fetch_array($combinations_res)) {
+
+    $params = array();
+    $params['status'] = 0;
+    $params['expired'] = 0;
+    $params['uid'] = $txn['uid'];
+    $params['tid'] = $txn['tid'];
+    _userpoints_update_cache($params);
+  }
+
+  return $ret;
+}
\ No newline at end of file
diff -r b50768911dd6 -r 1dba6a7eae1d httproot/sites/all/modules/userpoints/userpoints.module
--- a/httproot/sites/all/modules/userpoints/userpoints.module	Wed Jan 20 14:37:51 2010 -0500
+++ b/httproot/sites/all/modules/userpoints/userpoints.module	Wed Jan 20 16:27:19 2010 -0500
@@ -766,18 +766,12 @@
     $params += $txn;
     //Update existing transaction record for key txn_id
     $ret = drupal_write_record('userpoints_txn', $params, array('txn_id'));
-    //Only update if the record has been successfully updated
-    if ($ret != FALSE) {
     _userpoints_update_cache($params);
   }
-  }
   else {
     //Create new transaction record
     $ret = drupal_write_record('userpoints_txn', $params);
-    //don't cache entry if it's pending
-    if ($params['status'] != TRUE && $ret != FALSE) {
-      _userpoints_update_cache($params);
-    }
+    _userpoints_update_cache($params);
   }
   return TRUE;
 } //function userpoints_transaction
@@ -791,18 +785,26 @@
       return false;
   }
   if (!isset($params['tid'])) {
-    $params['tid'] = NULL;
+    $params['tid'] = 0;
   }
 
-  // Calculate the current points based upon the tid
-  $current_points = (int)$params['points'] + userpoints_get_current_points($params['uid'], $params['tid']);
-  //Grab the user's maximum points to preserve it
-  $max_points = db_result(db_query('SELECT max_points FROM {userpoints} WHERE uid = %d AND tid = %d',
-    $params['uid'], $params['tid']));
-  if ($params['points'] > 0) {
-    //points are greater than zero, update their max_points
-    $max_points = (int)$params['points'] + (int)$max_points;
-  }
+  $tnx_data = db_fetch_array(db_query("
+      SELECT SUM(p.points) AS current_points, mp.max_points
+      FROM {userpoints_txn} AS p
+      INNER JOIN ( SELECT ut.uid, ut.tid, SUM(ut.points) AS max_points
+                   FROM {userpoints_txn} AS ut
+                   WHERE ut.status = 0
+                         AND ut.points > 0
+                         AND ut.uid = %d
+                         AND ut.tid = %d
+                 ) AS mp
+            ON (mp.uid = p.uid AND mp.tid = p.tid)",
+     $params['uid'],
+     $params['tid']
+  ));
+
+  $current_points = (int)$tnx_data['current_points'];
+  $max_points = (int)$txn_data['max_points'];
 
   // insert or update the userpoints caching table with the user's current points
   if (_userpoints_user_exists($params['uid'], $params['tid'])) {
