diff --git a/civicrm_constant_contact.module b/civicrm_constant_contact.module
index f66eee1..850b42a 100755
--- a/civicrm_constant_contact.module
+++ b/civicrm_constant_contact.module
@@ -379,7 +379,7 @@ function civicrm_constant_contact_civicrm_post_manage_group( $op, $objectName, $
         WHERE entity_id=$objectId";
       CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_NULLArray );
       cc_log('The group '. $objectRef->title .' was successfully created in Constant Contact. The associated group id in Constant Contact is '. $constant_contact_group_id .'.');
-      civicrm_constant_contact_display('The group '. $objectRef->title. ' was successfully created in Constant Contact.');
+      civicrm_constant_contact_display('The group '. $objectRef->title . ' was successfully created in Constant Contact.');
     }//if sync
   }
   elseif ($op == "edit") { //end if create
@@ -421,10 +421,11 @@ function civicrm_constant_contact_civicrm_post_manage_group( $op, $objectName, $
             cc_log('The group '. $objectRef->title .' was successfully edited in Constant Contact.');
           }
           else { //if edit group
-            civicrm_constant_contact_display('The group '. $objectRef->title.' failed to be edited in Constant Contact.');
-            cc_log('The group '. $objectRef->title.' failed to be edited in Constant Contact.');
+            civicrm_constant_contact_display('The group '. $objectRef->title . ' failed to be edited in Constant Contact.');
+            cc_log('The group '. $objectRef->title . ' failed to be edited in Constant Contact.');
           }//else edit group
-        } else {//if $constant_contact_group_id
+        } 
+        else {//if $constant_contact_group_id
           //the group doesn't exist and must be created  
           //create group and store return URI
           $cleanId = explode("/", addGroup($objectRef));
@@ -432,8 +433,8 @@ function civicrm_constant_contact_civicrm_post_manage_group( $op, $objectName, $
           $constant_contact_group_id = $cleanId[7];
           //WARNING!!: Very destructive check here - remove everything in, referenceing, or even looking sideways at this group
           if ( !$constant_contact_group_id  ) {
-            civicrm_constant_contact_display('The group '. $objectRef->title.' failed to be created in Constant Contact.', 'error');
-            cc_log('The group '. $objectRef->title.' failed to be created in Constant Contact.', WATCHDOG_ERROR);
+            civicrm_constant_contact_display('The group '. $objectRef->title . ' failed to be created in Constant Contact.', 'error');
+            cc_log('The group '. $objectRef->title . ' failed to be created in Constant Contact.', WATCHDOG_ERROR);
             //$objectRef->discard( $objectId );
             $sync_query = "UPDATE $table
             SET $sync_field = 0
@@ -447,21 +448,23 @@ function civicrm_constant_contact_civicrm_post_manage_group( $op, $objectName, $
               SET $ccID_field=$constant_contact_group_id
               WHERE entity_id=$objectId";
             CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_NULLArray );
-            cc_log('The group '. $objectRef->title.' was successfully created in Constant Contact. The associated group id in Constant Contact is '. $constant_contact_group_id.'.');
-            civicrm_constant_contact_display('The group '. $objectRef->title.' was successfully created in Constant Contact.');
+            cc_log('The group '. $objectRef->title . ' was successfully created in Constant Contact. The associated group id in Constant Contact is '. $constant_contact_group_id .'.');
+            civicrm_constant_contact_display('The group '. $objectRef->title . ' was successfully created in Constant Contact.');
         }//else
         //group has been created or updated add members to the group in contant contact
         //get group members from civi
         $group_members = CRM_Contact_BAO_Group::getMember( $objectId );
         $cc_group_id = get_cc_group_id($objectId);
-	$numMembers = sizeof($group_members);
+  $numMembers = sizeof($group_members);
         if ($numMembers > 25) {
           if (bulk_update( $group_members, $cc_group_id)) {
-            civicrm_constant_contact_display($numMembers.' added to the group '. $objectRef->title);
-          } else {
+            civicrm_constant_contact_display($numMembers .' added to the group '. $objectRef->title);
+          } 
+          else {
             civicrm_constant_contact_display('Failed to update the group '. $objectRef->title);
           }
-        } else { //if members>25
+        } 
+        else { //if members>25
           //add or edit each group member in civi
           foreach ($group_members as $contact) {
             cc_log('count: '. $count);
@@ -473,41 +476,47 @@ function civicrm_constant_contact_civicrm_post_manage_group( $op, $objectName, $
               cc_log('old add?');
               $result = add_or_edit_subscriber($contactEmail, $contactDetails);
               if ( $result ) {
-                civicrm_constant_contact_display($contactEmail.' synced successfully in Constant Contact');
-                cc_log('Group Contact with e-mail '. $contactEmail.' synced successfully in Constant Contact for CiviCRM group with ID: '. $objectId.'.');
-              } else {//if result
-                civicrm_constant_contact_display($contactEmail.' failed to sync with Constant Contact');
-                cc_log('The group Contact with e-mail '. $contactEmail.' could not be synced in Constant Contact for   CiviCRM group with ID: '. $objectId.'.', WATCHDOG_ERROR);
+                civicrm_constant_contact_display($contactEmail .' synced successfully in Constant Contact');
+                cc_log('Group Contact with e-mail '. $contactEmail . ' synced successfully in Constant Contact for CiviCRM group with ID: '. $objectId . '.');
+              } 
+              else {//if result
+                civicrm_constant_contact_display($contactEmail . ' failed to sync with Constant Contact');
+                cc_log('The group Contact with e-mail '. $contactEmail .' could not be synced in Constant Contact for   CiviCRM group with ID: '. $objectId .'.', WATCHDOG_ERROR);
                 //** TODO:
                 //add code here to remove the created GroupContact from this group in Civi to keep data synched
                 //** End TODO
                 //----------------------------------------------------------------------------------
               }//else add failed
-            } else {//if empty
+            } 
+            else {//if empty
               cc_log('Could not sync contact: No e-mail address');
             }
           }//for each
         }//else members < 25
-      } else {//if !$_SESSION['cc_sync_bool']
+      } 
+      else {//if !$_SESSION['cc_sync_bool']
         //group is staying synced, means just a name change
         if (editGroup($constant_contact_group_id, $objectRef)) {
-          civicrm_constant_contact_display('The group '. $objectRef->title.' was successfully edited in Constant Contact.');
-          cc_log('The group '. $objectRef->title.' was successfully edited in Constant Contact.');
-        } else { //if edit group
-          civicrm_constant_contact_display('The group '. $objectRef->title.' failed to be edited in Constant Contact.');
-          cc_log('The group '. $objectRef->title.' failed to be edited in Constant Contact.');
+          civicrm_constant_contact_display('The group '. $objectRef->title .' was successfully edited in Constant Contact.');
+          cc_log('The group '. $objectRef->title .' was successfully edited in Constant Contact.');
+        } 
+        else { //if edit group
+          civicrm_constant_contact_display('The group '. $objectRef->title .' failed to be edited in Constant Contact.');
+          cc_log('The group '. $objectRef->title .' failed to be edited in Constant Contact.');
         }//else edit group  
                   
       }//else
-    } else {//if $constant_contact_group_sync_bool
+    } 
+    else {//if $constant_contact_group_sync_bool
       //from sync to no sync
       if ($old_cc_sync) {
         cc_log('sync to no sync');
         if (deleteGroup($constant_contact_group_id)) {
-          civicrm_constant_contact_display('The group '. $objectRef->title.' was successfully deleted from Constant Contact.');
-          cc_log('The group '. $objectRef->title.' was successfully deleted from Constant Contact.');
-        } else {
-          civicrm_constant_contact_display('The group '. $objectRef->title.' failed to be deleted from Constant Contact.');
+          civicrm_constant_contact_display('The group '. $objectRef->title .' was successfully deleted from Constant Contact.');
+          cc_log('The group '. $objectRef->title .' was successfully deleted from Constant Contact.');
+        } 
+        else {
+          civicrm_constant_contact_display('The group '. $objectRef->title .' failed to be deleted from Constant Contact.');
         }
         //delete the constant contact ID from the db
         $constant_contact_group_id = '';
@@ -553,7 +562,8 @@ function civicrm_constant_contact_civicrm_post_manage_individual( $op, $objectNa
       $result = add_or_edit_subscriber($_SESSION['cc_old_email_address'], $feilds);
       if ($result) {
         civicrm_constant_contact_display('Contact Updated in Constant Contact');
-      } else {
+      } 
+      else {
         civicrm_constant_contact_display('Contact Update Failed in Constant Contact');
       }
       break;
@@ -578,22 +588,22 @@ function civicrm_constant_contact_civicrm_post_manage_individual( $op, $objectNa
 function doServerCall($request, $parameter = '', $type="GET", $loginType = "") {
   $ch = curl_init();
   if ($loginType != 'Partner') $request = str_replace('http://', 'https://', $request); // Convert id URI to BASIC compliant
-  curl_setopt ($ch, CURLOPT_URL, $request);
-  curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
+  curl_setopt($ch, CURLOPT_URL, $request);
+  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
   curl_setopt($ch, CURLOPT_TIMEOUT, 100);
-  curl_setopt ($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
   $requestLogin = makeLogin($loginType);
-  curl_setopt ($ch, CURLOPT_USERPWD, $requestLogin);
+  curl_setopt($ch, CURLOPT_USERPWD, $requestLogin);
   // curl_setopt ($ch, CURLOPT_FOLLOWLOCATION  ,1); 
-  curl_setopt ($ch, CURLOPT_HEADER, 0);
-  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
-  curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml"));
-  curl_setopt ($ch, CURLOPT_FAILONERROR, 1);
-  curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
+  curl_setopt($ch, CURLOPT_HEADER, 0);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml"));
+  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
+  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   switch ($type) {
     case 'POST': 
-      curl_setopt ($ch, CURLOPT_POST, 1);
-      curl_setopt ($ch, CURLOPT_POSTFIELDS , $parameter);
+      curl_setopt($ch, CURLOPT_POST, 1);
+      curl_setopt($ch, CURLOPT_POSTFIELDS , $parameter);
       break;
     case 'PUT':
       $tmpfile = tmpfile();
@@ -608,17 +618,17 @@ function doServerCall($request, $parameter = '', $type="GET", $loginType = "") {
       curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");        
       break;
       default:
-        curl_setopt ($ch, CURLOPT_HTTPGET, 1);
+        curl_setopt($ch, CURLOPT_HTTPGET, 1);
         break;
   }
-  $emessage = curl_exec ($ch);
+  $emessage = curl_exec($ch);
   //civicrm_constant_contact_display($emassage); // echo $request.'<br />';
   //set to TRUE to see debug messages
   $error = curl_error($ch);
   if ($error) { 
-    drupal_set_message($error,'error'); 
+    drupal_set_message($error, 'error'); 
   }
-  curl_close ($ch);
+  curl_close($ch);
   //if ($emessage) { $return = array('return' => TRUE, 'body' => $emessage); }
   //else { $return = array('return' => FALSE, 'body' => $error); }
   return $emessage; # This returns HTML
@@ -634,7 +644,7 @@ function doServerCall($request, $parameter = '', $type="GET", $loginType = "") {
  * @return String used for logging into constant contact servers
  */  
 function makeLogin($type = "") {
-  return   $requestLogin = variable_get('civicrm_constant_contact_apikey',"")."%".variable_get('civicrm_constant_contact_username',"").":".variable_get('civicrm_constant_contact_password',"");
+  return   $requestLogin = variable_get('civicrm_constant_contact_apikey', "")."%".variable_get('civicrm_constant_contact_username', "").":".variable_get('civicrm_constant_contact_password', "");
 }
 
 function createAccountXML( $params= array() ) {
@@ -742,7 +752,7 @@ function createContactXML($id, $params = array()) {
   /*
     if (!empty($params['custom_fields'])) {
       foreach ($params['custom_fields'] as $k=>$v) {
-        $contact_node->addChild("CustomField".$k, htmlspecialchars($v));
+        $contact_node->addChild("CustomField". $k, htmlspecialchars($v));
       }
     }
    */
@@ -771,13 +781,14 @@ function createContactXML($id, $params = array()) {
 function addSubscriber($feilds) {
   $contactXML = createContactXML("", $feilds);
   //cc_log('add XML: '.(string)$contactXML);
-  $call = variable_get('civicrm_constant_contact_apipath',"").variable_get('civicrm_constant_contact_username',"").'/contacts';
+  $call = variable_get('civicrm_constant_contact_apipath', "").variable_get('civicrm_constant_contact_username', "").'/contacts';
   $return = doServerCall($call, $contactXML, 'POST');
   $parsedReturn = simplexml_load_string($return);
   if ($return) {
     return TRUE; 
-  } else {
-  return FALSE;
+  } 
+  else {
+    return FALSE;
   }
 }
 
@@ -805,15 +816,16 @@ function add_or_edit_subscriber($contactEmail, $feilds) {
     $return = doServerCall($id, $contactXML, 'PUT');
   }
   if (!empty($return)) {
-    if (strpos($return,'<')!== FALSE) {
+    if (strpos($return, '<')!== FALSE) {
       $parsedReturn = simplexml_load_string($return);
       if (!empty($parsedReturn->message)) {
         $lastError = $parsedReturn->message;
       }
-    } else {
+    } 
+    else {
       $lastError = $return;
     }
-      drupal_set_message($lastError,'warning');
+      drupal_set_message($lastError, 'warning');
       return FALSE;
   }
     return TRUE;
@@ -836,12 +848,13 @@ function deleteSubscriber($contactEmail, $feilds) {
   $contactXML = createContactXML($id, $feilds);
   $return = doServerCall($id, $contactXML, 'PUT');
   if (!empty($return)) {
-    if (strpos($return,'<')!== FALSE) {
+    if (strpos($return, '<')!== FALSE) {
       $parsedReturn = simplexml_load_string($return);
       if (!empty($parsedReturn->message)) {
         $lastError = $parsedReturn->message;
       }
-    } else {
+    } 
+    else {
       $lastError = $parsedReturn->message;
     }
     return FALSE;
@@ -861,7 +874,7 @@ function deleteSubscriber($contactEmail, $feilds) {
 function civicrm_constant_contact_get_primary_email($contact_id) {
   //Get all the emails associated with the given contact ID
   $array = array();
-  $all_user_emails = CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_Email', 'contact_id', $contact_id, $array, array(        'is_primary','email'));
+  $all_user_emails = CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_Email', 'contact_id', $contact_id, $array, array(        'is_primary', 'email'));
   //Look for the email with the primary variable set, and return that address
   foreach ($all_user_emails as $email) {
     if ($email['is_primary']=='1') {
@@ -899,9 +912,9 @@ function civicrm_constant_contact_get_primary_address($contact_id) {
   foreach ($all_addresses as $address) {
     if ($address['is_primary']=='1') {
     cc_log('insede primary ook');
-    $address['stateName'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_StateProvince', $address['state_province_id'],'name','id');
+    $address['stateName'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_StateProvince', $address['state_province_id'], 'name', 'id');
     cc_log('state name: '. $address['stateName']);
-    $address['stateCode'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_StateProvince',$address['state_province_id'],'abbreviation','id');
+    $address['stateCode'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_StateProvince', $address['state_province_id'], 'abbreviation', 'id');
     cc_log('state code: '. $address['stateCode']);
     cc_log('attempt to return primary: '. $address);
       return $address;
@@ -922,20 +935,20 @@ function civicrm_constant_contact_get_primary_address($contact_id) {
  * @return Bi-Dimenstional array with information about contacts. 
  */
 
-function getSubcribers($email = '',$page = '') {
+function getSubcribers($email = '', $page = '') {
   $contacts = array();
   $contacts['items'] = array();
-  $apipath = variable_get('civicrm_constant_contact_apipath',"");
-  $username = variable_get('civicrm_constant_contact_username',"");
+  $apipath = variable_get('civicrm_constant_contact_apipath', "");
+  $username = variable_get('civicrm_constant_contact_username', "");
   if (!empty($email)) {
-    $call = $apipath.$username.'/contacts?email='. $email;
+    $call = $apipath . $username .'/contacts?email='. $email;
   }
   else {
     if (!empty($page)) {
-      $call = $apipath.$username.$page;
+      $call = $apipath . $username . $page;
     }
     else {
-      $call = $apitpath.$username.'/contacts';
+      $call = $apitpath . $username .'/contacts';
     }
   }
   $return = doServerCall($call);
@@ -945,15 +958,15 @@ function getSubcribers($email = '',$page = '') {
   foreach ($parsedReturn->link as $item) {
     $attributes = $item->Attributes();
     if (!empty($attributes['rel']) && $attributes['rel']=='next') {
-      $tmp = explode($requestLogin,$attributes['href']);
+      $tmp = explode($requestLogin, $attributes['href']);
       $contacts['next'] = $tmp[1];
     }
     if (!empty($attributes['rel']) && $attributes['rel']=='first') {
-      $tmp = explode($requestLogin,$attributes['href']);
+      $tmp = explode($requestLogin, $attributes['href']);
       $contacts['first'] = $tmp[1];
     }
     if (!empty($attributes['rel']) && $attributes['rel']=='current') {
-      $tmp = explode($requestLogin,$attributes['href']);
+      $tmp = explode($requestLogin, $attributes['href']);
       $contacts['current'] = $tmp[1];
     }
   }
@@ -981,7 +994,7 @@ function createGroupXML($id, $groupName) {
   if (empty($id)) {
     $id = "data:,";
   }
-  $update_date = date("Y-m-d").'T'.date("H:i:s").'+01:00';
+  $update_date = date("Y-m-d") .'T'. date("H:i:s") .'+01:00';
   $xml_string = "<entry xmlns='http://www.w3.org/2005/Atom'></entry>";
   $xml_object = simplexml_load_string($xml_string);
   $id_node = $xml_object->addChild("id", htmlspecialchars($id));
@@ -1006,14 +1019,15 @@ function createGroupXML($id, $groupName) {
  * @return URI for the newly created group, 
  */
 function addGroup($groupName) {
-  $call = variable_get('civicrm_constant_contact_apipath',"").variable_get('civicrm_constant_contact_username',"").'/lists';
+  $call = variable_get('civicrm_constant_contact_apipath', "") . variable_get('civicrm_constant_contact_username', "") .'/lists';
   $groupXML = createGroupXML("", $groupName);
   $return = doServerCall($call, $groupXML, 'POST');
   $parsedReturn = simplexml_load_string($return);
   $created_id = $parsedReturn->id; 
   if ($created_id) {
     return $created_id; 
-  } else {
+  } 
+  else {
     return FALSE; 
   }
 }
@@ -1028,15 +1042,16 @@ function addGroup($groupName) {
  */
 function editGroup($groupId, $groupName) {
   $groupURI = makeGroupURI($groupId);
-  $return = doServerCall($groupURI,createGroupXML($groupURI, $groupName) , 'PUT');
+  $return = doServerCall($groupURI, createGroupXML($groupURI, $groupName) , 'PUT');
   $parsedReturn = simplexml_load_string($return);
   if (!empty($return)) {
-    if (strpos($return,'<')!== FALSE) {
+    if (strpos($return, '<')!== FALSE) {
       $parsedReturn = simplexml_load_string($return);
       if (!empty($parsedReturn->message)) {
         $lastError = $parsedReturn->message;
       }
-    } else {
+    } 
+    else {
       $lastError = $parsedReturn->message;
     }
       return FALSE;
@@ -1053,7 +1068,7 @@ function editGroup($groupId, $groupName) {
  */
 function deleteGroup($groupId) {
   $groupURI = makeGroupURI($groupId);
-  $return = doServerCall($groupURI,'','DELETE');
+  $return = doServerCall($groupURI, '', 'DELETE');
   if (!empty($return)) {
     return FALSE;
   }
@@ -1088,7 +1103,7 @@ function civicrm_constant_contact_new_account_form() {
   $form['SiteOwnerLoginName'] = array(
     '#type' => 'textfield',
     '#title' => t('New Constant Contact Username'),
-    '#default_value' => variable_get('civicrm_constant_contact_username',''),
+    '#default_value' => variable_get('civicrm_constant_contact_username', ''),
     '#description' => t("The username used to log into Constant Contact"),
     '#required' => TRUE,
   );
@@ -1162,12 +1177,12 @@ function civicrm_constant_contact_new_account_form() {
 }
 
 function civicrm_constant_contact_new_account_form_validate ($form, &$form_state) {
-  preg_match('(`|!|~|#|%|^)',$form_state['values']['SiteOwnerPassword'],$out);
+  preg_match('(`|!|~|#|%|^)', $form_state['values']['SiteOwnerPassword'], $out);
   if ( !empty($out[0]) ) {
-    drupal_set_message('The password cannot contain the characters ` ! ~ # % ^ ','error',FALSE);
+    drupal_set_message('The password cannot contain the characters ` ! ~ # % ^ ', 'error', FALSE);
   }
   if (strlen($form_state['values']['SiteOwnerPassword']) < 7 ) {
-    drupal_set_message('The passwrd must be at least 6 characters','error',FALSE);
+    drupal_set_message('The passwrd must be at least 6 characters', 'error', FALSE);
   }
 }
 
@@ -1192,7 +1207,7 @@ function civicrm_constant_contact_admin_form() {
   $form['civicrm_constant_contact_username'] = array(
     '#type' => 'textfield',
     '#title' => t('Constant Contact Username'),
-    '#default_value' => variable_get('civicrm_constant_contact_username',''),
+    '#default_value' => variable_get('civicrm_constant_contact_username', ''),
     '#description' => t("The username used to log into Constant Contact"),
     '#required' => TRUE,
   );
@@ -1206,14 +1221,14 @@ function civicrm_constant_contact_admin_form() {
   $form['civicrm_constant_contact_apikey'] = array(
     '#type' => 'textfield',
     '#title' => t('Constant Contact API Key'),
-    '#default_value' => variable_get('civicrm_constant_contact_apikey',''),
+    '#default_value' => variable_get('civicrm_constant_contact_apikey', ''),
     '#description' => t("The API Key used to log into Constant Contact (confirm)"),
     '#required' => TRUE,
   );
   $form['civicrm_constant_contact_apipath'] = array(
     '#type' => 'textfield',
     '#title' => t('Constant Contact API Path'),
-    '#default_value' => variable_get('civicrm_constant_contact_apipath',''),
+    '#default_value' => variable_get('civicrm_constant_contact_apipath', ''),
     '#description' => t("The API Path used to log into Constant Contact (confirm)"),
     '#required' => TRUE,
   );
@@ -1259,7 +1274,7 @@ function civicrm_constant_contact_menu() {
 */
 function civicrm_constant_contact_display($msg, $level = 'info') {
   if (user_access('access administration pages')) {
-    drupal_set_message(t($msg),$level);
+    drupal_set_message(t($msg), $level);
   }
 }
 
@@ -1287,8 +1302,8 @@ function cc_log($msg, $level = WATCHDOG_DEBUG, $type = 'CiviCRM-ConstantContact'
 * @return Built URI for the constant contact group
 */
 function makeGroupURI($groupId) {
-  $userName = variable_get('civicrm_constant_contact_username',"");
-  $uri = "http://api.constantcontact.com/ws/customers/".$userName."/lists/".$groupId;
+  $userName = variable_get('civicrm_constant_contact_username', "");
+  $uri = "http://api.constantcontact.com/ws/customers/". $userName ."/lists/". $groupId;
   return $uri;
 }
 
@@ -1304,10 +1319,10 @@ function getContactDetails($objectId) {
   require_once 'CRM/Contact/BAO/GroupContact.php'; 
   require_once 'CRM/Core/Permission.php';
   //Gather the contact details
-  $fname = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',$objectId,'first_name');
-  $lname = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',$objectId,'last_name');
-  $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',$objectId,'job_title');
-  $org = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',$objectId,'organization_name');
+  $fname = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $objectId, 'first_name');
+  $lname = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $objectId, 'last_name');
+  $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $objectId, 'job_title');
+  $org = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $objectId, 'organization_name');
   /*$address_array = civicrm_constant_contact_get_primary_address($objectId);
     $street = $address_array['street_address'];
     $street2 = $address_array['supplemental_address_1'];
@@ -1321,7 +1336,8 @@ function getContactDetails($objectId) {
   $constant_contact_group_ids = array();
   if ( sizeof( $group_titles_by_id ) <= 0 ) {
   //do nothing
-  } else {
+  } 
+  else {
     foreach ($group_titles_by_id as $group_id=>$group_title) {
       $civi_id = $group_title['group_id'];
       $cc_group_id = get_cc_group_id( $civi_id );
@@ -1370,91 +1386,79 @@ function get_cc_group_id( $group_id ) {
   return $constant_contact_group_id;
 }
 
-/*	Begin bulk updater */
-
-function contact_upload_finished( $success, $results, $operations )
-{
-	if ($success)
-	{
-		$message = 'Finished successfully.';
-		$message .= '<br> Processed ' . count($results['names']) . ' records.<br>';
-	}
-	else
-	{
-		$error_operation = reset($operations);
-		$message = 'An error occurred while processing ' . $error_operation[0] . ' with arg ' . print_r($error_operation[1], TRUE);
-	}
-	drupal_set_message($message);
+/*  Begin bulk updater */
+
+function contact_upload_finished( $success, $results, $operations ) {
+  if ($success) {
+    $message = 'Finished successfully.';
+    $message .= '<br> Processed ' . count($results['names']) . ' records.<br>';
+  }
+  else {
+    $error_operation = reset($operations);
+    $message = 'An error occurred while processing ' . $error_operation[0] . ' with arg ' . print_r($error_operation[1], TRUE);
+  }
+  drupal_set_message($message);
 }
 
-function contact_upload( $members, $cc_url, &$context )
-{
-
-	define('APIKEY', variable_get('civicrm_constant_contact_apikey', NULL));
-	define('USERNAME', variable_get('civicrm_constant_contact_username', NULL));
-	define('PASSWORD', variable_get('civicrm_constant_contact_password', NULL));
-	include_once('ctctWrapper.php');
-	civicrm_initialize();
-
-	if ( !isset($context['sandbox']['progress']) )
-	{
-		$context['sandbox']['progress'] = 0;
-		$context['sandbox']['max'] = 50;
-	}
-
-	$start = count($context['results']['names']);
-
-	if ( $start == count($members) )
-	{
-		$context['finished'] = 1;
-		return;
-	}
-
-	$contact_id = $members[$start];
-	$contactDetails = getContactDetails($contact_id);
-	$contactEmail = civicrm_constant_contact_get_primary_email($contact_id);
-	if (!empty($contactEmail))
-	{
-		$contact = new Contact();
-		$contact->setEmailAddress($contactEmail);
-		$contact->setFirstName($contactDetails['first_name']);
-		$contact->setLastName($contactDetails['last_name']);
-		$contact->setLists( $cc_url );
-		$context['results']['names'][] = $contact;
-
-		$context['message'] = 'Now processing ' . $contactDetails['first_name'] . ' ' . $contactDetails['last_name'];
-		$names = $context['results']['names'];
-		if ( !empty($names) )
-		{
-			$contact = $context['results']['names'][$start];
-			$col = new ContactsCollection();
-			$var = $col->createContact($contact);
-		}
-	}
-	else
-	{
-		$context['results']['names'][] = 'placeholder';
-		$context['message'] = 'Skipping record ' . $contact_id;
-	}
-
-	$context['sandbox']['progress']++;
-
-	if ( $context['sandbox']['progress'] != $context['sandbox']['max'] )
-	{
-		$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
-	}
+function contact_upload( $members, $cc_url, &$context ) {
+
+  define('APIKEY', variable_get('civicrm_constant_contact_apikey', NULL));
+  define('USERNAME', variable_get('civicrm_constant_contact_username', NULL));
+  define('PASSWORD', variable_get('civicrm_constant_contact_password', NULL));
+  include_once('ctctWrapper.php');
+  civicrm_initialize();
+
+  if ( !isset($context['sandbox']['progress']) ) {
+    $context['sandbox']['progress'] = 0;
+    $context['sandbox']['max'] = 50;
+  }
+
+  $start = count($context['results']['names']);
+
+  if ( $start == count($members) ) {
+    $context['finished'] = 1;
+    return;
+  }
+
+  $contact_id = $members[$start];
+  $contactDetails = getContactDetails($contact_id);
+  $contactEmail = civicrm_constant_contact_get_primary_email($contact_id);
+  if (!empty($contactEmail)) {
+    $contact = new Contact();
+    $contact->setEmailAddress($contactEmail);
+    $contact->setFirstName($contactDetails['first_name']);
+    $contact->setLastName($contactDetails['last_name']);
+    $contact->setLists( $cc_url );
+    $context['results']['names'][] = $contact;
+
+    $context['message'] = 'Now processing ' . $contactDetails['first_name'] . ' ' . $contactDetails['last_name'];
+    $names = $context['results']['names'];
+    if ( !empty($names) ) {
+      $contact = $context['results']['names'][$start];
+      $col = new ContactsCollection();
+      $var = $col->createContact($contact);
+    }
+  }
+  else {
+    $context['results']['names'][] = 'placeholder';
+    $context['message'] = 'Skipping record ' . $contact_id;
+  }
+
+  $context['sandbox']['progress']++;
+
+  if ( $context['sandbox']['progress'] != $context['sandbox']['max'] ) {
+    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
+  }
 }
 
-function test_bu()
-{
-	$gm = array();
-	for($i = 0; $i<700; $i++)
-	{
-		$gm[$i+1158] = $i+1158;
-	}
-	$a = bulk_update($gm, 1);
-	print "<BR> Got to end: <BR>";
-	//dpr($a);
+function test_bu() {
+  $gm = array();
+  for ($i = 0; $i<700; $i++) {
+    $gm[$i+1158] = $i+1158;
+  }
+  $a = bulk_update($gm, 1);
+  print "<BR> Got to end: <BR>";
+  //dpr($a);
 }
 
 /**
@@ -1465,32 +1469,31 @@ function test_bu()
 *
 * @return TRUE for success, FALSE if error
 */
-function bulk_update($group_members, $cc_group_id)
-{
-	$cc_url = makeGroupURI($cc_group_id);
-	$count = count($group_members);
-	$group_members = array_keys($group_members);  //the original writer used the keys to hold contact ids
-
-	$batch = array(
-		'operations' => array(),
-		'finished' => 'contact_upload_finished',
-		'title' => 'processing contacts',
-		'init_message' => t('Contacts processing'),
-		'progress_message' => t('Processed @current out of @total'),
-		'error_message' => t('Error...'),);
-
-	$handled = 0;
-	while($handled < $count)
-	{
-		$batch['operations'][] = array('contact_upload', array($group_members, $cc_url));
-		$handled += 50;
-	}
-
-	batch_set($batch);
-	batch_process('/');
+function bulk_update($group_members, $cc_group_id) {
+  $cc_url = makeGroupURI($cc_group_id);
+  $count = count($group_members);
+  $group_members = array_keys($group_members);  //the original writer used the keys to hold contact ids
+
+  $batch = array(
+    'operations' => array(),
+    'finished' => 'contact_upload_finished',
+    'title' => 'processing contacts',
+    'init_message' => t('Contacts processing'),
+    'progress_message' => t('Processed @current out of @total'),
+    'error_message' => t('Error...'),
+    );
+
+  $handled = 0;
+  while ($handled < $count) {
+    $batch['operations'][] = array('contact_upload', array($group_members, $cc_url));
+    $handled += 50;
+  }
+
+  batch_set($batch);
+  batch_process('/');
 }//function
 
-	/* end bulk updater */
+  /* end bulk updater */
 
 /**
  * civiconstantconstant_cron
@@ -1507,9 +1510,9 @@ function civicrm_constant_contact_cron() {
   require_once $civicrm_root . '/CRM/Contact/BAO/GroupContact.php';
   // Call the function to go out an update all of the smart groups.
   updateSmartGroups(); 
-  $username = variable_get('civicrm_constant_contact_username',"");
+  $username = variable_get('civicrm_constant_contact_username', "");
   $providers_username = "providerscouncil";
-  $url = "https://api.constantcontact.com/ws/customers/".$username."/lists/do-not-mail/members";
+  $url = "https://api.constantcontact.com/ws/customers/". $username ."/lists/do-not-mail/members";
   $xml_string = doServerCall( $url );
   if ( !$xml_string ) {
     cc_log("The Do Not Mail list could not be retrieved from Constant Contact. Opted out contacts were not updated in CiviCRM.", WATCHDOG_ERROR);
@@ -1518,7 +1521,7 @@ function civicrm_constant_contact_cron() {
   $xml_obj = simplexml_load_string($xml_string);
   $email_str = "";
   foreach ($xml_obj->entry as $member) {
-    $email_str.="'".(string)$member->content->ContactListMember->EmailAddress."',";
+    $email_str.="'" .(string)$member->content->ContactListMember->EmailAddress. "',";
   }
   $email_str = trim( $email_str, "," );
   $sql = "
@@ -1529,7 +1532,7 @@ function civicrm_constant_contact_cron() {
          FROM civicrm_email
          WHERE email IN ($email_str) AND is_primary=1)";
   //civiconstantcron_logger( $sql );
-  cc_log( "The Constant Contact members with email addresses: ".$email_str." have been marked as opted out in CiviCRM." );
+  cc_log( "The Constant Contact members with email addresses: ". $email_str ." have been marked as opted out in CiviCRM." );
   cc_log( "Opted out contacts have successfully been synchronized between Constant Contact and CiviCRM." );
   return CRM_Core_DAO::executeQuery( $sql );
 }
@@ -1550,7 +1553,7 @@ function  updateSmartGroups() {
   $sync_field = $settings['civicrm_constant_contact_group_sync_field']['field_name'];
   // get the smart groups that are set to be synced
   $smart_groups_sql = "
-    SELECT c.entity_id AS smart_group_id, c.$cc_id_field AS smart_cc_group_id
+    SELECT c.entity_id AS smart_group_id, c. $cc_id_field AS smart_cc_group_id
     FROM civicrm_group g, $table c
     WHERE (g.saved_search_id IS NOT NULL AND c.entity_id=g.id) AND $sync_field='1'";
   $data = CRM_Core_DAO::executeQuery( $smart_groups_sql );
@@ -1589,8 +1592,9 @@ function  updateSmartGroups() {
        * and that in our situation, we wouldn't be expected to code special conditions.
        */
       bulk_update( $smart_group['members'], $smart_group['cc_group_id'] );
-    } else {
-      cc_log( "The smart group with id ".$smart_group['group_id']." failed to be recreated in Constant Contact. Please unsync and resync the group in CiviCRM.", WATCHDOG_ERROR );
+    } 
+    else {
+      cc_log( "The smart group with id ". $smart_group['group_id'] ." failed to be recreated in Constant Contact. Please unsync and resync the group in CiviCRM.", WATCHDOG_ERROR );
     }
   }
   cc_log( 'Smart groups successfully updated in Constant Contact' );
@@ -1630,24 +1634,25 @@ function recreateGroup( $group_id, $cc_group_id, $table, $cc_group_id_field, $sy
         WHERE entity_id=$group_id";
   CRM_Core_DAO::executeQuery( $update_sql, CRM_Core_DAO::$_NULLArray );
     return $constant_contact_group_id;
-  } else {
+  } 
+  else {
     $update_sql = "
         UPDATE $table
         SET $cc_group_id_field='', $sync_field=''
         WHERE entity_id=$group_id";
     CRM_Core_DAO::executeQuery( $update_sql, CRM_Core_DAO::$_NULLArray );
-    cc_log("The smart group with id ".$smart_group['group_id']." failed to be recreated in Constant Contact. Please unsync and resync the group in CiviCRM.", WATCHDOG_ERROR );
+    cc_log("The smart group with id ". $smart_group['group_id'] ." failed to be recreated in Constant Contact. Please unsync and resync the group in CiviCRM.", WATCHDOG_ERROR );
     return FALSE;
   }
 }
 
-function _civicrm_constant_contact_ctctWrapper_file_check () {
+function _civicrm_constant_contact_ctctWrapper_file_check() {
   $module_dir = drupal_get_path('module', 'civicrm_constant_contact');
   if (!file_exists($module_dir . '/ctctWrapper.php')) {
     $options = array( 'attributes' =>
-                      array('target'=>'_blank'),
+                      array('target' => '_blank'),
                     );
-    drupal_set_message(t('The Constant Contact PHP library is missing please'). l(' download','http://sourceforge.net/projects/ctctphplib',$options) . t(" it and follow installation instruction in the README.txt file."), "error");
+    drupal_set_message(t('The Constant Contact PHP library is missing please'). l(' download', 'http://sourceforge.net/projects/ctctphplib', $options) . t(" it and follow installation instruction in the README.txt file."), "error");
   }
   
 }
