diff --git a/uc_userpoints_product.module b/uc_userpoints_product.module
index f9d398c..f26d642 100644
--- a/uc_userpoints_product.module
+++ b/uc_userpoints_product.module
@@ -60,24 +60,21 @@ function uc_userpoints_product_product_feature() {
 /**
 * Build the userpoints feature form
 */
-function uc_userpoints_product_feature_form($node, $feature) {
+function uc_userpoints_product_feature_form($form_state, $node, $feature) {
 	$points = 0;
+        $tid = NULL;
 
-	$nid = arg(1);
-
-	$res = db_query("SELECT * FROM {uc_userpoints_products} ucup, {uc_product_features} ucpf WHERE ucup.pfid = ucpf.pfid AND ucup.nid = %d",$nid);
+        if($feature) {
+	$res = db_query("SELECT * FROM {uc_userpoints_products} ucup, {uc_product_features} ucpf WHERE ucup.pfid = ucpf.pfid AND ucup.pfid = %d",$feature['pfid']);
 	while ($pf = db_fetch_object($res)) {
 	  $points = $pf->points;
 	  $tid = $pf->tid;
 	}
+        }
 	
 	$category_options = userpoints_get_categories();
 	$category_options[-1] = t('Default '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'Points').' Product Category');
 
-	$form['nid'] = array(
-		'#type' => 'value',
-		'#value' => $nid,
-	);
 	$form['points'] = array(
 		'#type' => 'textfield',
 		'#title' => t('Number of '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points')),
@@ -121,15 +118,16 @@ function uc_userpoints_product_feature_form_submit($form, &$form_state) {
 		'points' => $form_state['values']['points'],
 		'tid' => $form_state['values']['tid'],
 		'fid' => 'userpoints',
-		'description' => 'Product is now worth '.$form_state['values']['points'].' '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').', assigned to the \''. $term_name .'\' category',
+		'description' => t('Product is worth !num_points !category !points', array('!num_points' => $form_state['values']['points'], '!points' => variable_get(USERPOINTS_TRANS_LCPOINTS, 'points'), '!category' => $term_name)),
+
 	);
-	
+
 	$ret = uc_product_feature_save($data);
-	if (empty($data['pfid'])) {
-		$pf = db_fetch_object(db_query("select pfid from {uc_product_features} where nid = %d and fid = '%s'",$data['nid'],$data['fid']));
-		$data['pfid'] = $pf->pfid;
 
-		db_query("INSERT INTO {uc_userpoints_products} (pfid,nid,points,tid) VALUES (%d,%d,%d,%d)",$data['pfid'],$data['nid'],$data['points'],$data['tid']);
+	if (!$data['pfid']) {
+	  $data['pfid'] = db_result(db_query("SELECT MAX(pfid) FROM {uc_product_features} WHERE nid = %d AND fid = '%s'", $data['nid'], $data['fid']));
+    drupal_write_record('uc_userpoints_products', $data);
+
 	}
 	else {
 		db_query("UPDATE {uc_userpoints_products} SET points = %d, tid= %d WHERE nid = %d AND pfid = %d",$data['points'],$data['tid'],$data['nid'],$data['pfid']);
@@ -160,51 +158,32 @@ function uc_userpoints_product_feature_delete($feature) {
  * Implementation of hook_order();
  */
 function uc_userpoints_product_order($op, $order, $status) {
-
-	switch ($op) {
-		case 'update':
-		// We might want to add the "Order Status" to the Userpoints Ubercart options...
-			if (($status == 'completed' && $order->uid > 0) && ($order_user = user_load(array('uid' => $order->uid))) !== FALSE) {
-				$totalPoints = 0; // this will be the total order points
-				foreach ($order->products as $product) {
-					$productPoints = 0; // This will be the product points * quantity
-					$points = db_result(db_query("SELECT sum(points) FROM {uc_userpoints_products} WHERE nid = %d", $product->nid));
-					$tid = db_result(db_query("SELECT tid FROM {uc_userpoints_products} WHERE nid = %d", $product->nid));
-					if ($points > 0) {
-						//drupal_set_message($product->title.' has '.$points.' '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').' attached');
-						$productPoints = ($product->qty * $points); // Make sure we account for multiple qty of the Points product
-					}
-					if (($tid == '') || ($tid == '-1')) {
-			            $tid = variable_get(USERPOINTS_PRODUCT_CATEGORY, 0);
-			        }
-			    
-			    $params = array (
-				    'tid' => $tid,
-				    'uid' => $order->uid,
-				    'points' => $productPoints,
-				    'operation' => 'add',
-				    'description' => t('A user purchased !product containing !amount points.', array('!product' => l($product->title, 'node/' . $product->nid), '!amount' => $productPoints)),
-				    'entity_id' => $order->oid,
-				    'entity_type' => 'Ubercart Transaction',
-				    'moderate' => variable_get(USERPOINTS_PRODUCT_MODERATE, 0),
-			    );
-			
-				$totalPoints += $productPoints;
-				
-		        if ($productPoints > 0) {
-					userpoints_userpointsapi($params);
-					uc_order_comment_save($order->order_id, 0, t('User bought '.$productPoints.' points with product: '. $product->title .'!'), 'admin'); //Order comment per product points
-				}
-				}
-				if ($totalPoints > 0) {
-				  uc_order_comment_save($order->order_id, 0, t('User bought a total of '.$totalPoints.' points on this order!'), 'admin'); //Order comment on total points
-				}
-		    }
-		    
-	break;
-	}
+  switch($op) {
+    case 'update':
+      if (($status == 'completed' && $order->uid > 0) && ($order_user = user_load(array('uid' => $order->uid))) !== FALSE) {
+        foreach($order->products as $product) {
+          $result = db_query("SELECT * FROM {uc_userpoints_products} WHERE nid = %d", $product->nid);
+          while($record = db_fetch_array($result)) {
+            $replacements = userpoints_translation() + array('!product' => l($product->title, 'node/' . $product->nid), '!order' => $order->oid);
+            $message = t('!Points purchased through !product as part of order !order', $replacements);
+            $params = array(
+              'tid' => ($record['tid']) ? $record['tid'] : variable_get(USERPOINTS_PRODUCT_CATEGORY, 0),
+              'points' => $record['points'],
+              'uid' => $order->uid,
+              'entity_id' => $order->oid,
+              'entity_type' => 'Order',
+              'moderate' => variable_get(USERPOINTS_PRODUCT_MODERATE, 0),
+              'description' => $message
+            );
+            userpoints_userpointsapi($params);
+          }
+        }
+      }
+  }
 }
 
+
+
 /**
 * Check and make sure the user isn't trying to buy points with points.
 *  @todo: Make this configurable?
