diff -rup ./uc_coupon/uc_coupon.install ./uc_coupon_new/uc_coupon.install
--- ./uc_coupon/uc_coupon.install	2009-01-23 05:43:49.000000000 -0700
+++ ./uc_coupon_new/uc_coupon.install	2009-04-19 22:51:11.000000000 -0600
@@ -18,23 +18,29 @@ function uc_coupon_install() {
         status int(1) NOT NULL default '1',
         valid_until int(11) default NULL,
         max_uses int(4) NOT NULL,
-        products varchar(50) NOT NULL,
         users text,
         roles int(1) NOT NULL,
         minimum_order decimal(6,2) NOT NULL default 0.00,
         PRIMARY KEY  (cid)
         )");
   
-    db_query("CREATE TABLE {uc_coupons_orders} (
-      cuid int(11) NOT NULL auto_increment,
-      cid int(11) NOT NULL,
-      oid int(11) NOT NULL default '0',
-      value decimal(10,2) NOT NULL default '0.00',
-      user varchar(50) NOT NULL default '0',
-      role varchar(40) NOT NULL default '0',
-      code varchar(40) NOT NULL default 'default_code',
-      PRIMARY KEY  (cuid)
-      )");
+      db_query("CREATE TABLE {uc_coupons_orders} (
+        cuid int(11) NOT NULL auto_increment,
+        cid int(11) NOT NULL,
+        oid int(11) NOT NULL default '0',
+        value decimal(10,2) NOT NULL default '0.00',
+        user varchar(50) NOT NULL default '0',
+        role varchar(40) NOT NULL default '0',
+        code varchar(40) NOT NULL default 'default_code',
+        PRIMARY KEY  (cuid)
+        )");
+      
+      db_query("CREATE TABLE {uc_coupons_products} (
+        coupon_product_id int(11) NOT NULL,
+        cid int(11) NOT NULL,
+        INDEX (cid)
+        )");
+      
     break;
   }
 }
@@ -42,6 +48,7 @@ function uc_coupon_install() {
 function uc_coupon_uninstall() {
   db_query("DROP TABLE {uc_coupons}");
   db_query("DROP TABLE {uc_coupons_orders}");
+  db_query("DROP TABLE {uc_coupons_products}");
   drupal_set_message("UC Coupon Successfully Uninstalled.");
 }
 
diff -rup ./uc_coupon/uc_coupon.module ./uc_coupon_new/uc_coupon.module
--- ./uc_coupon/uc_coupon.module	2009-04-07 18:38:36.000000000 -0600
+++ ./uc_coupon_new/uc_coupon.module	2009-04-19 23:15:18.000000000 -0600
@@ -136,7 +136,6 @@ function uc_coupon_display($view_type = 
 }
 
 
-
 /**
  *  Form builder for product attributes.
  *
@@ -155,6 +154,13 @@ function uc_coupon_add_form($action, $ci
       '#type' => 'value',
       '#value' => $value->cid,
     );
+    $query = db_query("SELECT coupon_product_id FROM {uc_coupons_products} WHERE cid = %d", $value->cid);
+    $products = array();
+    while ($product = db_fetch_object($query)){
+      $products[] = $product->coupon_product_id;
+    }
+    $value->products = $products;
+
   }
   else {
     $value->valid_until = time();
@@ -164,7 +170,7 @@ function uc_coupon_add_form($action, $ci
     $value->roles = 1;
     $value->products = '0';
   }
-
+  
   $value->valid_until = array('year' => format_date($value->valid_until, 'custom', 'Y'), 'month' => format_date($value->valid_until, 'custom', 'n'), 'day' => format_date($value->valid_until, 'custom', 'j'));
 
   $form['name'] = array(
@@ -241,7 +247,7 @@ function uc_coupon_add_form($action, $ci
     '#title' => t('Product'),
     '#description' => t('Choosing one or more products will make this coupon valid only for those products, and discounts will apply to each matching product.'),
     '#options' => uc_coupon_load_products(),
-    '#default_value' => explode(',', $value->products),
+    '#default_value' => $value->products,
     '#required' => TRUE,
   );
 
@@ -303,11 +309,16 @@ function uc_coupon_add_form_submit($form
     }
   }
 
-  $products = implode(',', $form['products']);
-
   // If the forms coupon id is not set then we try to insert a new coupon
   if (!isset($form['cid'])) {
-    if (db_query("INSERT INTO {uc_coupons} (name, code, value, type, status, valid_until, max_uses, products, users, roles, minimum_order) VALUES ('%s', '%s', '%f', '%s', '%d', '%d', '%d', '%s', '%s', '%s', %d)", $form['name'], $form['code'], $form['value'], $form['type'], $form['status'], $form['valid_until'], $form['max_uses'], $products, $users, $form['roles'], $form['minimum_order'])) {
+    if (db_query("INSERT INTO {uc_coupons} (name, code, value, type, status, valid_until, max_uses, users, roles, minimum_order) VALUES ('%s', '%s', '%f', '%s', '%d', '%d', '%d', '%s', '%s', %d)", $form['name'], $form['code'], $form['value'], $form['type'], $form['status'], $form['valid_until'], $form['max_uses'], $products, $users, $form['roles'], $form['minimum_order'])) {
+            
+      $this_cid = db_result(db_query("SELECT cid FROM {uc_coupons} WHERE code = '%s'", $form['code']));
+      
+      foreach ($form['products'] as $product_id) {
+        db_query("INSERT INTO {uc_coupons_products} (coupon_product_id, cid) VALUES (%d, %d)", $product_id, $this_cid);
+      }
+      
       $message = "New coupon {$form['name']} added succesfully";
     }
     else {
@@ -316,7 +327,14 @@ function uc_coupon_add_form_submit($form
   }
   else {
     // Otherwise we try to update the coupon with matching coupon id
-    if (db_query("UPDATE {uc_coupons} SET name = '%s', code = '%s', value = %f, type = '%s', status = %d, valid_until = %d, max_uses = %d, products = '%s', users = '%s', roles = '%s', minimum_order = %d WHERE cid = %d", $form['name'], $form['code'], $form['value'], $form['type'], $form['status'], $form['valid_until'], $form['max_uses'], $products, $users, $form['roles'], $form['minimum_order'], $form['cid'])) {
+    if (db_query("UPDATE {uc_coupons} SET name = '%s', code = '%s', value = %f, type = '%s', status = %d, valid_until = %d, max_uses = %d, users = '%s', roles = '%s', minimum_order = %d WHERE cid = %d", $form['name'], $form['code'], $form['value'], $form['type'], $form['status'], $form['valid_until'], $form['max_uses'], $users, $form['roles'], $form['minimum_order'], $form['cid'])) {
+    
+      db_query("DELETE FROM {uc_coupons_products} WHERE cid = %d", $form['cid']);
+      
+      foreach ($form['products'] as $product_id) {
+        db_query("INSERT INTO {uc_coupons_products} (coupon_product_id, cid) VALUES (%d, %d)", $product_id, $form['cid']);
+      }
+
       $message = "Coupon updated succssfully";
     }
     else {
@@ -414,6 +432,7 @@ function uc_coupon_delete_confirm($cid) 
 function uc_coupon_delete_confirm_submit($form_id, $form) {
   $coupon_id = $form['cid'];
   if (db_query("DELETE FROM {uc_coupons} WHERE cid = %d", $coupon_id)) {
+    db_query("DELETE FROM {uc_coupons} WHERE cid = %d", $coupon_id);
     drupal_set_message("Coupon deleted successfully");
   }
   else {
@@ -441,12 +460,11 @@ function uc_coupon_validate($code) {
   if ($coupon_data) {
     $coupon_result->valid = FALSE;
 
-    if ($coupon_data->products) {
+    if ($coupons_products = db_fetch_array(db_query("SELECT coupon_product_id FROM {uc_coupons_products} WHERE cid = %d", $coupon_data->cid))) {
       // Product coupons apply to the subtotal and quantity of matching products.
-      $coupon_products = explode(',', $coupon_data->products);
       foreach (uc_cart_get_contents() as $item) {
         $cart_total += $item->price * $item->qty;
-        if (in_array($item->nid, $coupon_products)) {
+        if (in_array($item->nid, $coupons_products)) {
           $applicable_total += $item->price * $item->qty;
           $applicable_qty += $item->qty;
         }
