--- uc_upsell_core.inc	2009-06-20 23:03:09.000000000 -0700
+++ uc_upsell_core.inc.cartnids	2009-06-20 23:03:29.000000000 -0700
@@ -58,12 +58,10 @@ function uc_upsell_resolve_associates(&$
     // Start list with nids related to the product node
     $related = uc_upsell_get_associate_nids(array(arg(1)), intval($vars['max']), array(arg(1)), $vars);
 
-    // drupal_set_message('from db '.print_r($related, true));
-
     // Get/add nids related to the cart
     if ($config['block']['product']['use_cart'] == TRUE) {
+      $cart_nids = get_cart_nids();
       $related = array_merge($related, uc_upsell_get_associate_nids($cart_nids, $vars['max'] - count($related), arg(1)), $vars);
-      //drupal_set_message('including cart '.print_r($related, true));
     }
 
     // If related is not empty...
@@ -167,13 +165,11 @@ function uc_upsell_get_associate_nids($s
 //drupal_set_message('seeking '.count($sought));
       $filtered = array_diff($related, $sought);
 //drupal_set_message('difference of ' .count($filtered));
-      $related = array_unique(array_merge((array)$ary, (array)$related));
+      $related = array_unique(array_merge((array)$filtered, (array)$related));
 //drupal_set_message('found '.count($related));
     }
   }
 
-  $cart_nids = get_cart_nids();
-
   // If count of related nodes doesn't meet threshold and can include random nodes, add them.
   if (count($related) < $vars['max'] && $vars['use_random']) {
 
