diff -ru mailchimp.OLD/mailchimp.module mailchimp/mailchimp.module
--- mailchimp.OLD/mailchimp.module	2010-07-13 03:16:03.000000000 +1000
+++ mailchimp/mailchimp.module	2010-08-12 15:12:01.000000000 +1000
@@ -170,37 +170,43 @@
         '#attributes'     => array('class' => 'mailchimp-newsletter-checkbox-' . $list->id)
     );
 
-    // present interest groups
+    // present groups
     if (variable_get('mailchimp_interest_groups_user_forms', FALSE)) {
-      if ($intgroup = $q->listInterestGroups($list->id)) {
-        switch ($intgroup['form_field']) {
-          case 'radio':
-            $field_type = 'radios';
-            break;
-          case 'checkbox':
-            $field_type = 'checkboxes';
-            break;
-          default:
-            $field_type = $intgroup['form_field'];
-        }
-        $options = array();
-        foreach ((array)$intgroup['groups'] as $group) {
-          $options[$group] = $group;
-        }
-        $form['wrapper'. $list->id]['mailchimp_list_'. $list->id .'_INTERESTS'] = array(
-          '#type'           => $field_type,
-          '#title'          => $intgroup['name'],
-          '#options'        => $options,
-          '#default_value'  => $is_subscribed ? explode(",", str_replace(', ', ',', $memberinfo['merges']['INTERESTS'])) : array(),
-          '#attributes'     => array('class' => 'mailchimp-newsletter-interests-' . $list->id)
+      if ($intgroups = $q->listinterestgroupings($list->id)) {
+        $form['wrapper'. $list->id]['mailchimp_list_'. $list->id .'_GROUPINGS'] = array(
+          '#type' => 'hidden',
+          '#value' => $intgroups,
         );
+        foreach ($intgroups as $key => $intgroup) {
+          switch ($intgroup['form_field']) {
+            case 'radio':
+              $field_type = 'radios';
+              break;
+            case 'checkbox':
+              $field_type = 'checkboxes';
+              break;
+            default:
+              $field_type = $intgroup['form_field'];
+          }
+          $options = array();
+          foreach ((array)$intgroup['groups'] as $group) {
+            $options[$group['name']] = $group['name'];
+          }
+          $form['wrapper'. $list->id]['mailchimp_list_'. $list->id .'_GROUPINGS_'. $intgroup['id']] = array(
+            '#type'           => $field_type,
+            '#title'          => $intgroup['name'],
+            '#options'        => $options,
+            '#default_value'  => $is_subscribed ? explode(",", str_replace(', ', ',', $memberinfo['merges']['GROUPINGS'][$key]['groups'])) : array(),
+            '#attributes'     => array('class' => 'mailchimp-newsletter-group-' . $list->id)
+          );
+        }
         drupal_add_js('$(document).ready(function(){
           if($(".mailchimp-newsletter-checkbox-'. $list->id .'").attr("checked")){
-            $(".mailchimp-newsletter-interests-'. $list->id .'").parent(".form-item").show();
+            $(".mailchimp-newsletter-group-'. $list->id .'").parent(".form-item").show();
           } else {
-            $(".mailchimp-newsletter-interests-'. $list->id .'").parent(".form-item").hide();
+            $(".mailchimp-newsletter-group-'. $list->id .'").parent(".form-item").hide();
           }
-          $(".mailchimp-newsletter-checkbox-'. $list->id .'").click(function(){ $(".mailchimp-newsletter-interests-'. $list->id .'").parent(".form-item").toggle("slow");});
+          $(".mailchimp-newsletter-checkbox-'. $list->id .'").click(function(){ $(".mailchimp-newsletter-group-'. $list->id .'").parent(".form-item").toggle("slow");});
         });', 'inline');
       }
     }
@@ -258,8 +264,13 @@
           }
 
           // include interest groups
-          if (!empty($form_state['values']['mailchimp_list_'. $list->id .'_INTERESTS'])){
-            $merge_vars['INTERESTS'] = implode(',', array_filter($form_state['values']['mailchimp_list_'. $list->id .'_INTERESTS']));
+          $merge_vars['GROUPINGS'] = array();
+          foreach ($form_state['values']['mailchimp_list_'. $list->id .'_GROUPINGS'] as $group) {
+            $merge_vars['GROUPINGS'][] = array(
+              'id' => $group['id'],
+              'name' => $group['name'],
+              'groups' => implode(',', array_filter($form_state['values']['mailchimp_list_'. $list->id .'_GROUPINGS_'. $group['id']])),
+            );
           }
           
           $ret = _mailchimp_subscribe_user($list, $account->mail, $merge_vars, TRUE, $q);
@@ -463,9 +474,19 @@
   foreach ($lists as $list) {
     if (!empty($list['EMAIL'])) {
       $success = FALSE;
-      // filter our interest groups and return in an comma delimited string
-      if (!empty($values['INTERESTS'])) {
-        $list['INTERESTS'] = implode(',', array_filter($list['INTERESTS']));
+      // filter our groups and return in an comma delimited string
+      // get all the existing groups
+      $groups = $list['GROUPINGS'];
+      // set to empty array, to pass as merg_vars
+      $list['GROUPINGS'] = array();
+      foreach ($groups as $group) {
+        $list['GROUPINGS'][] = array(
+          'id' => $group['id'],
+          'name' => $group['name'],
+          'groups' => implode(',', array_filter($list['GROUPINGS_'. $group['id']])),
+        );
+        // Unset individual groups from $list as we do not want to pass them to mailchimp
+        unset($list['GROUPINGS_'. $group['id']]);
       }
 
       $success = _mailchimp_subscribe_user($list['list'], $list['EMAIL'], $list, TRUE);
@@ -540,26 +561,33 @@
     $form[$mergevar['tag']] = _mailchimp_insert_drupal_form_tag($mergevar);
   }
 
-  // present interest groups
-  if ($intgroup = $q->listInterestGroups($list->id)) {
-    switch ($intgroup['form_field']) {
-      case 'radio':
-        $field_type = 'radios';
-        break;
-      case 'checkbox':
-        $field_type = 'checkboxes';
-        break;
-      default:
-        $field_type = $intgroup['form_field'];
-    }
-    foreach ((array)$intgroup['groups'] as $group) {
-      $options[$group] = $group;
-    }
-    $form['INTERESTS'] = array(
-      '#type'           => $field_type,
-      '#title'          => $intgroup['name'],
-      '#options'        => $options
+  // present groups
+  if ($intgroups = $q->listinterestgroupings($list->id)) {
+    $form['GROUPINGS'] = array(
+      '#type' => 'hidden',
+      '#value' => $intgroups,
     );
+    foreach ($intgroups as $key => $intgroup) {
+      switch ($intgroup['form_field']) {
+        case 'radio':
+          $field_type = 'radios';
+          break;
+        case 'checkbox':
+          $field_type = 'checkboxes';
+          break;
+        default:
+          $field_type = $intgroup['form_field'];
+      }
+      $options = array();
+      foreach ((array)$intgroup['groups'] as $group) {
+        $options[$group['name']] = $group['name'];
+      }
+      $form['GROUPINGS_'. $intgroup['id']] = array(
+        '#type'           => $field_type,
+        '#title'          => $intgroup['name'],
+        '#options'        => $options,
+      );
+    }
   }
 }
 
