diff --git a/includes/mimemail.incoming.inc b/includes/mimemail.incoming.inc
index 57a5b12..f58e32a 100644
--- a/includes/mimemail.incoming.inc
+++ b/includes/mimemail.incoming.inc
@@ -11,7 +11,7 @@
  * This function enables messages to be sent via POST or some other RFC822
  * source input (e.g. directly from a mail server).
  *
- * @return
+ * @return array
  *   The POSTed message.
  */
 function mimemail_post() {
@@ -29,7 +29,7 @@ function mimemail_post() {
 /**
  * Parses an externally received message.
  *
- * @param $message
+ * @param string $message
  *   The message to parse.
  */
 function mimemail_incoming($message) {
diff --git a/includes/mimemail.mail.inc b/includes/mimemail.mail.inc
index 042068a..04774fa 100644
--- a/includes/mimemail.mail.inc
+++ b/includes/mimemail.mail.inc
@@ -12,11 +12,11 @@ class MimeMailSystem implements MailSystemInterface {
   /**
    * Concatenate and wrap the e-mail body for HTML mails.
    *
-   * @param $message
-   *   A message array, as described in hook_mail_alter() with optional parameters
-   *   described in mimemail_prepare_message().
+   * @param array $message
+   *   A message array, as described in hook_mail_alter() with optional
+   *   parameters described in mimemail_prepare_message().
    *
-   * @return
+   * @return array
    *   The formatted $message.
    */
   public function format(array $message) {
@@ -44,11 +44,11 @@ class MimeMailSystem implements MailSystemInterface {
   /**
    * Send an HTML e-mail message, using Drupal variables and default settings.
    *
-   * @param $message
-   *   A message array, as described in hook_mail_alter() with optional parameters
-   *   described in mimemail_prepare_message().
+   * @param array $message
+   *   A message array, as described in hook_mail_alter() with optional
+   *   parameters described in mimemail_prepare_message().
    *
-   * @return
+   * @return boolean
    *   TRUE if the mail was successfully accepted, otherwise FALSE.
    */
   public function mail(array $message) {
diff --git a/includes/mimemail.rules.inc b/includes/mimemail.rules.inc
index 340b186..ede96ac 100644
--- a/includes/mimemail.rules.inc
+++ b/includes/mimemail.rules.inc
@@ -77,7 +77,7 @@ function rules_action_mimemail_to_users_of_role($roles, $from_name = NULL, $from
   else {
     $rids = implode(',', $roles);
     // Avoid sending emails to members of two or more target role groups.
-    $result = db_query('SELECT DISTINCT u.mail FROM {users} u INNER JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid IN ('. $rids .')');
+    $result = db_query('SELECT DISTINCT u.mail FROM {users} u INNER JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid IN (' . $rids . ')');
   }
 
   $params = array(
@@ -111,4 +111,3 @@ function rules_action_mimemail_to_users_of_role($roles, $from_name = NULL, $from
 /**
  * @}
  */
-
diff --git a/mimemail.inc b/mimemail.inc
index f01259f..e19bebd 100644
--- a/mimemail.inc
+++ b/mimemail.inc
@@ -8,22 +8,26 @@
  */
 
 /**
- * Attempts to RFC822-compliant headers for the mail message or its MIME parts
- * TODO could use some enhancement and stress testing
+ * Attempts to RFC822-compliant headers for the mail message or its MIME parts.
  *
- * @param $headers An array of headers
- * @return header string
+ * @TODO could use some enhancement and stress testing.
+ *
+ * @param array $headers
+ *   An array of headers.
+ *
+ * @return string
+ *   Header string.
  */
 function mimemail_rfc_headers($headers) {
   $header = '';
   $crlf = variable_get('mimemail_crlf', MAIL_LINE_ENDINGS);
   foreach ($headers as $key => $value) {
     $key = trim($key);
-    // collapse spaces and get rid of newline characters
+    // Collapse spaces and get rid of newline characters.
     $value = preg_replace('/(\s+|\n|\r|^\s|\s$)/', ' ', $value);
-    //fold headers if they're too long
+    // Fold headers if they're too long.
     if (drupal_strlen($value) > 60) {
-      //if there's a semicolon, use that to separate
+      // If there's a semicolon, use that to separate.
       if (count($array = preg_split('/;\s*/', $value)) > 1) {
         $value = trim(join(";$crlf    ", $array));
       }
@@ -39,8 +43,11 @@ function mimemail_rfc_headers($headers) {
 /**
  * Gives useful defaults for standard email headers.
  *
- * @param $headers An array of headers
- * @return header string.
+ * @param array $headers
+ *   An array of headers.
+ *
+ * @return array
+ *   Header string.
  */
 function mimemail_headers($headers, $from = NULL) {
   $default_from = variable_get('site_mail', ini_get('sendmail_from'));
@@ -77,22 +84,25 @@ function mimemail_headers($headers, $from = NULL) {
 /**
  * Extracts links to local images from html documents.
  *
- * @param $html html text
- * @param $name document name
+ * @param string $html
+ *   Html text.
  *
- * @return an array of arrays
- *            array(array(
- *                     'name' => document name
- *                     'content' => html text, local image urls replaced by Content-IDs,
- *                     'Content-Type' => 'text/html; charset=utf-8')
- *                  array(
- *                     'name' => file name,
- *                     'file' => reference to local file,
- *                     'Content-ID' => generated Content-ID,
- *                     'Content-Type' => derived using mime_content_type
- *                                       if available, educated guess otherwise
- *                     )
- *                  )
+ * @return array
+ *   An array of arrays:
+ *     array(
+ *       array(
+ *         'name' => document name
+ *         'content' => html text, local image urls replaced by Content-IDs,
+ *         'Content-Type' => 'text/html; charset=utf-8'
+ *       ),
+ *       array(
+ *       'name' => file name,
+ *       'file' => reference to local file,
+ *       'Content-ID' => generated Content-ID,
+ *       'Content-Type' => derived using mime_content_type if available,
+ *   educated guess otherwise
+ *       ),
+ *    )
  */
 function mimemail_extract_files($html) {
   $pattern = '/(<link[^>]+href=[\'"]?|<object[^>]+codebase=[\'"]?|@import |[\s]src=[\'"]?)([^\'>"]+)([\'"]?)/mis';
@@ -110,7 +120,7 @@ function mimemail_extract_files($html) {
 }
 
 /**
- * Callback for preg_replace_callback()
+ * Callback for preg_replace_callback().
  */
 function _mimemail_replace_files($matches) {
   return stripslashes($matches[1]) . _mimemail_file($matches[2]) . stripslashes($matches[3]);
@@ -119,13 +129,14 @@ function _mimemail_replace_files($matches) {
 /**
  * Helper function to extract local files.
  *
- * @param $url
+ * @param string $url
  *   The URI or the absolute URL to the file.
- * @param $content
+ * @param string $content
  *   The actual file content.
  *
- * @return
- *   The Content-ID and/or an array of the files on success or the URL on failure. 
+ * @return mixed
+ *   The Content-ID and/or an array of the files on success or the URL on
+ *   failure.
  */
 function _mimemail_file($url = NULL, $content = NULL, $name = '', $type = '', $disposition = 'related') {
   static $files = array();
@@ -156,11 +167,17 @@ function _mimemail_file($url = NULL, $content = NULL, $name = '', $type = '', $d
 
   if (isset($file) && (@is_file($file) || $content)) {
 
-    if (!$name) $name = (@is_file($file)) ? basename($file) : 'attachment.dat';
-    if (!$type) $type = ($name) ? file_get_mimetype($name) : file_get_mimetype($file);
+    if (!$name) {
+      $name = (@is_file($file)) ? basename($file) : 'attachment.dat';
+    }
+    if (!$type) {
+      $type = ($name) ? file_get_mimetype($name) : file_get_mimetype($file);
+    }
 
     // Prevent duplicate items.
-    if (isset($filenames[$name])) return 'cid:' . $filenames[$name];
+    if (isset($filenames[$name])) {
+      return 'cid:' . $filenames[$name];
+    }
     $content_id = md5($name) . '@' . $_SERVER['HTTP_HOST'];
 
     $new_file = array(
@@ -188,10 +205,10 @@ function _mimemail_file($url = NULL, $content = NULL, $name = '', $type = '', $d
 }
 
 /**
+ * Build a multipart body.
  *
- * @param $parts
- *        an array of parts to be included
- *        each part is itself an array:
+ * @param array $parts
+ *   Array of parts to be included each part is itself an array:
  *        array(
  *          'name' => $name the name of the attachement
  *          'content' => $content textual content
@@ -207,16 +224,16 @@ function _mimemail_file($url = NULL, $content = NULL, $name = '', $type = '', $d
  *                                         8bit for other content.
  *          'Content-ID' => optional, for in-mail references to attachements.
  *        )
- *        name is mandatory, one of content and file is required,
- *        they are mutually exclusive.
+ *   name is mandatory, one of content and file is required, they are mutually
+ *   exclusive.
  *
- * @param $content_type
- *        Content-Type for the combined message, optional, default: multipart/mixed
+ * @param string $content_type
+ *   Content-Type for the combined message, optional, default: multipart/mixed.
  *
- * @return
- *     an array containing the elements 'header' and 'body'.
- *     'body' is the mime encoded multipart body of a mail.
- *     'headers' is an array that includes some headers for the mail to be sent.
+ * @return array
+ *   Array containing the elements 'header' and 'body'.
+ *   'body' is the mime encoded multipart body of a mail.
+ *   'headers' is an array that includes some headers for the mail to be sent.
  */
 function mimemail_multipart_body($parts, $content_type = 'multipart/mixed; charset=utf-8', $sub_part = FALSE) {
   $boundary = md5(uniqid($_SERVER['REQUEST_TIME']));
@@ -251,8 +268,8 @@ function mimemail_multipart_body($parts, $content_type = 'multipart/mixed; chars
       $part_headers['Content-Transfer-Encoding'] = $part['Content-Transfer-Encoding'];
     }
 
-    // mail content provided as a string
     if (isset($part['content']) && $part['content']) {
+      // Mail content provided as a string.
       if (!isset($part['Content-Transfer-Encoding'])) {
         $part_headers['Content-Transfer-Encoding'] = '8bit';
       }
@@ -262,9 +279,9 @@ function mimemail_multipart_body($parts, $content_type = 'multipart/mixed; chars
         $part_headers['Content-Disposition'] .= '; filename="' . $part['name'] . '"';
       }
 
-    // mail content references in a filename
     }
     else {
+      // Mail content references in a filename.
       if (!isset($part['Content-Transfer-Encoding'])) {
         $part_headers['Content-Transfer-Encoding'] = 'base64';
       }
@@ -281,7 +298,7 @@ function mimemail_multipart_body($parts, $content_type = 'multipart/mixed; chars
       if (isset($part['file'])) {
         $file = (is_file($part['file'])) ? file_get_contents($part['file']) : $part['file'];
         $part_body = chunk_split(base64_encode($file), 76, variable_get('mimemail_crlf', "\n"));
-        
+
       }
     }
 
@@ -295,22 +312,28 @@ function mimemail_multipart_body($parts, $content_type = 'multipart/mixed; chars
 }
 
 /**
- * Callback for preg_replace_callback()
+ * Callback for preg_replace_callback().
  */
 function _mimemail_expand_links($matches) {
   return $matches[1] . _mimemail_url($matches[2]);
 }
 
 /**
- * Generate a multipart message body with a text alternative for some html text
- * @param $body An HTML message body
- * @param $subject The message subject
- * @param $plaintext Whether the recipient prefers plaintext-only messages (default false)
+ * Generate a multipart message body with a text alternative for some html text.
+ *
+ * @param string $body
+ *   An HTML message body.
+ * @param string $subject
+ *   The message subject.
+ * @param boolean $plain
+ *   Whether the recipient prefers plaintext-only messages (default false).
+ * @param string $plaintext
+ *   The plaintext message.
  *
- * @return
- *     an array containing the elements 'header' and 'body'.
- *     'body' is the mime encoded multipart body of a mail.
- *     'headers' is an array that includes some headers for the mail to be sent.
+ * @return array
+ *   Array containing the elements 'header' and 'body'.
+ *   'body' is the mime encoded multipart body of a mail.
+ *   'headers' is an array that includes some headers for the mail to be sent.
  *
  * The first mime part is a multipart/alternative containing mime-encoded
  * sub-parts for HTML and plaintext.  Each subsequent part is the required
@@ -333,11 +356,11 @@ function mimemail_html_body($body, $subject, $plain = FALSE, $plaintext = NULL,
         'headers' => array('Content-Type' => 'text/plain; charset=utf-8'),
       );
     }
-    // Plain mail with attachement.
+    // Plain mail with attachment.
     else {
       $content_type = 'multipart/mixed';
       $parts = array(array(
-      'content' => $plaintext,
+        'content' => $plaintext,
         'Content-Type' => 'text/plain; charset=utf-8',
       ));
     }
@@ -347,7 +370,7 @@ function mimemail_html_body($body, $subject, $plain = FALSE, $plaintext = NULL,
 
     $plaintext_part = array('Content-Type' => 'text/plain; charset=utf-8', 'content' => $plaintext);
 
-    //expand all local links
+    // Expand all local links.
     $pattern = '/(<a[^>]+href=")([^"]*)/mi';
     $body = preg_replace_callback($pattern, '_mimemail_expand_links', $body);
 
@@ -379,6 +402,15 @@ function mimemail_html_body($body, $subject, $plain = FALSE, $plaintext = NULL,
   return mimemail_multipart_body($parts, $content_type);
 }
 
+/**
+ * Parses a message into its parts.
+ *
+ * @param string $message
+ *   The message to parse.
+ *
+ * @return array
+ *   The parts of the message.
+ */
 function mimemail_parse($message) {
   // Provides a "headers", "content-type" and "body" element.
   $mail = mimemail_parse_headers($message);
@@ -399,7 +431,7 @@ function mimemail_parse($message) {
     $part = mimemail_parse_headers($part_body);
     $sub_parts = mimemail_parse_boundary($part);
 
-    // Content is encoded in a multipart/alternative section
+    // Content is encoded in a multipart/alternative section.
     if (count($sub_parts) > 1) {
       foreach ($sub_parts as $j => $sub_part_body) {
         $sub_part = mimemail_parse_headers($sub_part_body);
@@ -426,7 +458,7 @@ function mimemail_parse($message) {
     }
   }
 
-  // Make sure our text and html parts are accounted for
+  // Make sure our text and html parts are accounted for.
   if (isset($mail['html']) && !isset($mail['text'])) {
     $mail['text'] = preg_replace('|<style.*</style>|mis', '', $mail['html']);
     $mail['text'] = drupal_html_to_text($mail['text']);
@@ -444,8 +476,8 @@ function mimemail_parse($message) {
   return $mail;
 }
 
-/*
- * Split a multi-part message using mime boundaries
+/**
+ * Split a multi-part message using mime boundaries.
  */
 function mimemail_parse_boundary($part) {
   $m = array();
@@ -457,8 +489,8 @@ function mimemail_parse_boundary($part) {
   return array($part['body']);
 }
 
-/*
- * Split a message (or message part) into its headers and body section
+/**
+ * Split a message (or message part) into its headers and body section.
  */
 function mimemail_parse_headers($message) {
   // Split out body and headers.
@@ -471,9 +503,9 @@ function mimemail_parse_headers($message) {
 
   $headers = array();
   foreach (explode("\n", trim($hdr)) as $row) {
-    $split = strpos( $row, ':' );
+    $split = strpos($row, ':');
     $name = trim(drupal_substr($row, 0, $split));
-    $val  = trim(drupal_substr($row, $split+1));
+    $val = trim(drupal_substr($row, $split + 1));
     $headers[$name] = $val;
   }
 
@@ -482,8 +514,8 @@ function mimemail_parse_headers($message) {
   return array('headers' => $headers, 'body' => $body, 'content-type' => $type);
 }
 
-/*
- * Return a decoded mime part in UTF8
+/**
+ * Return a decoded mime part in UTF8.
  */
 function mimemail_parse_content($part) {
   $content = $part['body'];
@@ -494,10 +526,13 @@ function mimemail_parse_content($part) {
       case 'base64':
         $content = base64_decode($content);
         break;
+
       case 'quoted-printable':
         $content = quoted_printable_decode($content);
         break;
-      case '7bit':  // 7bit is the RFC default
+
+      // 7bit is the RFC default.
+      case '7bit':
         break;
     }
   }
@@ -510,7 +545,7 @@ function mimemail_parse_content($part) {
   return $content;
 }
 
-/*
+/**
  * Convert a mime part into a file array.
  */
 function mimemail_parse_attachment($part) {
@@ -530,11 +565,13 @@ function mimemail_parse_attachment($part) {
 }
 
 /**
- * Helper function to format urls
+ * Helper function to format urls.
  *
- * @param $url an url
+ * @param string $url
+ *   An url.
  *
- * @return an absolute url, sans mailto:
+ * @return string
+ *   An absolute url, sans mailto:.
  */
 function _mimemail_url($url, $embed_file = NULL) {
   global $base_url;
@@ -552,10 +589,12 @@ function _mimemail_url($url, $embed_file = NULL) {
     return $url;
   }
 
-  $url = preg_replace( '!^' . base_path() . '!', '', $url, 1);
+  $url = preg_replace('!^' . base_path() . '!', '', $url, 1);
 
   // If we're processing to embed the file, we're done here so return.
-  if ($embed_file) return $url;
+  if ($embed_file) {
+    return $url;
+  }
 
   if (!preg_match('!^\?q=*!', $url)) {
     $strip_clean = TRUE;
@@ -600,7 +639,9 @@ function _mimemail_url($url, $embed_file = NULL) {
   $url = url($path, $options);
 
   // If url() added a ?q= where there should not be one, remove it.
-  if (isset($strip_clean) && $strip_clean) $url = preg_replace('!\?q=!', '', $url);
+  if (isset($strip_clean) && $strip_clean) {
+    $url = preg_replace('!\?q=!', '', $url);
+  }
 
   $url = str_replace('+', '%2B', $url);
   return $url;
@@ -608,12 +649,13 @@ function _mimemail_url($url, $embed_file = NULL) {
 
 /**
  * Formats an address string.
- * 
+ *
  * @todo: could use some enhancement and stress testing.
  *
- * @param $address
+ * @param mixed $address
  *   A user object, a text email address or an array containing name, mail.
- * @return
+ *
+ * @return string|FALSE
  *   A formatted address string or FALSE.
  */
 function mimemail_address($address) {
diff --git a/mimemail.install b/mimemail.install
index 0521a07..9e9ec42 100644
--- a/mimemail.install
+++ b/mimemail.install
@@ -34,7 +34,7 @@ function mimemail_disable() {
 }
 
 /**
- * Implementation of hook_uninstall()
+ * Implements hook_uninstall().
  */
 function mimemail_uninstall() {
   $variables = array(
@@ -66,25 +66,26 @@ function mimemail_requirements($phase) {
   if ($phase === 'install' || module_exists('mailsystem')) {
     return array();
   }
+  $t = get_t();
   $args = array(
     '!mailsystem' => url('http://drupal.org/project/mailsystem'),
     '%mailsystem' => 'Mail System',
     '!mimemail' => url('http://drupal.org/project/mimemail'),
     '%mimemail' => 'Mime Mail',
   );
-  if ( module_enable(array('mailsystem'))
+  if (module_enable(array('mailsystem'))
     && module_load_include('module', 'mailsystem')
   ) {
     drupal_set_message(
-      t('The %mailsystem module has been enabled because the %mimemail module now requires it.', $args)
+      $t('The %mailsystem module has been enabled because the %mimemail module now requires it.', $args)
     );
     return array();
   }
   return array(
     'mimemail_mailsystem' => array(
-      'title' => t('%mailsystem module', $args),
-      'value' => t('Not installed'),
-      'description' => t(
+      'title' => $t('%mailsystem module', $args),
+      'value' => $t('Not installed'),
+      'description' => $t(
         'The <a href="!smtp">%mimemail</a> module dependencies have changed.  Please download and install the required <a href="!mailsystem">%mailsystem</a> module, then re-enable the <a href="!mimemail">%mimemail</a> module.', $args
       ),
       'severity' => REQUIREMENT_ERROR,
@@ -102,9 +103,8 @@ function mimemail_update_7000() {
 }
 
 /**
-* Deletes useless variables.
-*/
+ * Deletes useless variables.
+ */
 function mimemail_update_7001() {
   variable_del('mimemail_theme');
 }
-
diff --git a/mimemail.module b/mimemail.module
index 905ebf2..35fc703 100644
--- a/mimemail.module
+++ b/mimemail.module
@@ -293,14 +293,17 @@ function mimemail_rules_action_mail_upgrade($element, RulesPlugin $target) {
 function mimemail_rules_action_mail_to_user_upgrade($element, RulesPlugin $target) {
   switch ($element['#settings']['#argument map']['user']) {
     case 'author':
-        $token = 'node:author';
+      $token = 'node:author';
       break;
+
     case 'author_unchanged':
-        $token = 'node-unchanged:author';
+      $token = 'node-unchanged:author';
       break;
+
     case 'user':
-        $token = 'site:current-user';
+      $token = 'site:current-user';
       break;
+
   }
   $target->settings['to:select'] = $token . ':mail';
   mimemail_rules_action_mail_upgrade($element, $target);
@@ -358,7 +361,7 @@ function mimemail_mail($key, &$message, $params) {
 /**
  * Retreives a list of all available mailer engines.
  *
- * @return
+ * @return array
  *   An array of mailer engine names.
  */
 function mimemail_get_engines() {
@@ -372,11 +375,12 @@ function mimemail_get_engines() {
 /**
  * Implements hook_mailengine().
  *
- * @param $op
+ * @param string $op
  *   The operation to perform on the message.
- * @param $message
+ * @param array $message
  *   The message to perform the operation on.
- * @return
+ *
+ * @return boolean
  *   Returns TRUE if the operation was successful or FALSE if it was not.
  */
 function mimemail_mailengine($op, $message = array()) {
@@ -392,11 +396,18 @@ function mimemail_mailengine($op, $message = array()) {
     case 'settings':
       // Not implemented.
       break;
+
     case 'multiple':
     case 'single':
     case 'send':
       // Default values.
-      $default = array('to' => '', 'subject' => '', 'body' => '', 'from' => '', 'headers' => '');
+      $default = array(
+        'to' => '',
+        'subject' => '',
+        'body' => '',
+        'from' => '',
+        'headers' => '',
+      );
       $message = array_merge($default, $message);
 
       // If 'Return-Path' isn't already set in php.ini, we pass it separately
@@ -429,15 +440,15 @@ function mimemail_mailengine($op, $message = array()) {
             ini_set('sendmail_from', $old_from);
           }
           else {
-            // On most non-Windows systems, the "-f" option to the sendmail command
-            // is used to set the Return-Path.
+            // On most non-Windows systems, the "-f" option to the sendmail
+            // command is used to set the Return-Path.
             $result = @mail($to, $subject, $body, $headers, '-f' . $return_path) && $result;
           }
         }
         else {
-          // The optional $additional_parameters argument to mail() is not allowed
-          // if safe_mode is enabled. Passing any value throws a PHP warning and
-          // makes mail() return FALSE.
+          // The optional $additional_parameters argument to mail() is not
+          // allowed if safe_mode is enabled. Passing any value throws a PHP
+          // warning and makes mail() return FALSE.
           $result = @mail($to, $subject, $body, $headers) && $result;
         }
       }
@@ -451,11 +462,12 @@ function mimemail_mailengine($op, $message = array()) {
 /**
  * Prepares the message for sending.
  *
- * @param $message
- *   An array containing the message data. The optional parameters in 'params' are:
+ * @param array $message
+ *   An array containing the message data.
+ *   The optional parameters in 'params' are:
  *   - 'plain':
- *      Whether to send the message as plaintext only or HTML. If evaluates to TRUE,
- *      then the message will be sent as plaintext.
+ *      Whether to send the message as plaintext only or HTML. If evaluates to
+ *      TRUE, then the message will be sent as plaintext.
  *   - 'plaintext':
  *      Optional plaintext portion of a multipart email.
  *   - 'attachments':
@@ -482,7 +494,7 @@ function mimemail_mailengine($op, $message = array()) {
  *        )
  *      )
  *
- * @return
+ * @return array
  *   The $message array structure containing all details of the message.
  */
 function mimemail_prepare_message($message) {
@@ -520,19 +532,28 @@ function mimemail_prepare_message($message) {
   // Try to determine recipient's text mail preference.
   elseif (is_null($plain)) {
     if (is_object($to) && isset($to->data['mimemail_textonly'])) {
-        $plain = $to->data['mimemail_textonly'];
+      $plain = $to->data['mimemail_textonly'];
     }
     elseif (is_string($to) && valid_email_address($to)) {
       if (is_object($account = user_load_by_mail($to)) && isset($account->data['mimemail_textonly'])) {
         $plain = $account->data['mimemail_textonly'];
-        $to = $account; // Might as well pass the user object to the address function.
+        // Might as well pass the user object to the address function.
+        $to = $account;
       }
     }
   }
 
   $subject = str_replace(array(" \n", "\n"), '', trim(drupal_html_to_text($subject)));
   $key = str_replace('_', '-', $key);
-  $body = theme(array('mimemail_message__' . $key, 'mimemail_message'), array('key' => $key, 'recipient' => $to, 'subject' => $subject, 'body' => $body));
+  $body = theme(
+    array('mimemail_message__' . $key, 'mimemail_message'),
+    array(
+      'key' => $key,
+      'recipient' => $to,
+      'subject' => $subject,
+      'body' => $body,
+    )
+  );
 
   foreach (module_implements('mail_post_process') as $module) {
     $function = $module . '_mail_post_process';
diff --git a/modules/mimemail_action/mimemail_action.module b/modules/mimemail_action/mimemail_action.module
index fdeb8ae..59d431e 100644
--- a/modules/mimemail_action/mimemail_action.module
+++ b/modules/mimemail_action/mimemail_action.module
@@ -6,8 +6,8 @@
  */
 
 /**
-* Implementation of hook_action_info().
-*/
+ * Implements of hook_action_info().
+ */
 function mimemail_action_info() {
   return array(
     'mimemail_send_email_action' => array(
@@ -59,7 +59,17 @@ function mimemail_send_email_action($entity, $context) {
  * Form for configurable Drupal action to send an HTML mail.
  */
 function mimemail_send_email_action_form($context) {
-  $context += array('to' => '', 'cc' => '', 'bcc' => '', 'reply-to' => '', 'subject' => '', 'body' => '', 'format' => filter_fallback_format(), 'plaintext' => '', 'attachments' => '');
+  $context += array(
+    'to' => '',
+    'cc' => '',
+    'bcc' => '',
+    'reply-to' => '',
+    'subject' => '',
+    'body' => '',
+    'format' => filter_fallback_format(),
+    'plaintext' => '',
+    'attachments' => '',
+  );
 
   $form['to'] = array(
     '#type' => 'textfield',
@@ -69,7 +79,7 @@ function mimemail_send_email_action_form($context) {
     '#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'),
     '#required' => TRUE,
   );
- $form['cc'] = array(
+  $form['cc'] = array(
     '#type' => 'textfield',
     '#title' => t('CC Recipient'),
     '#default_value' => $context['cc'],
diff --git a/modules/mimemail_compress/mimemail_compress.inc b/modules/mimemail_compress/mimemail_compress.inc
index e7fb1b2..7b9e341 100644
--- a/modules/mimemail_compress/mimemail_compress.inc
+++ b/modules/mimemail_compress/mimemail_compress.inc
@@ -8,7 +8,7 @@
  */
 
 /**
- * Separate CSS from HTML for processing
+ * Separate CSS from HTML for processing.
  */
 function mimemail_compress_clean_message($message) {
   $parts = array();
@@ -25,7 +25,7 @@ function mimemail_compress_clean_message($message) {
 }
 
 /**
- * Compress HTML and CSS into combined message
+ * Compress HTML and CSS into combined message.
  */
 class mimemail_compress {
   private $html = '';
@@ -37,10 +37,13 @@ class mimemail_compress {
     $this->css  = $css;
   }
 
-  // There are some HTML tags that DOMDocument cannot process,
-  // and will throw an error if it encounters them.
-  // These functions allow you to add/remove them if necessary.
-  // It only strips them from the code (does not remove actual nodes).
+
+  /**
+   * There are some HTML tags that DOMDocument cannot process, and will throw an
+   * error if it encounters them.
+   * These functions allow you to add/remove them if necessary. It only strips
+   * them from the code (does not remove actual nodes).
+   */
   public function add_unprocessable_tag($tag) {
     $this->unprocessable_tags[] = $tag;
   }
@@ -64,12 +67,12 @@ class mimemail_compress {
     }
 
     $err = error_reporting(0);
-    $doc = new DOMDocument;
+    $doc = new DOMDocument();
 
     // Try to set character encoding.
     if (function_exists('mb_convert_encoding')) {
-        $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
-        $doc->encoding= "UTF-8";
+      $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
+      $doc->encoding = "UTF-8";
     }
 
     $doc->strictErrorChecking = FALSE;
@@ -89,7 +92,8 @@ class mimemail_compress {
     foreach ($matches[1] as $key => $selector_string) {
       // If there is a blank definition, skip.
       if (!strlen(trim($matches[2][$key]))) continue;
-      // Else split by commas and duplicate attributes so we can sort by selector precedence.
+      // Else split by commas and duplicate attributes so we can sort by
+      // selector precedence.
       $selectors = explode(',', $selector_string);
       foreach ($selectors as $selector) {
         // Don't process pseudo-classes.
@@ -125,15 +129,19 @@ class mimemail_compress {
       $nodes = $xpath->query($this->css_to_xpath(trim($value['selector'])));
 
       foreach ($nodes as $node) {
-        // If it has a style attribute, get it, process it, and append (overwrite) new stuff.
+        // If it has a style attribute, get it, process it, and append
+        // (overwrite) new stuff.
         if ($node->hasAttribute('style')) {
           // Break it up into an associative array.
           $old_style = $this->css_style_to_array($node->getAttribute('style'));
           $new_style = $this->css_style_to_array($value['attributes']);
-          // New styles overwrite the old styles (not technically accurate, but close enough).
+          // New styles overwrite the old styles (not technically accurate,
+          // but close enough).
           $compressed = array_merge($old_style, $new_style);
           $style = '';
-          foreach ($compressed as $k => $v) $style .= (drupal_strtolower($k) . ':' . $v . ';');
+          foreach ($compressed as $k => $v) {
+            $style .= (drupal_strtolower($k) . ':' . $v . ';');
+          }
         }
         else {
           // Otherwise create a new style.
@@ -143,9 +151,12 @@ class mimemail_compress {
       }
     }
 
-    // This removes styles from your email that contain display:none. You could comment these out if you want.
+    // This removes styles from your email that contain display:none. You could
+    // comment these out if you want.
     $nodes = $xpath->query('//*[contains(translate(@style," ",""), "display:none")]');
-    foreach ($nodes as $node) $node->parentNode->removeChild($node);
+    foreach ($nodes as $node) {
+      $node->parentNode->removeChild($node);
+    }
 
     error_reporting($err);
 
@@ -153,20 +164,24 @@ class mimemail_compress {
   }
 
   private static function sort_selector_precedence($a, $b) {
-    $precedenceA = self::get_selector_precedence($a['selector']);
-    $precedenceB = self::get_selector_precedence($b['selector']);
+    $precedence_a = self::get_selector_precedence($a['selector']);
+    $precedence_b = self::get_selector_precedence($b['selector']);
 
-    // We want these sorted ascendingly so selectors with lesser precedence get processed first and selectors with greater precedence get sorted last.
-    return ($precedenceA == $precedenceB) ? ($a['index'] < $b['index'] ? -1 : 1) : ($precedenceA < $precedenceB ? -1 : 1);
+    // We want these sorted ascending so selectors with lesser precedence get
+    // processed first and selectors with greater precedence get sorted last.
+    return ($precedence_a == $precedence_b) ? ($a['index'] < $b['index'] ? -1 : 1) : ($precedence_a < $precedence_b ? -1 : 1);
   }
 
   private static function get_selector_precedence($selector) {
     $precedence = 0;
     $value = 100;
-    $search = array('\#', '\.', ''); // ids: worth 100, classes: worth 10, elements: worth 1
+    // Ids: worth 100, classes: worth 10, elements: worth 1.
+    $search = array('\#', '\.', '');
 
     foreach ($search as $s) {
-      if (trim($selector == '')) break;
+      if (trim($selector == '')) {
+        break;
+      }
       $num = 0;
       $selector = preg_replace('/' . $s . '\w+/', '', $selector, -1, $num);
       $precedence += ($value * $num);
@@ -212,26 +227,38 @@ class mimemail_compress {
     $definitions = explode(';', $style);
     $css_styles = array();
     foreach ($definitions as $def) {
-      if (empty($def) || strpos($def, ':') === FALSE) continue;
+      if (empty($def) || strpos($def, ':') === FALSE) {
+        continue;
+      }
       list($key, $value) = explode(':', $def, 2);
-      if (empty($key) || empty($value)) continue;
+      if (empty($key) || empty($value)) {
+        continue;
+      }
       $css_styles[trim($key)] = trim($value);
     }
     return $css_styles;
   }
 
-  // Get the full path to a DOM node.
-  // @see http://stackoverflow.com/questions/2643533/php-getting-xpath-of-a-domnode
-  function calculateXPath(DOMNode $node) {
+
+  /**
+   * Get the full path to a DOM node.
+   * @see http://stackoverflow.com/questions/2643533/php-getting-xpath-of-a-domnode
+   *
+   * @param DOMNode $node
+   *   The node to analyze.
+   *
+   * @return string
+   *   The full xpath to a DOM node.
+   */
+  public function calculateXPath(DOMNode $node) {
     $xpath = '';
     $q = new DOMXPath($node->ownerDocument);
 
     do {
-        $position = 1 + $q->query('preceding-sibling::*[name()="' . $node->nodeName . '"]', $node)->length;
-        $xpath    = '/' . $node->nodeName . '[' . $position . ']' . $xpath;
-        $node     = $node->parentNode;
-    }
-    while (!$node instanceof DOMDocument);
+      $position = 1 + $q->query('preceding-sibling::*[name()="' . $node->nodeName . '"]', $node)->length;
+      $xpath    = '/' . $node->nodeName . '[' . $position . ']' . $xpath;
+      $node     = $node->parentNode;
+    } while (!$node instanceof DOMDocument);
 
     return $xpath;
   }
diff --git a/modules/mimemail_compress/mimemail_compress.module b/modules/mimemail_compress/mimemail_compress.module
index baeb22e..8dbbd06 100644
--- a/modules/mimemail_compress/mimemail_compress.module
+++ b/modules/mimemail_compress/mimemail_compress.module
@@ -6,13 +6,13 @@
  */
 
 /**
- * Mimemail postprocess
+ * Mimemail postprocess.
  */
 function mimemail_compress_mail_post_process(&$message, $mailkey) {
   module_load_include('inc', 'mimemail_compress');
-  // Separate CSS from HTML for processing
+  // Separate CSS from HTML for processing.
   $parts = mimemail_compress_clean_message($message);
-  // Compress HTML and CSS into combined message
+  // Compress HTML and CSS into combined message.
   if (!empty($parts)) {
     $output = new mimemail_compress($parts['html'], $parts['css']);
     $output = $output->compress();
