diff -u -r /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.drush.inc /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.drush.inc
--- /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.drush.inc	2010-05-26 17:11:02.000000000 -0700
+++ /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.drush.inc	2010-06-22 18:35:40.000000000 -0700
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Implementation of hook_drush_command().
+ * Implements hook_drush_command().
  *
  * @return
  *   An associative array of commands.
@@ -23,11 +23,11 @@
 
 function _mailchimp_cron_batch($temp_batchsize = NULL) {
   if ( !is_null($temp_batchsize) ) {
-    $stored_batchsize = variable_get('mailchimp_batch_limit',100) ;
-    variable_set('mailchimp_batch_limit',$temp_batchsize);
+    $stored_batchsize = variable_get('mailchimp_batch_limit', 100);
+    variable_set('mailchimp_batch_limit', $temp_batchsize);
   }
-  mailchimp_cron() ;
+  mailchimp_cron();
   if ( !is_null($batchsize) ) {
-    variable_set('mailchimp_batch_limit',$stored_batchsize);
+    variable_set('mailchimp_batch_limit', $stored_batchsize);
   }
-}
\ No newline at end of file
+}
diff -u -r /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.info /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.info
--- /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.info	2010-06-08 10:00:11.000000000 -0700
+++ /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.info	2010-06-22 18:35:43.000000000 -0700
@@ -2,10 +2,15 @@
 name = Mailchimp
 description = Mailchimp email service integration.
 package = MailChimp
-core = 6.x
+core = 7.x
 ; Information added by drupal.org packaging script on 2010-06-08
 version = "6.x-2.0-rc5"
-core = "6.x"
+core = 7.x
 project = "mailchimp"
 datestamp = "1276016411"
 
+
+files[] = MCAPI.class.php
+files[] = mailchimp.drush.inc
+files[] = mailchimp.install
+files[] = mailchimp.module
diff -u -r /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.install /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.install
--- /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.install	2010-06-07 23:26:48.000000000 -0700
+++ /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.install	2010-06-22 18:35:40.000000000 -0700
@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Install, update and uninstall functions for the mailchimp module.
+ *
+ */
+
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function mailchimp_schema() {
   // A table of uids
@@ -17,27 +23,28 @@
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function mailchimp_install() {
-  drupal_install_schema('mailchimp');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.;
+  // drupal_install_schema('mailchimp');
 }
 
 /**
- * implementation of hook_update_N
+ * Implements hook_update_N().
  */
-function mailchimp_update_6200(){
+function mailchimp_update_6200() {
   // clean up old variables
   $ret = array();
   $ret[] = update_sql("DELETE FROM {variable} WHERE name like 'mailchimp_list\_%'");
   cache_clear_all();
-  return $ret;  
+  return $ret;
 }
 
 /**
- * Implementation of hook_update_N().
+ * Implements hook_update_N().
  *
- * Create a new table for the queue. 
+ * Create a new table for the queue.
  *
  * When going from no queue to queue, we have to import everyone to
  * the queue for the first pass. After that we can start adding people
@@ -45,38 +52,38 @@
  */
 function mailchimp_update_6201() {
   $ret = array();
-  
+
   $schema = drupal_get_schema_unprocessed('mailchimp', 'mailchimp_user');
-  db_create_table($ret, 'mailchimp_user', $schema);
+  db_create_table('mailchimp_user', $schema);
 
   // Everybody goes in here (exclude status = 0 here?)
-  $ret[] = update_sql("INSERT INTO {mailchimp_user} (uid, status) SELECT uid, '". MAILCHIMP_USERSTATUS_PENDING ."' FROM {users} WHERE uid > 0");
+  $ret[] = update_sql("INSERT INTO {mailchimp_user} (uid, status) SELECT uid, '" . MAILCHIMP_USERSTATUS_PENDING . "' FROM {users} WHERE uid > 0");
   return $ret;
 }
 
 /**
- * Implementation of hook_update_N().
+ * Implements hook_update_N().
  *
  * Takes the old username and password and changes it into an API key.
  */
 function mailchimp_update_6202() {
   $ret = array();
-  
+
   module_load_include('php', 'mailchimp', 'MCAPI.class');
 
   $q = new MCAPI(variable_get('mailchimp_username', ''), variable_get('mailchimp_password', ''));
   // Set the timeout to something reasonsable to avoid taking down the site.
   $q->setTimeout(60);
-  
+
   if ($q->errorCode) {
     watchdog('mailchimp', $q->errorMessage, NULL, WATCHDOG_ERROR);
     $ret[] = array('success' => FALSE, 'query' => 'MailChimp returned error: ' . check_plain($q->errorMessage));
     return $ret;
   }
-  
+
   // Save the API key.
   variable_set('mailchimp_api_key', $q->api_key);
-  
+
   // Clean up old variables.
   variable_del('mailchimp_username');
   variable_del('mailchimp_password');
@@ -84,7 +91,7 @@
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function mailchimp_uninstall() {
   variable_del('mailchimp_api_key');
@@ -98,5 +105,6 @@
   variable_del('mailchimp_user_edit');
   variable_del('mailchimp_user_register');
 
-  drupal_uninstall_schema('mailchimp');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.;
+  // drupal_uninstall_schema('mailchimp');
 }
diff -u -r /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.module /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.module
--- /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/old/mailchimp/mailchimp.module	2010-06-08 09:44:55.000000000 -0700
+++ /Users/jonduell_pro/Sites/drupal7.dev/sites/default/files/coder_upgrade/new/mailchimp/mailchimp.module	2010-06-22 18:35:43.000000000 -0700
@@ -13,16 +13,15 @@
 define('MAILCHIMP_USERSTATUS_CURRENT', 'current');
 
 /**
- * Implementation of hook_user
- *
- * Required lists are updated on insert, update, and delete.
- * The list form fields are added to the registration and profile forms
+ * Implements hook_form_user_register_form_alter().
  */
-function mailchimp_user($op, &$edit, &$account, $category = NULL) {
-  // include the form in the user registration if any applicable newsletters
-  if ($op == 'register' && variable_get('mailchimp_user_register', TRUE)){
+function mailchimp_form_user_register_form_alter(&$form, &$form_state) {
+  $edit = $form;
+  $account = $form['#user'];
+  $category = $form['#user_category'];
+  if (TRUE && variable_get('mailchimp_user_register', TRUE)) {
     $account->roles = array(2 => 'authenticated');
-    if(count(_mailchimp_get_available_lists($account)) > 0 ){
+    if (count(_mailchimp_get_available_lists($account)) > 0 ) {
       // wrap in a fieldset
       $form['mailchimp_lists'] = array(
         '#type' => 'fieldset',
@@ -32,45 +31,58 @@
       return $form;
     }
   }
+}
 
+/**
+ * Implements hook_user().
+ *
+ * Required lists are updated on insert, update, and delete.
+ * The list form fields are added to the registration and profile forms
+ */
+function mailchimp_user_OLD($op, &$edit, &$account, $category = NULL) {
+  // TODO Remaining code in this function needs to be moved to the appropriate new hook function.
+  // include the form in the user registration if any applicable newsletters
   if (in_array($op, array('insert', 'delete', 'update')) && $q = _mailchimp_get_api_object()) {
-    foreach ((array)_mailchimp_get_required_lists() as $list) {
+    foreach ((array) _mailchimp_get_required_lists() as $list) {
       $action_taken = FALSE;
       switch ($op) {
-      // delete a user from MC list
+        // delete a user from MC list
         case "delete":
           db_query('DELETE FROM {mailchimp_user} WHERE uid = %d', $account->uid);
+          db_delete('mailchimp_user')
+    ->condition('uid', $account->uid)
+  ->execute();
           $ret = _mailchimp_unsubscribe_user($list, $account->mail, FALSE, $q);
           $action_taken = TRUE;
           break;
-        // insert or update a user to/in a MC list
+          // insert or update a user to/in a MC list
         case 'insert':
         case 'update':
           // don't repeat if already managing via cron
           if (!variable_get('mailchimp_cron', FALSE) ) {
             $action_taken = TRUE;
-            
+
             // determine if a user is allowed in a given list
             $is_allowed = FALSE;
             $roles = $edit['roles'];
             if (!is_array($roles)) {
               $roles = $account->roles;
             }
-            foreach($list->roles as $key=>$value){
-              if(array_key_exists($key, $roles)){
+            foreach ($list->roles as $key => $value) {
+              if (array_key_exists($key, $roles)) {
                 $is_allowed = TRUE;
                 break;
               }
             }
 
             // they are allowed, update or subscribe
-            if($is_allowed){
+            if ($is_allowed) {
               $userinfo = _mailchimp_load_user_list_mergevars($account->uid, $list->id, $q->listMergeVars($list->id));
               $userinfo['EMAIL'] = $edit['mail'];
               $ret = _mailchimp_subscribe_user($list, $account->mail, $userinfo, FALSE, $q);
             }
             // remove from list
-            else{
+            else {
               $ret = _mailchimp_unsubscribe_user($list, $account->mail, FALSE, $q);
             }
           }
@@ -78,15 +90,27 @@
             // They don't *really* need to go in the queue unless they just changed their prefs.
             if ($op == 'insert') {
               db_query("INSERT INTO {mailchimp_user} (uid, status) VALUES (%d, '%s')", $account->uid, MAILCHIMP_USERSTATUS_PENDING);
+              $id = db_insert('mailchimp_user')
+  ->fields(array(
+    'uid' => $account->uid,
+    'status' => MAILCHIMP_USERSTATUS_PENDING,
+  ))
+  ->execute();
             }
             else {
               db_query("UPDATE {mailchimp_user} SET status = '%s' WHERE uid = %d", MAILCHIMP_USERSTATUS_PENDING, $account->uid);
+              db_update('mailchimp_user')
+  ->fields(array(
+    'status' => MAILCHIMP_USERSTATUS_PENDING,
+  ))
+  ->condition('uid', $account->uid)
+  ->execute();
             }
           }
           break;
       }
 
-      if($action_taken){
+      if ($action_taken) {
         if ($ret) {
           watchdog('mailchimp', 'MailChimp: %email updated in list %list on action %action',
               array('%email' => $account->mail, '%list' => $list->name, '%action' => $op), WATCHDOG_NOTICE);
@@ -102,7 +126,7 @@
 /**
  * Add mailchimp form fields to account and registration forms
  */
-function mailchimp_subscribe_auth_form($form_state, $account, $standalone = TRUE) {
+function mailchimp_subscribe_auth_form($form, $form_state, $account, $standalone = TRUE) {
   $form = array();
 
   if ($q = _mailchimp_get_api_object()) {
@@ -132,12 +156,12 @@
         }
 
         // wrap in a div
-        $form['wrapper'. $list->id] = array(
+        $form['wrapper' . $list->id] = array(
           '#prefix' => '<div class="mailchimp-newsletter-wrapper">',
           '#suffix' => '</div>'
         );
 
-        $form['wrapper'. $list->id]['mailchimp_list_'. $list->id] = array(
+        $form['wrapper' . $list->id]['mailchimp_list_' . $list->id] = array(
             '#type'           => 'checkbox',
             '#title'          => t('Subscribe to the @newsletter newsletter', array('@newsletter' => $list->name)),
             '#default_value'  => $default_value,
@@ -159,10 +183,10 @@
                 $field_type = $intgroup['form_field'];
             }
             $options = array();
-            foreach ((array)$intgroup['groups'] as $group) {
+            foreach ((array) $intgroup['groups'] as $group) {
               $options[$group] = $group;
             }
-            $form['wrapper'. $list->id]['mailchimp_list_'. $list->id .'_INTERESTS'] = array(
+            $form['wrapper' . $list->id]['mailchimp_list_' . $list->id . '_INTERESTS'] = array(
               '#type'           => $field_type,
               '#title'          => $intgroup['name'],
               '#options'        => $options,
@@ -170,19 +194,19 @@
               '#attributes'     => array('class' => 'mailchimp-newsletter-interests-' . $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();
+              if($(".mailchimp-newsletter-checkbox-' . $list->id . '").attr("checked")){
+                $(".mailchimp-newsletter-interests-' . $list->id . '").parent(".form-item").show();
               } else {
-                $(".mailchimp-newsletter-interests-'. $list->id .'").parent(".form-item").hide();
+                $(".mailchimp-newsletter-interests-' . $list->id . '").parent(".form-item").hide();
               }
-              $(".mailchimp-newsletter-checkbox-'. $list->id .'").click(function(){ $(".mailchimp-newsletter-interests-'. $list->id .'").parent(".form-item").toggle("slow");});
-            });', 'inline');
+              $(".mailchimp-newsletter-checkbox-' . $list->id . '").click(function(){ $(".mailchimp-newsletter-interests-' . $list->id . '").parent(".form-item").toggle("slow");});
+            });', array('type' => 'inline', 'scope' => JS_DEFAULT));
           }
         }
       }
     }
 
-    if ($standalone){
+    if ($standalone) {
       $form['submit'] = array(
         '#type' => 'submit',
         '#value' => t('save settings'),
@@ -195,13 +219,13 @@
 }
 
 /**
- * Implementation of hook_form_alter
+ * Implements hook_form_alter().
  *
  * Add a submit handler to registration and profile forms. Doing this in hook_user breaks user updates
  */
-function mailchimp_form_alter(&$form, $form_state, $form_id){
-  if($form_id == 'user_register'){
-    if(variable_get('mailchimp_user_register', TRUE)){
+function mailchimp_form_alter(&$form, $form_state, $form_id) {
+  if ($form_id == 'user_register') {
+    if (variable_get('mailchimp_user_register', TRUE)) {
       // need to set this here as the submit handler doesn't get triggered in hook_user
       $form['#submit'][] = 'mailchimp_subscribe_auth_form_submit';
     }
@@ -215,7 +239,7 @@
   if ($q = _mailchimp_get_api_object()) {
     $account = new stdClass();
     if ($form_state['values']['uid']) {
-      $account = user_load(array('uid' => $form_state['values']['uid']));
+      $account = user_load_multiple(array($form_state['values']['uid']));
     }
     else {
       $account = $form_state['user'];
@@ -223,30 +247,30 @@
 
     $lists = _mailchimp_get_available_lists($account);
     foreach ($lists as $list) {
-    // ignore required lists, they are handled via hook_user
+      // ignore required lists, they are handled via hook_user
       if ($list->listtype !== MAILCHIMP_LISTTYPE_REQUIRED) {
         $is_subscribed = _mailchimp_is_subscribed($list->id, $account->mail, $q);
         $ret = TRUE;
-        $selected = @$form_state['values']['mailchimp_list_'. $list->id];
+        $selected = @$form_state['values']['mailchimp_list_' . $list->id];
 
         // unsubscribe a subscribed user who unchecked the box for this newsletter
         if ($is_subscribed && !$selected) {
           $ret = _mailchimp_unsubscribe_user($list, $account->mail, TRUE, $q);
         }
         else if ($selected) {
-        // subscribe the user if they are not previously subscribed or update existing subscriptions
+          // subscribe the user if they are not previously subscribed or update existing subscriptions
           $merge_vars = _mailchimp_load_user_list_mergevars($account->uid, $list->id, $q->listMergeVars($list->id));
 
           // include updated email address if already subscribed
-          if (!empty($form_state['values']['mail']) && $is_subscribed){
+          if (!empty($form_state['values']['mail']) && $is_subscribed) {
             $merge_vars['EMAIL'] = $form_state['values']['mail'];
           }
 
           // 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']));
+          if (!empty($form_state['values']['mailchimp_list_' . $list->id . '_INTERESTS'])) {
+            $merge_vars['INTERESTS'] = implode(',', array_filter($form_state['values']['mailchimp_list_' . $list->id . '_INTERESTS']));
           }
-          
+
           $ret = _mailchimp_subscribe_user($list, $account->mail, $merge_vars, TRUE, $q);
         }
 
@@ -259,7 +283,7 @@
 }
 
 /**
- * Implementation of hook_cron.
+ * Implements hook_cron().
  *
  * Resubscribes all users to the required lists if the user has chosen to do so.
  */
@@ -267,7 +291,7 @@
   if (variable_get('mailchimp_cron', FALSE) && $q = _mailchimp_get_api_object()) {
     $sql = "SELECT uid FROM {mailchimp_user} WHERE status = '%s'";
     $result = db_query_range($sql, array(MAILCHIMP_USERSTATUS_PENDING), 0, variable_get('mailchimp_batch_limit', 100));
-  
+
     if ($result) {
       $lists = _mailchimp_get_required_lists();
       foreach ($lists as $key => $list) {
@@ -276,11 +300,17 @@
       }
       while ($row = db_fetch_object($result)) {
         db_query('UPDATE {mailchimp_user} SET status = \'%s\' WHERE uid = %d', MAILCHIMP_USERSTATUS_CURRENT, $account->uid);
-        if ($account = user_load(array('uid' => $row->uid))) {
+        db_update('mailchimp_user')
+  ->fields(array(
+    'status' => MAILCHIMP_USERSTATUS_CURRENT,
+  ))
+  ->condition('uid', $account->uid)
+  ->execute();
+        if ($account = user_load_multiple(array($row->uid))) {
           // We don't update people if their status = 0 (but perhaps we could unsubscribe them?)
           if ($account->status) {
-            foreach ((array)$lists as $key => $list) {
-              foreach ((array)$account->roles as $rid => $info) {
+            foreach ((array) $lists as $key => $list) {
+              foreach ((array) $account->roles as $rid => $info) {
                 if ($list->roles[$rid]) {
                   $lists[$key]->batch[] = _mailchimp_load_user_list_mergevars($row->uid, $list->id, $lists[$key]->mergevars);
                   break;
@@ -296,7 +326,7 @@
         if (count($lists[$key]->batch)) {
           $ret = $q->listBatchSubscribe($list->id, $lists[$key]->batch, FALSE, TRUE);
           if ($ret['error_count'] > 0) {
-            foreach ((array)$ret['errors'] as $error) {
+            foreach ((array) $ret['errors'] as $error) {
               watchdog('mailchimp', $error['message'], NULL, WATCHDOG_ERROR);
             }
           }
@@ -310,7 +340,7 @@
 }
 
 /**
- * Implementation of hook_menu.
+ * Implements hook_menu().
  */
 function mailchimp_menu() {
   $items = array();
@@ -327,20 +357,20 @@
 
   $items['mailchimp/subscribe'] = array(
       'page callback' => 'mailchimp_subscribe_page',
-      'title' => 'Newsletter Subscription' ,
+      'title' => 'Newsletter Subscription',
       'type' => MENU_NORMAL_ITEM,
       'access arguments' => array('access content'),
   );
   $items['mailchimp/unsubscribe'] = array(
       'page callback' => 'drupal_get_form',
       'page arguments' => array('mailchimp_unsubscribe_form'),
-      'title' => 'Newsletter Unsubscribe' ,
+      'title' => 'Newsletter Unsubscribe',
       'type' => MENU_CALLBACK,
       'access callback' => TRUE,
   );
   $items['mailchimp/unsubscribe/success'] = array(
       'page callback' => 'mailchimp_unsubscribe_success',
-      'title' => 'Unsubscription Confirmed' ,
+      'title' => 'Unsubscription Confirmed',
       'type' => MENU_CALLBACK,
       'access callback' => TRUE,
   );
@@ -350,7 +380,7 @@
       'type' => MENU_CALLBACK,
       'access callback' => TRUE,
   );
-  $items['admin/settings/mailchimp'] = array(
+  $items['admin/config/mailchimp'] = array(
       'title' => 'MailChimp',
       'description' => 'Manage MailChimp Settings.',
       'page callback' => 'drupal_get_form',
@@ -362,8 +392,8 @@
   return $items;
 }
 
-function mailchimp_user_edit_access($user){
-  if(variable_get('mailchimp_user_edit', TRUE) && user_edit_access($user)){
+function mailchimp_user_edit_access($user) {
+  if (variable_get('mailchimp_user_edit', TRUE) && user_edit_access($user)) {
     return TRUE;
   }
   else {
@@ -371,17 +401,22 @@
   }
 }
 /**
- * Implementation of hook_perm()
+ * Implements hook_permission().
  */
-function mailchimp_perm() {
-  return array('administer mailchimp');
+function mailchimp_permission() {
+  return array(
+    'administer mailchimp' => array(
+      'title' => t('administer mailchimp'),
+      'description' => t('TODO Add a description for administer mailchimp'),
+    ),
+  );
 }
 
 /**
- * implementation of hook_admin_settings
+ * Implements hook_admin_settings().
  * @return <type>
  */
-function mailchimp_admin_settings() {
+function mailchimp_admin_settings($form, &$form_state) {
   module_load_include('php', 'mailchimp', 'MCAPI.class');
 
   $form['mailchimp_account_info'] = array(
@@ -397,7 +432,7 @@
       '#default_value' => variable_get('mailchimp_api_key', ''),
       '#description' => t('The API key for your MailChimp account. Get or generate a valid API key at your !apilink.', array('!apilink' => l(t('MailChimp API Dashboard'), 'http://admin.mailchimp.com/account/api')))
   );
-  
+
   // only show the list selection forms if account info provided
   $api_key = variable_get('mailchimp_api_key', FALSE);
   if ($api_key) {
@@ -416,7 +451,7 @@
           $saved_list = unserialize(variable_get('mailchimp_lists', NULL));
           $saved_list = $saved_list[$list['id']];
 
-          $form['mailchimp_lists']['mailchimp_list_'. $list['id']] = array(
+          $form['mailchimp_lists']['mailchimp_list_' . $list['id']] = array(
               '#type'       => 'fieldset',
               '#collapsible' => TRUE,
               '#collapsed' => TRUE,
@@ -424,18 +459,18 @@
               '#tree'         => TRUE,
           );
 
-          $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['list_id'] = array(
+          $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['list_id'] = array(
               '#type'       => 'value',
               '#value'      => $list['id'],
           );
 
-          $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['name'] = array(
+          $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['name'] = array(
               '#type'       => 'value',
               '#value'      => $list['name'],
           );
 
           // Add a row of checkboxes for role enabling.
-          $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['roles'] = array(
+          $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['roles'] = array(
               '#type'         => 'fieldset',
               '#title'        => t('Roles'),
               '#description'  => t('Choose which roles may subscribe to this list. All users will see the lists they\'re eligble for at the !subscribe and in the subscription block. Lists assigned to the Authenticated role may also apear in the registration form if that option is selected below. Authenticated user may also manage their list settings from their profile.', array('!subscribe' => l(t('newsletter subscription page'), 'mailchimp/subscribe'))),
@@ -443,29 +478,29 @@
           );
 
           foreach (user_roles() as $rid => $name) {
-            $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['roles'][$rid] = array(
+            $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['roles'][$rid] = array(
                 '#type'           => 'checkbox',
                 '#title'          => $name,
                 '#default_value'  => $saved_list->roles[$rid],
             );
           }
 
-          $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['description'] = array(
+          $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['description'] = array(
               '#type'           => 'textarea',
               '#title'          => t('List Description'),
               '#default_value'  => $saved_list->description,
               '#description'    => t('This description will be shown to the user on the list signup and user account settings pages')
           );
 
-          $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['listtype'] = array(
+          $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['listtype'] = array(
               '#type'           => 'select',
               '#title'          => t('Subscription Method'),
               '#options'        => array(MAILCHIMP_LISTTYPE_OPTIN => "Opt-in", MAILCHIMP_LISTTYPE_OPTOUT => 'Opt-out', MAILCHIMP_LISTTYPE_REQUIRED => 'Required'),
-              '#default_value'  => ($saved_list->listtype) ?  $saved_list->listtype : MAILCHIMP_LISTTYPE_OPTOUT,
+              '#default_value'  => ($saved_list->listtype) ?   $saved_list->listtype : MAILCHIMP_LISTTYPE_OPTOUT,
               '#description'    => t('<strong>Opt-in:</strong> Users must sign up to recieve messages.<br/><strong>Opt-out: </strong> Users are automatically signed up but may unsubscribe.<br/><strong>Required: </strong> Users will remain on the list as long as they have an account and cannot unsubscribe.')
           );
 
-          $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['doublein'] = array(
+          $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['doublein'] = array(
               '#type'           => 'checkbox',
               '#title'          => t('Require subscribers to Double Opt-in'),
               '#default_value'  => $saved_list->doublein,
@@ -473,8 +508,8 @@
           );
           $mergevars = $q->listMergeVars($list['id']);
           if ($mergevars) {
-          // Merge var fieldset
-            $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['mergevars'] = array(
+            // Merge var fieldset
+            $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['mergevars'] = array(
                 '#type'         => 'fieldset',
                 '#title'        => t('Merge Variables'),
                 '#description'  => t('Select Drupal user variables to send to Mailchimp as Merge Variables. Available Drupal variables are any Profile or Token variables for the given user. For more information on Merge Variables, see the !doc', array('!doc' => l(t('Mailchimp Documentation'), 'http://server.iad. liveperson.net/hc/s-31286565/cmd/kbresource/kb-8214439208090042855/view_question!PAGETYPE?sq=merge%2bvariables&sf=101113&sg=0&st=188569&documentid=143258&action=view'))),
@@ -483,7 +518,7 @@
             $mergeoptions = mailchimp_get_merge_keys();
             foreach ($mergevars as $mergevar) {
               if ($mergevar['tag'] !== 'EMAIL') {
-                $form['mailchimp_lists']['mailchimp_list_'. $list['id']]['mergevars'][$mergevar['tag']] = array(
+                $form['mailchimp_lists']['mailchimp_list_' . $list['id']]['mergevars'][$mergevar['tag']] = array(
                     '#type'           => 'select',
                     '#title'          => $mergevar['name'],
                     '#options'        => $mergeoptions,
@@ -545,7 +580,7 @@
           '#title' => t('Mailchimp Cron'),
         );
         $form['cron']['info'] = array(
-          '#value' => t('Updates to Mailchimp can be done when the user is added or edited, or deferred until the next cron run. Deferring these updates to cron will speed up the user interface when editing users. You need to ensure cron is running correctly, and that it keeping up with the number of user edits on your site.<br /><strong>There are currently !count users with pending updates in the queue.</strong>', array('!count'=>db_result(db_query('SELECT COUNT(*) FROM {mailchimp_user} WHERE status = \'%s\'', MAILCHIMP_USERSTATUS_PENDING)))),
+          '#value' => t('Updates to Mailchimp can be done when the user is added or edited, or deferred until the next cron run. Deferring these updates to cron will speed up the user interface when editing users. You need to ensure cron is running correctly, and that it keeping up with the number of user edits on your site.<br /><strong>There are currently !count users with pending updates in the queue.</strong>', array('!count' => db_query('SELECT COUNT(*) FROM {mailchimp_user} WHERE status = \'%s\'', MAILCHIMP_USERSTATUS_PENDING)->fetchField())),
         );
         $form['cron']['mailchimp_cron'] = array(
             '#type'           => 'checkbox',
@@ -583,14 +618,14 @@
       }
     }
     else if (FALSE && $q->errorCode === 'INVALID_LOGIN') {
-        drupal_set_message(t('Could not login to mailchimp. Please check your username and password.'), "error");
-      }
-      else if ($q->errorMessage) {
-          drupal_set_message(t('Could not retrieve info for mailchimp. The following error was returned: %error.', array('%error' => $q->errorMessage)), "error");
-        }
-        else {
-          drupal_set_message(t('Could not retrieve info for mailchimp for an unknown reason. Please try again later'), "error");
-        }
+      drupal_set_message(t('Could not login to mailchimp. Please check your username and password.'), "error");
+    }
+    else if ($q->errorMessage) {
+      drupal_set_message(t('Could not retrieve info for mailchimp. The following error was returned: %error.', array('%error' => $q->errorMessage)), "error");
+    }
+    else {
+      drupal_set_message(t('Could not retrieve info for mailchimp for an unknown reason. Please try again later'), "error");
+    }
   }
 
   $form['#validate'][] = 'mailchimp_admin_settings_validate';
@@ -606,7 +641,7 @@
  */
 function mailchimp_admin_settings_validate($form, &$form_state) {
   // no lists selected or first time here
-  if(!is_array($form_state['values']['mailchimp_lists'])){
+  if (!is_array($form_state['values']['mailchimp_lists'])) {
     return;
   }
 
@@ -634,16 +669,16 @@
  * @global <type> $user
  * @return <type> page content of all available MC lists for a given user
  */
-function mailchimp_subscribe_page(){
+function mailchimp_subscribe_page() {
   global $user;
   $ret = '';
-  if($user->uid){
+  if ($user->uid) {
     $ret = drupal_get_form('mailchimp_subscribe_auth_form', $user);
   }
   elseif ($q = _mailchimp_get_api_object()) {
-    $lists =_mailchimp_get_available_lists($user);
+    $lists = _mailchimp_get_available_lists($user);
     foreach ($lists as $list) {
-      $ret .= '<h3 class="mailchimp-newseltter-title">'. $list->name .'</h3>'. drupal_get_form('mailchimp_subscribe_anon_form', $list, $q);
+      $ret .= '<h3 class="mailchimp-newseltter-title">' . $list->name . '</h3>' . drupal_get_form('mailchimp_subscribe_anon_form', $list, $q);
     }
   }
   return $ret;
@@ -657,7 +692,7 @@
  * @param <type> $q MC object
  * @return <type> form array
  */
-function mailchimp_subscribe_anon_form($form_state, $list, $q) {
+function mailchimp_subscribe_anon_form($form, $form_state, $list, $q) {
   $form = array();
 
   $form['description'] = array(
@@ -676,7 +711,7 @@
     $mergevalues = _mailchimp_load_user_list_mergevars($user->uid, $list->id, $q->listMergeVars($list->id));
   }
 
-  foreach ((array)$q->listMergeVars($list->id) as $mergevar) {
+  foreach ((array) $q->listMergeVars($list->id) as $mergevar) {
     // set the default value for merge fields if we have it
     if ($mergevalues && $mergevalues[$mergevar['tag']]) {
       $mergevar['default'] = $mergevalues[$mergevar['tag']];
@@ -696,7 +731,7 @@
       default:
         $field_type = $intgroup['form_field'];
     }
-    foreach ((array)$intgroup['groups'] as $group) {
+    foreach ((array) $intgroup['groups'] as $group) {
       $options[$group] = $group;
     }
     $form['INTERESTS'] = array(
@@ -732,7 +767,7 @@
 
   switch ($mergevar['field_type']) {
     case 'dropdown':
-    // dropdown is mapped to <select> element in Drupal Form API
+      // dropdown is mapped to <select> element in Drupal Form API
       $input['#type'] = 'select';
 
       // Creates options, we must delete array keys to have revealant information
@@ -744,7 +779,7 @@
       $input['#options'] = $choices;
       break;
     case 'radio':
-    // radio is mapped to <input type='radio' /> i.e. 'radios' element in Drupal Form API
+      // radio is mapped to <input type='radio' /> i.e. 'radios' element in Drupal Form API
       $input['#type'] = 'radios';
 
       // Creates options, we must delete array keys to have revealant information
@@ -757,7 +792,7 @@
       break;
 
     default:
-    // This is a standard input[type=text] or something we can't handle with Drupal FormAPI
+      // This is a standard input[type=text] or something we can't handle with Drupal FormAPI
       $input['#type'] = 'textfield';
       $input['#size'] = $mergevar['size'];
       break;
@@ -805,7 +840,7 @@
  * @param <type> $form_values
  * @return <type>
  */
-function mailchimp_unsubscribe_form($form_values = array()) {
+function mailchimp_unsubscribe_form($form, $form_values = array()) {
   $form = array();
   $form['intro'] = array(
       '#type'           => 'markup',
@@ -833,7 +868,7 @@
 function mailchimp_unsubscribe_form_submit($form, &$form_state) {
   if ($q || $q = _mailchimp_get_api_object()) {
     $success = TRUE;
-    foreach ((array)$q->lists() as $list) {
+    foreach ((array) $q->lists() as $list) {
       $success = $success && _mailchimp_unsubscribe_user($list, $form_state['values']['EMAIL'], TRUE, $q);
       if ($success) {
         drupal_set_message(variable_get('mailchimp_unsubscription_success_message', t('Thank you, you have been successfully unsubscribed.')));
@@ -855,10 +890,10 @@
   if (!$form_state['values']['EMAIL']) {
     form_set_error('EMAIL', t('Please enter your email address.'));
   }
-  else  {
+  else {
     if ($q || $q = _mailchimp_get_api_object()) {
       $subscribed = FALSE;
-      foreach ((array)$q->lists() as $list) {
+      foreach ((array) $q->lists() as $list) {
         $subscribed = $subscribed || _mailchimp_is_subscribed($list['id'], $form_state['values']['EMAIL'], $q);
       }
       if (!$subscribed) {
@@ -872,7 +907,7 @@
 }
 
 /**
- * Implementation of hook_mailchimp_merge_keys
+ * Implements hook_mailchimp_merge_keys().
  */
 function mailchimp_mailchimp_merge_keys() {
   $out = array(0 => '<none>');
@@ -906,7 +941,7 @@
     $tokens = token_get_list(array('user', 'order'));
     if (is_array($tokens['user'])) {
       foreach ($tokens['user'] as $token => $name) {
-        $out['token_'. $token] = t('Token: !field', array('!field' => $name));
+        $out['token_' . $token] = t('Token: !field', array('!field' => $name));
       }
     }
   }
@@ -915,12 +950,12 @@
 }
 
 /**
- * Implementation of hook_mailchimp_merge_values
+ * Implements hook_mailchimp_merge_values().
  */
 function mailchimp_mailchimp_merge_values($user) {
   $out = array();
-  $out = (array)$user;
-  foreach ((array)$user as $key => $value) {
+  $out = (array) $user;
+  foreach ((array) $user as $key => $value) {
     if (is_array($value) && $key != 'role') {
       $out[$key] = implode('/', $value);
     }
@@ -943,7 +978,7 @@
   if (function_exists('token_get_values')) {
     $vars = token_get_values('user', $user);
     foreach ($vars->tokens as $key => $value) {
-      $out['token_'. $value] = $vars->values[$key];
+      $out['token_' . $value] = $vars->values[$key];
     }
   }
   return $out;
@@ -961,7 +996,7 @@
  * Get all the potential merge var values for a given user
  */
 function mailchimp_get_merge_values($uid) {
-  if ($user = user_load(array('uid' => $uid))) {
+  if ($user = user_load_multiple(array($uid))) {
     return module_invoke_all('mailchimp_merge_values', $user);
   }
   return array();
@@ -1014,7 +1049,7 @@
     if (_mailchimp_is_subscribed($list->id, $email, $q)) {
       $action = 'updated in';
       $success = $q->listUpdateMember($list->id, $email, $merge_vars);
-      if($success && $message){
+      if ($success && $message) {
         drupal_set_message(t('You have updated your settings in %list.', array('%list' => $list->name)));
       }
     }
@@ -1054,7 +1089,7 @@
       }
     }
   }
-  return TRUE;//$success; // the mailchim api seems to always return FALSE on unsubscribe operations
+  return TRUE; //$success; // the mailchim api seems to always return FALSE on unsubscribe operations
 }
 
 /**
@@ -1066,7 +1101,7 @@
   if (!empty($all_lists)) {
     $all_lists = unserialize($all_lists);
     foreach ($all_lists as $key => $list) {
-      foreach ((array)$user->roles as $rid => $info) {
+      foreach ((array) $user->roles as $rid => $info) {
         if ($list->roles[$rid]) {
           $available_lists[$list->id] = $list;
           break;
@@ -1104,7 +1139,7 @@
   $q = new MCAPI(variable_get('mailchimp_api_key', ''));
   // set the timeout to something reasonsable to avoid taking down the Drupal site
   $q->setTimeout(60);
-  
+
   if ($q->errorCode) {
     watchdog('mailchimp', $q->errorMessage, NULL, WATCHDOG_ERROR);
     return NULL;
@@ -1113,11 +1148,10 @@
 }
 
 /**
- * implementation of hook_block
- * Provides a block for each available list for a given user
+ * Implements hook_block_info.
  */
-function mailchimp_block($op='list', $delta=0) {
-  if ($op == "list") {
+function mailchimp_block_info() {
+  if (TRUE) {
     $all_lists = variable_get('mailchimp_lists', array());
     if (!empty($all_lists)) {
       $all_lists = unserialize($all_lists);
@@ -1129,12 +1163,20 @@
       }
     }
   }
+}
+
+/**
+ * Implements hook_block().
+ * Provides a block for each available list for a given user
+ */
+function mailchimp_block_OLD($op = 'list', $delta = 0) {
+  // TODO Remaining code in this function needs to be moved to the appropriate new hook function.
   else if ($op == 'view') {
     global $user;
     $lists = _mailchimp_get_available_lists($user);
     $list = $lists[$delta];
     if (!empty($list) && $q = _mailchimp_get_api_object()) {
-      $block['subject'] = t('Subscribe to @title', array('@title' => $list->name));;
+      $block['subject'] = t('Subscribe to @title', array('@title' => $list->name));
       $block['content'] = drupal_get_form('mailchimp_subscribe_anon_form', $list, $q);
     }
   }
