diff --git a/antispam.admin.inc b/antispam.admin.inc
index edaa6aa..a1deda2 100644
--- a/antispam.admin.inc
+++ b/antispam.admin.inc
@@ -1,4 +1,10 @@
 <?php
+/**
+ * @file
+ * The antispam admin theme.
+ *
+ * Administration functions for managing the module.
+ */
 
 /**
  * Truncate size of content body for the tooltip
@@ -6,10 +12,8 @@
 define('BODY_TOOLTIP_LEN', 128);
 
 function antispam_settings_form_validate($form, &$form_state) {
-
+  // If connection enabled, then validate the entered API key.
   if ($form_state['values']['antispam_connection_enabled']) {
-    // if connection enabled, then check and validate the entered API key
-
     $service_provider = $form_state['values']['antispam_service_provider'];
     switch ($service_provider) {
       case AKISMET_SERVICE:
@@ -54,9 +58,10 @@ function antispam_settings_form() {
   $service_provider = antispam_get_service_provider();
 
   // Provide the AntiSpam administration JavaScript.
-  drupal_add_js(drupal_get_path('module', 'antispam') .'/antispam.js');
+  drupal_add_js(drupal_get_path('module', 'antispam') . '/antispam.js');
 
-  $service_fieldset_collapsed = FALSE; // always show 
+  // Always show.
+  $service_fieldset_collapsed = FALSE;
 
   $form['service'] = array(
     '#type' => 'fieldset', '#title' => t('AntiSpam Service Options'),
@@ -207,7 +212,8 @@ function antispam_settings_form() {
         '@admin-nodes' => t('administer nodes'),
         '!admin-access' => url('admin/access'),
       ))
-      .'<br />'. t('<strong>Note:</strong> To interact fully with the antispam service, you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise antispam service will never learn from its mistakes. Thank you.'),
+      . '<br />'
+      . t('<strong>Note:</strong> To interact fully with the antispam service, you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise antispam service will never learn from its mistakes. Thank you.'),
   );
 
   if (module_exists('comment')) {
@@ -244,7 +250,8 @@ function antispam_settings_form() {
           '@admin-comments' => t('administer comments'),
           '!admin-access' => url('admin/access'),
         ))
-        .'<br />'. t('<strong>Note:</strong> To interact fully with the selected antispam service, you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise the antispam service will never learn from its mistakes. Thank you.'),
+        . '<br />'
+        . t('<strong>Note:</strong> To interact fully with the selected antispam service, you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use these links to submit missed spam and false positives (ham), otherwise the antispam service will never learn from its mistakes. Thank you.'),
     );
   }
 
@@ -368,7 +375,7 @@ function antispam_moderator_operations($mode, $submode) {
       )
     );
   }
-  else if ($mode == 'comments') {
+  elseif ($mode == 'comments') {
     $operations = array(
       'submit-spam' => array(
         'title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit selected comments as spam') : t('Mark selected comments as spam')),
@@ -406,10 +413,10 @@ function antispam_moderator_operations($mode, $submode) {
   if ($submode == 'spam') {
     unset($operations['submit-spam']);
   }
-  else if ($submode == 'unpublished') {
+  elseif ($submode == 'unpublished') {
     unset($operations['unpublish']);
   }
-  else if ($submode == 'published') {
+  elseif ($submode == 'published') {
     unset($operations['publish']);
   }
   else { // Unknown submode!
@@ -426,54 +433,65 @@ function antispam_generate_statistics_graph() {
   /**
    * Chart 1: Element Ratio Pie Chart
    */
-  // get sum
+  // Get sum.
   $counts = antispam_get_total_counter();
-  // construct URL for Google Chart API
+  // Construct URL for Google Chart API.
   $total = $counts['total_spam'] + $counts['total_ham'];
   $counts['total_spam'] -= $counts['total_fpositive'];
   $counts['total_ham'] -= $counts['total_fnegative'];
   $chart_width = variable_get('antispam_chart_width', 480);
-  $output = '<p><img src="http://chart.apis.google.com/chart?'
-            . 'chtt=' . t('Total Statistics')
-            . '&cht=p'  // char type: line chart
-            . '&chs=' . $chart_width . 'x' . ($chart_width / 2) // chart size
-            . '&chds=0,' . $total
-            . '&chl=' . t('Spam') . '|' . t('Ham') .'|'
-              . t('False Negative') . '|' . t('False Positive') // legend
-            . '&chd=t:' . $counts['total_spam'] . ',' . $counts['total_ham'] . ','
-              . $counts['total_fnegative'] . ',' . $counts['total_fpositive']
-            . '&chco=dd6666,ffdd33,444444,bbbbbb' // line colors
-            . '" alt="Total Statistics Chart" class="antispam-chart" /></p>' . "\n";
+  $output = '<p><img src="http://chart.apis.google.com/chart?';
+  $output .= 'chtt=' . t('Total Statistics');
+  // Char type: line chart.
+  $output .= '&cht=p';
+  // Chart size.
+  $output .= '&chs=' . $chart_width . 'x' . ($chart_width / 2);
+  $output .= '&chds=0,' . $total;
+  $output .= '&chl=' . t('Spam') . '|' . t('Ham') . '|';
+  // Legend.
+  $output .= t('False Negative') . '|' . t('False Positive');
+  $output .= '&chd=t:' . $counts['total_spam'] . ',' . $counts['total_ham'] . ',';
+  $output .= $counts['total_fnegative'] . ',' . $counts['total_fpositive'];
+  // Line colors.
+  $output .= '&chco=dd6666,ffdd33,444444,bbbbbb';
+  $output .= '" alt="Total Statistics Chart" class="antispam-chart" /></p>' . "\n";
 
   /**
    * Chart 2: Daily Statistics Line Chart (max 1 year)
    */
-  // get max
+  // Get max.
   $max_counts = antispam_get_max_counter();
   $y_max = max($max_counts['max_spam'], $max_counts['max_ham']) + 1;
 
-
-  // get oldest and latest date within the range
-  $rec = db_query("SELECT MIN(date) AS oldest, MAX(date) AS latest FROM {antispam_counter} ORDER BY date DESC LIMIT 365")->fetchObject();
+  // Get oldest and latest date within the range.
+  $rec = db_query_range("SELECT MIN(date) AS oldest, MAX(date) AS latest FROM {antispam_counter} ORDER BY date DESC", 0, 365)->fetchObject();
   $oldest = $rec ? date('M-d', strtotime($rec->oldest)) : '';
   $latest = $rec ? date('M-d', strtotime($rec->latest)) : date('M-d');
 
-  // construct URL for Google Chart API
-  $output .= '<p><img src="http://chart.apis.google.com/chart?'
-            . 'chtt=' . t('Daily Statistics')
-            . '&cht=lc' // char type: line chart
-            . '&chs=' . $chart_width . 'x' . (int)($chart_width *2 / 3) // chart size
-            . '&chdl=' . t('Spam') . '|' . t('Ham') // legend
-            . '&chdlp=t' // legend at top
-            . '&chxt=x,y' // axis
-            . '&chxl=0:|' . $latest . '|' . $oldest // x-axis label
-            . '&chxr=0,0,365|1,0,' . $y_max // x-axis, y-axis range
-            . '&chds=0,' . $y_max
-            . '&chco=dd6666,ffdd33' // line colors
-            . '&chd=t:';
+  // Construct URL for Google Chart API.
+  $output .= '<p><img src="http://chart.apis.google.com/chart?';
+  $output .= 'chtt=' . t('Daily Statistics');
+  // Char type: line chart.
+  $output .= '&cht=lc';
+  // Chart size.
+  $output .= '&chs=' . $chart_width . 'x' . (int)($chart_width * 2 / 3);
+  // Legend.
+  $output .= '&chdl=' . t('Spam') . '|' . t('Ham');
+  // Legend at top.
+  $output .= '&chdlp=t';
+  // Axis.
+  $output .= '&chxt=x,y';
+  // X-axis label.
+  $output .= '&chxl=0:|' . $latest . '|' . $oldest;
+  // X-axis, y-axis range.
+  $output .= '&chxr=0,0,365|1,0,' . $y_max;
+  $output .= '&chds=0,' . $y_max;
+  // Line colors.
+  $output .= '&chco=dd6666,ffdd33';
+  $output .= '&chd=t:';
   $spam = $ham = array();
-  // max 1 year
-  $result = db_query("SELECT * FROM {antispam_counter} ORDER BY date DESC LIMIT 365");
+  // Max 1 year.
+  $result = db_query_range("SELECT * FROM {antispam_counter} ORDER BY date DESC", 0, 365);
   foreach ($result as $rec) {
     $spam[] = $rec->spam_detected;
     $ham[] = $rec->ham_detected;
@@ -481,11 +499,13 @@ function antispam_generate_statistics_graph() {
   foreach ($spam as $spam_count) {
     $output .= $spam_count . ',';
   }
-  $output = rtrim($output, ','); // drop trailing comma
+  // Drop trailing comma.
+  $output = rtrim($output, ',');
   foreach ($ham as $ham_count) {
     $output .= $ham_count . ',';
   }
-  $output = rtrim($output, ','); // drop trailing comma
+  // Drop trailing comma.
+  $output = rtrim($output, ',');
   $output .= '" alt="Daily Statistics Chart" class="antispam-chart" /></p>' . "\n";
 
   return $output;
@@ -494,8 +514,10 @@ function antispam_generate_statistics_graph() {
 /**
  * Menu callback; Moderation queue.
  *
- * @param string Mode: overview (default), nodes, comments, statistics
- * @param string Submode: spam (default), unpublished, published.
+ * @param string mode
+ *   'overview' (default), 'nodes', 'comments', 'statistics'.
+ * @param string submode
+ *   'spam' (default), 'unpublished', 'published'.
  */
 function antispam_callback_queue($mode = '', $submode = '') {
   // Make sure we're dealing with a valid mode and submode.
@@ -508,14 +530,14 @@ function antispam_callback_queue($mode = '', $submode = '') {
   if (empty($mode)) {
     $mode = 'overview';
   }
-  else if (!in_array($mode, $valid_modes)) {
+  elseif (!in_array($mode, $valid_modes)) {
     drupal_not_found();
     return;
   }
   if (empty($submode)) {
     $submode = 'spam';
   }
-  else if (!isset($valid_submodes[$submode])) {
+  elseif (!isset($valid_submodes[$submode])) {
     drupal_not_found();
     return;
   }
@@ -530,7 +552,8 @@ function antispam_callback_queue($mode = '', $submode = '') {
   }
   $allowed_nodes_count = count($allowed_nodes);
 
-  // Make sure the user has some kind of content administration/moderation permission.
+  // Make sure the user has some kind of content administration/moderation
+  // permission.
   if ($allowed_nodes_count <= 0 && !$allowed_comments) {
     drupal_access_denied();
     return;
@@ -539,7 +562,7 @@ function antispam_callback_queue($mode = '', $submode = '') {
   // Present the overview page (default).
   if ($mode == 'overview') {
     $items = array();
-    //------ node ------
+    // ------ node ------
     if ($allowed_nodes_count > 0) {
       $subitems = array();
       foreach ($valid_submodes as $key => $title) {
@@ -549,10 +572,10 @@ function antispam_callback_queue($mode = '', $submode = '') {
         if ($key == 'spam') {
           $query->isNotNull('s.content_id');            
         }
-        else if ($key == 'unpublished') {
+        elseif ($key == 'unpublished') {
           $query->condition('n.status', NODE_NOT_PUBLISHED);
         }
-        else if ($key == 'published') {
+        elseif ($key == 'published') {
           $query->condition('n.status', NODE_PUBLISHED);
         }
         $query->addTag('node_access');
@@ -561,13 +584,13 @@ function antispam_callback_queue($mode = '', $submode = '') {
         $sql_cnt = str_replace('%cond', $sql_nodes_cond[$key], $sql_nodes_cnt);
         $count = db_query(db_rewrite_sql($sql_cnt))->fetchField();
 */
-        $path = 'admin/content/antispam/nodes'. ($key == 'spam' ? '' : '/'. $key);
+        $path = 'admin/content/antispam/nodes' . ($key == 'spam' ? '' : '/' . $key);
         $label = ($count > 0 ? l($title, $path) : $title);
-        $subitems[] = '<p><strong>'. $label .': '. $count .'</strong></p>';
+        $subitems[] = '<p><strong>' . $label . ': ' . $count . '</strong></p>';
       }
-      $items[] = '<h4>'. t('Nodes') .'</h4>'. theme('item_list', array('items' => $subitems));
+      $items[] = '<h4>' . t('Nodes') . '</h4>' . theme('item_list', array('items' => $subitems));
     }
-    //------ comment ------
+    // ------ comment ------
     if ($allowed_comments) {
       $subitems = array();
       foreach ($valid_submodes as $key => $title) {
@@ -577,19 +600,19 @@ function antispam_callback_queue($mode = '', $submode = '') {
         if ($key == 'spam') {
           $query->isNotNull('s.content_id');            
         }
-        else if ($key == 'unpublished') {
+        elseif ($key == 'unpublished') {
           $query->condition('c.status', 0);
         }
-        else if ($key == 'published') {
+        elseif ($key == 'published') {
           $query->condition('c.status', 1);
         }
         $query->addTag('node_access');
         $count = $query->countQuery()->execute()->fetchField();
-        $path = 'admin/content/antispam/comments'. ($key == 'spam' ? '' : '/'. $key);
+        $path = 'admin/content/antispam/comments' . ($key == 'spam' ? '' : '/' . $key);
         $label = ($count > 0 ? l($title, $path) : $title);
-        $subitems[] = '<p><strong>'. $label .': '. $count .'</strong></p>';
+        $subitems[] = '<p><strong>' . $label . ': ' . $count . '</strong></p>';
       }
-      $items[] = '<h4>'. t('Comments') .'</h4>'. theme('item_list', array('items' => $subitems));
+      $items[] = '<h4>' . t('Comments') . '</h4>' . theme('item_list', array('items' => $subitems));
     }
     return '<h3>' . t('Summary of content:') . '</h3>' . theme('item_list', array('items' => $items));
   }
@@ -598,7 +621,8 @@ function antispam_callback_queue($mode = '', $submode = '') {
     $items = array();
     $provider_name = antispam_get_provider_name(antispam_get_service_provider(), TRUE);
     $items[] = $provider_name;
-    $output = '<h3>' . t('Current Service Provider') . '</h3>' . theme('item_list', array('items' => $items)) . '<br />';
+    $output = '<h3>' . t('Current Service Provider') . '</h3>';
+    $output .= theme('item_list', array('items' => $items)) . '<br />';
     
     $items = array();
     $counts = antispam_get_total_counter();
@@ -618,9 +642,9 @@ function antispam_callback_queue($mode = '', $submode = '') {
     $items[] = '<p><strong>' . t('Accuracy: !accuracy %', array('!accuracy' => $accuracy)) . '</strong></p>';
     $output .= '<h3>' . t('Statistics since @since (!days)', 
       array('@since' => antispam_get_counting_since(), '!days' => format_plural($days, '1 day', '@count days'))) . '</h3>' . theme('item_list', array('items' => $items));
-    // generate graph using Google Chart API
+    // Generate graph using Google Chart API.
     $output .= antispam_generate_statistics_graph();
-    // footnotes
+    // Footnotes.
     $output .= '<p><br /><i>' . t('Note: <strong>False negatives</strong> is the number of spams that were incorrectly tagged as hams, while <strong>false positives</strong> is the number of hams that were incorrectly tagged as spams. These numbers totally depends on your manual operation to retrain the antispam service using <strong>submit as spam</strong> and <strong>submit as ham</strong> feature.') . '</i></p>';
     $output .= '<p><i>' . t('Note: <strong>Accuracy</strong> is calculated by the following formula:<br /> accuracy(%) = 100 - (((false negative + false positive) / total checked) * 100)') . '</i></p>';
    
@@ -635,8 +659,11 @@ function antispam_callback_queue($mode = '', $submode = '') {
   }
 }
 
+/**
+ * @param $spaminess float
+ *   Value between (0 to 1) or null.
+ */
 function _antispam_spaminess_bar($spaminess) {
-  // $spaminess - float value between (0 to 1) or null
   if (empty($spaminess)) {
     return;
   }
@@ -644,10 +671,10 @@ function _antispam_spaminess_bar($spaminess) {
     $ispaminess = (int)($spaminess * 100);
   }
   $output  = '<div style="width:100px; background-color: #eee;">';
-  $output .= '<div style="width:' . $ispaminess . 'px; color: #000; background: url('
-              . base_path() . drupal_get_path('module', 'antispam') 
-              . '/spaminess.jpg) center left; padding:0px 2px; font-size: 9px">' 
-              . $spaminess;
+  $output .= '<div style="width:' . $ispaminess . 'px; color: #000; background: url(';
+  $output .= base_path() . drupal_get_path('module', 'antispam');
+  $output .= '/spaminess.jpg) center left; padding:0px 2px; font-size: 9px">';
+  $output .= $spaminess;
   $output .= '</div></div>';
   return $output;
 }
@@ -659,15 +686,15 @@ function antispam_get_submode_menu($mode, $submode) {
   if ($submode == 'spam') {
     $spam_li = '<li class="active">'; 
   }
-  else if ($submode == 'unpublished') {
+  elseif ($submode == 'unpublished') {
     $unpublished_li = '<li class="active">'; 
   }
-  else if ($submode == 'published') {
+  elseif ($submode == 'published') {
     $published_li = '<li class="active">'; 
   }
-  $out .= $spam_li . l(t('Spam'), 'admin/content/antispam/'.$mode.'/spam') . '</li>';
-  $out .= $unpublished_li . l(t('Unpublished'), 'admin/content/antispam/'.$mode.'/unpublished') . '</li>';
-  $out .= $published_li . l(t('Published'), 'admin/content/antispam/'.$mode.'/published') . '</li>';
+  $out .= $spam_li . l(t('Spam'), 'admin/content/antispam/' . $mode . '/spam') . '</li>';
+  $out .= $unpublished_li . l(t('Unpublished'), 'admin/content/antispam/' . $mode . '/unpublished') . '</li>';
+  $out .= $published_li . l(t('Published'), 'admin/content/antispam/' . $mode . '/published') . '</li>';
   $out .= '</ul></div>';
   return $out;
 }
@@ -704,8 +731,8 @@ function antispam_moderation_form($form, &$form_state, $mode = '', $submode = ''
     '#default_value' => '');
   $form['options']['submit'] = array('#type' => 'submit', '#value' => t('Moderate'));
 
+  // Nodes.
   if ($mode == 'nodes') {
-
     $allowed_nodes = antispam_get_moderator_types();
     if (isset($allowed_nodes['comments'])) {
       unset($allowed_nodes['comments']);
@@ -728,10 +755,10 @@ function antispam_moderation_form($form, &$form_state, $mode = '', $submode = ''
     if ($submode == 'spam') {
       $query->isNotNull('s.content_id');            
     }
-    else if ($submode == 'unpublished') {
+    elseif ($submode == 'unpublished') {
       $query->condition('n.status', 0);
     }
-    else if ($submode == 'published') {
+    elseif ($submode == 'published') {
       $query->condition('n.status', 1);
     }
     if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
@@ -758,7 +785,8 @@ function antispam_moderation_form($form, &$form_state, $mode = '', $submode = ''
       ));
     }
   }
-  else { // comments
+  // Comments.
+  else {
     $query = db_select('comment', 'c');
     $query->join('users', 'u', 'u.uid = c.uid');
     $query->join('field_data_comment_body', 'e', 'e.entity_id = c.cid');
@@ -771,10 +799,10 @@ function antispam_moderation_form($form, &$form_state, $mode = '', $submode = ''
     if ($submode == 'spam') {
       $query->isNotNull('s.content_id');            
     }
-    else if ($submode == 'unpublished') {
+    elseif ($submode == 'unpublished') {
       $query->condition('c.status', COMMENT_NOT_PUBLISHED);
     }
-    else if ($submode == 'published') {
+    elseif ($submode == 'published') {
       $query->condition('c.status', COMMENT_PUBLISHED);
     }
     if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
@@ -807,20 +835,23 @@ function antispam_moderation_form($form, &$form_state, $mode = '', $submode = ''
   $items = array();
   $now = time();
   foreach ($result as $content) {
+    // Nodes.
     if ($mode == 'nodes') {
       $items[$content->nid] = '';
       $content->name = $content->uid ? $content->registered_name : $content->name;
       $form['title'][$content->nid] = array(
-        '#value' => l($content->title, 'node/'. $content->nid, array(
+        '#value' => l($content->title, 'node/' . $content->nid, array(
           'attributes' => array(
             'title' => truncate_utf8(render($content->body), BODY_TOOLTIP_LEN),
           )
         )
-      ) .' '. theme('mark', array('type' => node_mark($content->nid, $content->changed))));
+      ) . ' ' . theme('mark', array('type' => node_mark($content->nid, $content->changed))));
       $form['type'][$content->nid] = array('#value' => node_type_get_name($content));
       $form['author'][$content->nid] = array('#value' => theme('username', array('account' => user_load($content->uid))));
       $form['status'][$content->nid] = array('#value' => ($content->status ? t('published') : t('not published')));
-      if(empty($content->spam_mark)) $content->spam_mark = 0;
+      if (empty($content->spam_mark)) {
+        $content->spam_mark = 0;
+      }
       if ($content->spam_mark) {
         $form['status'][$content->nid]['#value'] .= '/' . t('spam');
       }
@@ -829,16 +860,17 @@ function antispam_moderation_form($form, &$form_state, $mode = '', $submode = ''
       }
       $form['created'][$content->nid] = array('#value' => t('%time ago', array('%time' => format_interval($now - $content->changed))));
     }
-    else { // comments
+    // Comments.
+    else {
       $items[$content->cid] = '';
       $content->name = $content->uid ? $content->registered_name : $content->name;
       $form['title'][$content->cid] = array(
-        '#value' => l($content->subject, 'node/'. $content->nid, array(
+        '#value' => l($content->subject, 'node/' . $content->nid, array(
           'attributes' => array(
             'title' => truncate_utf8(render($content->body), BODY_TOOLTIP_LEN)
           ), 
           'fragment' => 'comment-' . $content->cid,
-         )) .' '. theme('mark', array('type' => node_mark($content->cid, $content->created))));
+         )) . ' ' . theme('mark', array('type' => node_mark($content->cid, $content->created))));
       $form['author'][$content->cid] = array('#value' => theme('username', array('account' => user_load($content->uid))));
       $form['status'][$content->cid] = array('#value' => ($content->status == COMMENT_PUBLISHED ? t('published') : t('not published')));
       if ($content->spam_mark) {
@@ -889,9 +921,9 @@ function theme_antispam_moderation_form($variables) {
   }
   else {
     if ($submode == 'spam') {
-      $message = ($mode == 'nodes' ? t('There is no spam in the nodes moderation queue.') : t('There is no spam in the comments moderation queue.')) .'<br />'. t('It must be your lucky day! ;-)');
+      $message = ($mode == 'nodes' ? t('There is no spam in the nodes moderation queue.') : t('There is no spam in the comments moderation queue.')) . '<br />' . t('It must be your lucky day! ;-)');
     }
-    else if ($submode == 'unpublished') {
+    elseif ($submode == 'unpublished') {
       $message = ($mode == 'nodes' ? t('There are no unpublished nodes in the moderation queue.') : t('There are no unpublished comments in the moderation queue.'));
     }
     else { // published
@@ -946,9 +978,9 @@ function antispam_confirm_multiple_operation($form, &$form_state, $mode = '', $s
     return;
   }
 
-  $confirm_message = '<strong>'. $valid_operations[$operation]['confirm'] .'</strong>';
+  $confirm_message = '<strong>' . $valid_operations[$operation]['confirm'] . '</strong>';
   $confirm_button = $valid_operations[$operation]['button'];
-  $confirm_warning = '<p>'. (isset($valid_operations[$operation]['warning']) ? $valid_operations[$operation]['warning'] : '') .'</p>';
+  $confirm_warning = '<p>' . (isset($valid_operations[$operation]['warning']) ? $valid_operations[$operation]['warning'] : '') . '</p>';
   $content_type = ($mode == 'nodes' ? 'node' : 'comment');
 
   $form = array();
@@ -956,8 +988,13 @@ function antispam_confirm_multiple_operation($form, &$form_state, $mode = '', $s
   // array_filter() returns only elements with actual values
   foreach (array_filter($edit['items']) as $content_id => $value) {
     if ($content = antispam_content_load($content_type, $content_id)) {
-      $title = '&quot;'. check_plain($content_type == 'node' ? $content->title : $content->subject) .'&quot;, '. t('by') .' '. theme('username', array('account' => user_load($content->uid)));
-      $form['items'][$content_id] = array('#type' => 'hidden', '#value' => $content_id, '#prefix' => '<li>', '#suffix' => $title .'</li>');
+      $title = '&quot;' . check_plain($content_type == 'node' ? $content->title : $content->subject) . '&quot;, ' . t('by') . ' ' . theme('username', array('account' => user_load($content->uid)));
+      $form['items'][$content_id] = array(
+        '#type' => 'hidden',
+        '#value' => $content_id,
+        '#prefix' => '<li>',
+        '#suffix' => $title . '</li>',
+      );
     }
   }
   $form['mode'] = array('#type' => 'hidden', '#value' => $mode);
@@ -967,9 +1004,9 @@ function antispam_confirm_multiple_operation($form, &$form_state, $mode = '', $s
   // Redirect to a non-existent menu item to make tabs disappear.
   menu_set_active_item('');
 
-  $path = 'admin/content/antispam/'. $mode;
+  $path = 'admin/content/antispam/' . $mode;
   if ($submode != 'spam') {
-    $path .= '/'. $submode;
+    $path .= '/' . $submode;
   }
   return confirm_form($form, $confirm_message, $path, $confirm_warning, $confirm_button, t('Cancel'));
 }
@@ -996,11 +1033,13 @@ function antispam_confirm_multiple_operation_submit($form, &$form_state) {
         antispam_content_delete($content_type, $content_id);
         $message = ($mode == 'nodes' ? t('The nodes have been deleted.') : t('The comments have been deleted.'));
       }
-      else if ($content = antispam_content_load($content_type, $content_id)) {
+      elseif ($content = antispam_content_load($content_type, $content_id)) {
+        // Node.
         if ($content_type == 'node') {
           $is_published = ($content->status ? TRUE : FALSE);
         }
-        else { // comment
+        // Comment.
+        else {
           $is_published = ($content->status == COMMENT_PUBLISHED ? TRUE : FALSE);
         }
         $is_spam = antispam_content_is_spam($content_type, $content_id);
@@ -1009,7 +1048,7 @@ function antispam_confirm_multiple_operation_submit($form, &$form_state) {
           antispam_content_spam_operation($content_type, $content, 'submit-spam', TRUE);
           antispam_increase_counter(ANTISPAM_COUNT_FALSE_NEGATIVE);
         }
-        else if ($operation == 'submit-ham' && $is_spam) {
+        elseif ($operation == 'submit-ham' && $is_spam) {
           antispam_content_spam_operation($content_type, $content, 'submit-ham', TRUE);
           antispam_increase_counter(ANTISPAM_COUNT_FALSE_POSITIVE);
         }
@@ -1017,7 +1056,7 @@ function antispam_confirm_multiple_operation_submit($form, &$form_state) {
         if (in_array($operation, array('unpublish', 'submit-spam')) && $is_published) {
           antispam_content_publish_operation($content_type, $content, 'unpublish');
         }
-        else if (in_array($operation, array('publish', 'submit-ham')) && !$is_published) {
+        elseif (in_array($operation, array('publish', 'submit-ham')) && !$is_published) {
           antispam_content_publish_operation($content_type, $content, 'publish');
         }
 
@@ -1027,9 +1066,9 @@ function antispam_confirm_multiple_operation_submit($form, &$form_state) {
     drupal_set_message($message);
   }
 
-  $form_state['redirect'] = 'admin/content/antispam/'. $mode;
+  $form_state['redirect'] = 'admin/content/antispam/' . $mode;
   if ($submode != 'spam') {
-    $form_state['redirect'] .= '/'. $submode;
+    $form_state['redirect'] .= '/' . $submode;
   }
   return;
 }
diff --git a/antispam.cron.inc b/antispam.cron.inc
index 1dac7c2..4902779 100644
--- a/antispam.cron.inc
+++ b/antispam.cron.inc
@@ -1,4 +1,10 @@
 <?php
+/**
+ * @file
+ * The antispam cron code.
+ *
+ * Module crone functions.
+ */
 
 /**
  * Shutdown function executed at cron time.
@@ -55,8 +61,9 @@ function antispam_cron_shutdown() {
       }
     }
     if ($delete_count > 0) {
-      $message = t('AntiSpam housekeeping') .': '. format_plural($delete_count, '1 expired spam node removed from database', '@count expired spam nodes removed from database').
-        '<br />'.t('Node ID List: %nids', array('%nids' => implode(',', $deleted_items)));
+      $message = t('AntiSpam housekeeping') . ': ' . format_plural($delete_count, '1 expired spam node removed from database', '@count expired spam nodes removed from database') .
+        '<br />'
+        . t('Node ID List: %nids', array('%nids' => implode(',', $deleted_items)));
       watchdog('cron', $message);
       $clear_cache = TRUE;
     }
@@ -71,8 +78,9 @@ function antispam_cron_shutdown() {
       }
     }
     if ($delete_count > 0) {
-      $message = t('AntiSpam housekeeping') .': '. format_plural($delete_count, '1 expired spam comment removed from database', '@count expired spam comments removed from database').
-        '<br />'.t('Comment ID List: %cids', array('%cids' => implode(',', $deleted_items)));
+      $message = t('AntiSpam housekeeping') . ': ' . format_plural($delete_count, '1 expired spam comment removed from database', '@count expired spam comments removed from database') .
+        '<br />'
+        . t('Comment ID List: %cids', array('%cids' => implode(',', $deleted_items)));
       watchdog('cron', $message);
       $clear_cache = TRUE;
     }
@@ -99,12 +107,14 @@ function antispam_cron_shutdown() {
       ->execute();
   }
   if ($spam_marks_removed > 0) {
-    $message = t('AntiSpam housekeeping') .': '. format_plural($spam_marks_removed, '1 spam mark removed from database', '@count spam marks removed from database');
+    $message = t('AntiSpam housekeeping') . ': ' . format_plural($spam_marks_removed, '1 spam mark removed from database', '@count spam marks removed from database');
     if (isset($spam_nids_list)) {
-      $message .= '<br />'. t('Node ID List: %nids', array('%nids' => $spam_nids_list));
+      $message .= '<br />';
+      $message .= t('Node ID List: %nids', array('%nids' => $spam_nids_list));
     }
     if (isset($spam_cids_list)) {
-      $message .= '<br />'. t('Comment ID List: %cids', array('%cids' => $spam_cids_list));
+      $message .= '<br />';
+      $message .= t('Comment ID List: %cids', array('%cids' => $spam_cids_list));
     }
     watchdog('cron', $message);
     $clear_cache = TRUE;
diff --git a/antispam.install b/antispam.install
index c2950ee..d35197d 100644
--- a/antispam.install
+++ b/antispam.install
@@ -1,4 +1,68 @@
 <?php
+/**
+ * @file
+ * Requirements, schema and related hooks for the Antispam module.
+ */
+
+/**
+ * Implements hook_requirement().
+ */
+function antispam_requirements($phase) {
+  $t = get_t();
+
+  $provider = antispam_get_service_provider();
+
+  if ($phase == 'runtime') {
+    if ($provider == AKISMET_SERVICE) {
+      if (variable_get('antispam_wpapikey', '') == '') {
+        $requirements['antispam_key'] = array(
+          'title' => t('Akismet API key'),
+          'value' => t('Not present'),
+          'description' => t("Akismet spam protection service requires a <a href='!wpapikey'>Akismet API key</a> to function. Obtain a key by signing up for a free account at <a href='!akismet-com'>Akismet.com</a>, then enter the key on the <a href='!antispam-settings'>AntiSpam settings page</a>.",
+          array(
+            '!wpapikey' => url('http://akismet.com/signup/'),
+            '!akismet-com' => url('http://akismet.com'),
+            '!antispam-settings' => url('admin/config/spamprevention/antispam'),
+          )),
+          'severity' => REQUIREMENT_ERROR,
+        );
+        return $requirements;
+      }
+    }
+    elseif ($provider == TYPEPAD_SERVICE) {
+      if (variable_get('antispam_tpapikey', '') == '') {
+        $requirements['antispam_key'] = array(
+          'title' => t('TypePad AntiSpam API key'),
+          'value' => t('Not present'),
+          'description' => t("TypePad AntiSpam service requires a <a href='!tpapikey'>TypePad.com AntiSpam API key</a> to function. Obtain a key by signing up for a free account at <a href='!typepad-com'>Typepad.com</a>. Once you get a free account, visit the <a href='!tpapikey'>TypePad AntiSpam Service</a> and get your free TypePad AntiSpam API Key there, then enter the key on the <a href='!antispam-settings'>AntiSpam settings page</a>.",
+          array(
+            '!tpapikey' => url('http://antispam.typepad.com/info/get-api-key.html'),
+            '!typepad-com' => url('http://typepad.com/connect/register'),
+            '!antispam-settings' => url('admin/config/spamprevention/antispam'),
+          )),
+          'severity' => REQUIREMENT_ERROR,
+        );
+        return $requirements;
+      }
+    }
+    elseif ($provider == DEFENSIO_SERVICE) {
+      if (variable_get('antispam_deapikey', '') == '') {
+        $requirements['antispam_key'] = array(
+          'title' => t('Defensio AntiSpam API key'),
+          'value' => t('Not present'),
+          '#description' => t("Defensio spam protection service requires a <a href='!defensio-com'>Defensio API key</a> to function. Obtain a key by signing up for a free account at <a href='!defensio-key'>Defensio.com</a> and get your free Defensio API key there, then enter the key on the <a href='!antispam-settings'>AntiSpam settings page</a>.",
+          array(
+            '!defensio-com' => url('http://defensio.com/'),
+            '!defensio-key' => url('http://defensio.com/signup/'),
+            '!antispam-settings' => url('admin/config/spamprevention/antispam'),
+          )),
+          'severity' => REQUIREMENT_ERROR,
+        );
+        return $requirements;
+      }
+    }
+  }
+}
 
 /**
  * Implements hook_schema().
@@ -136,8 +200,8 @@ function antispam_schema() {
 /**
  * Implements hook_install().
  */
-function antispam_install() {
-}
+//function antispam_install() {
+//}
 
 /**
  * Implements hook_uninstall().
diff --git a/antispam.module b/antispam.module
index d72c439..2bf496c 100644
--- a/antispam.module
+++ b/antispam.module
@@ -1,32 +1,36 @@
 <?php
+/**
+ * @file
+ * Primary hook implementations for the Antispam module.
+ */
 
 /**
-* AntiSpam Drupal and Module versions.
-*/
+ * AntiSpam Drupal and Module versions.
+ */
 define('ANTISPAM_DRUPAL_VERSION', '7');
 define('ANTISPAM_MODULE_VERSION', '1.0');
 define('ANTISPAM_MODULE_HOMEURL', 'http://www.drupal.org/project/antispam');
-define('ANTISPAM_MODULE_USERAGENT', 'Drupal/'. ANTISPAM_DRUPAL_VERSION .' | antispam.module/'. ANTISPAM_MODULE_VERSION);
+define('ANTISPAM_MODULE_USERAGENT', 'Drupal/' . ANTISPAM_DRUPAL_VERSION . ' | antispam.module/' . ANTISPAM_MODULE_VERSION);
 
 
 /**
-* AntiSpam API constants.
-*/
+ * AntiSpam API constants.
+ */
 define('AKISMET_API_HOST', 'rest.akismet.com');
 define('TYPEPAD_API_HOST', 'api.antispam.typepad.com');
 define('DEFENSIO_API_HOST', 'api.defensio.com');
 define('ANTISPAM_API_PORT', 80);
 define('AKISMET_API_VERSION', '1.1');
 define('DEFENSIO_API_VERSION', '1.2');
-define('ANTISPAM_API_USERAGENT', 'Drupal/'. ANTISPAM_DRUPAL_VERSION .' | antispam.module/'. ANTISPAM_MODULE_VERSION);
+define('ANTISPAM_API_USERAGENT', 'Drupal/' . ANTISPAM_DRUPAL_VERSION . ' | antispam.module/' . ANTISPAM_MODULE_VERSION);
 define('ANTISPAM_API_RESULT_ERROR', -1);
 define('ANTISPAM_API_RESULT_SUCCESS', 0);
 define('ANTISPAM_API_RESULT_IS_SPAM', 1);
 define('ANTISPAM_API_RESULT_IS_HAM', 2);
 
 /**
-* Service provider constants.
-*/
+ * Service provider constants.
+ */
 define('AKISMET_SERVICE', 0);
 define('TYPEPAD_SERVICE', 1);
 define('DEFENSIO_SERVICE', 2);
@@ -38,11 +42,10 @@ define('ANTISPAM_COUNT_FALSE_NEGATIVE', 3);
 define('ANTISPAM_COUNT_FALSE_POSITIVE', 4);
 
 /**
- * Debug function
+ * Debug function.
  */
-function antispam_debug($str)
-{
-  if(is_array($str) || is_object($str)) {
+function antispam_debug($str) {
+  if (is_array($str) || is_object($str)) {
     error_log(print_r($str, TRUE) . "\r\n", 3, "/tmp/antispam.txt");
   }
   else {
@@ -51,32 +54,31 @@ function antispam_debug($str)
 }
 
 /**
-* Implements hook_help().
-*/
+ * Implements hook_help().
+ */
 function antispam_help($path, $arg) {
   switch ($path) {
     case 'admin/help#antispam':
       $output = t('<p>In order to use the AntiSpam, you need a API key for the selected antispam service. If you don\'t have one already, you can get it by simply signing up for a free account at the following sites.</p>
 <ul>
-<li><a href="!akismet">akismet.com</a> for Akismet service
-<li><a href="!typepad">typepad.com</a> for TypePad AntiSpam service
-<li><a href="!defensio">defensio.com</a> for Defensio service
+  <li><a href="!akismet">akismet.com</a> for Akismet service
+  <li><a href="!typepad">typepad.com</a> for TypePad AntiSpam service
+  <li><a href="!defensio">defensio.com</a> for Defensio service
 </ul>
 <p>The <em>antispam module</em> may automatically check for spam posted in content (nodes and/or comments) by any user, except node or comment administrators respectively. It is also possible, from the <a href="!permission">Permission</a> panel, to grant <em>%no-check-perm</em> permission to <em>user roles</em> of your choice.</p>
 <p>Content marked as <em>spam</em> is still saved into database so it can be reviewed by content administrators. There is <a href="!antispam-settings">an option</a> that allows you to specify how long this information will be kept in the database. <em>Spam</em> older than a specified age will be automatically removed. Requires crontab.</p>
-<p>Automatic spam detection can be enabled or disabled by content type and/or comments. In addition to this, the antspam service makes it easy for <em>content administrators</em> to manually <em>publish</em>/<em>unpublish</em> content and <em>mark</em>/<em>unmark</em> content as spam, from links available at the bottom of content.</p>
-<p></p>',
+<p>Automatic spam detection can be enabled or disabled by content type and/or comments. In addition to this, the antspam service makes it easy for <em>content administrators</em> to manually <em>publish</em>/<em>unpublish</em> content and <em>mark</em>/<em>unmark</em> content as spam, from links available at the bottom of content.</p>',
       array(
         '!akismet' => url('http://akismet.com'),
         '!typepad' => url('http://antispam.typepad.com'),
         '!defensio' => url('http://defensio.com'),
-        '!antispam-settings' => url('admin/config/antispam'),
+        '!antispam-settings' => url('admin/config/spamprevention/antispam'),
         '!permission' => url('admin/people/permissions'),
         '%no-check-perm' => t('post with no antispam checking')
       ));
       return $output;
     case 'admin/help/antispam':
-    case 'admin/config/antispam':
+    case 'admin/config/spamprevention/antispam':
       $output = t('<p>The <a href="!antispam-module-home">AntiSpam module</a> for <a href="!drupal">Drupal</a> allows you to use either one of the <a href="!akismet">Akismet</a>, <a href="!typepad">TypePad AntiSpam</a> or <a href="!defensio">Defensio</a> service to protect your site from being spammed.</p>',
       array(
         '!antispam-module-home' => url(ANTISPAM_MODULE_HOMEURL),
@@ -89,97 +91,38 @@ function antispam_help($path, $arg) {
       return $output;
     case 'admin/content/antispam/nodes/unpublished':
       $output = t('Below is the list of <strong>unpublished nodes</strong> awaiting for moderation.');
-      $output .= ' '. t('Click on the titles to see the content of the nodes or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.');
+      $output .= ' ' . t('Click on the titles to see the content of the nodes or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.');
       break;
     case 'admin/content/antispam/nodes/published':
       $output = t('Below is the list of <strong>published nodes</strong>.');
-      $output .= ' '. t('Click on the titles to see the content of the nodes or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.');
+      $output .= ' ' . t('Click on the titles to see the content of the nodes or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.');
       break;
     case 'admin/content/antispam/nodes': // spam
       $output = t('Below is the list of <strong>nodes marked as spam</strong> awaiting for moderation.');
-      $output .= ' '. t('Click on the titles to see the content of the nodes or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.');
+      $output .= ' ' . t('Click on the titles to see the content of the nodes or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the nodes upon your needs.');
       break;
     case 'admin/content/antispam/comments/unpublished':
       $output = t('Below is the list of <strong>unpublished comments</strong> awaiting for moderation.');
-      $output .= ' '. t('Click on the subjects to see the comments or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.');
+      $output .= ' ' . t('Click on the subjects to see the comments or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.');
       break;
     case 'admin/content/antispam/comments/published':
       $output = t('Below is the list of <strong>published comments</strong>.');
-      $output .= ' '. t('Click on the subjects to see the comments or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.');
+      $output .= ' ' . t('Click on the subjects to see the comments or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.');
       break;
     case 'admin/content/antispam/comments': // spam
       $output = t('Below is the list of <strong>comments marked as spam</strong> awaiting for moderation.');
-      $output .= ' '. t('Click on the subjects to see the comments or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.');
+      $output .= ' ' . t('Click on the subjects to see the comments or the author\'s name to view the author\'s user information. You may also wish to click on the headers to order the comments upon your needs.');
       break;
   }
   if (arg(0) == 'admin' && arg(1) == 'content '&& arg(2) == 'antispam' && !isset($_POST) && !empty($output)) {
-    $output .= '<br />'. t('<strong>Note:</strong> To interact fully with the antispam service, you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use the submit <em>ham</em> operation rather than simply publishing content that was identified as spam (false positives). This is necessary in order to let the antispam service learn from its mistakes. Thank you.');
+    $output .= '<br />';
+    $output .= t('<strong>Note:</strong> To interact fully with the antispam service, you really should try putting data back into the system as well as just taking it out. If it is at all possible, please use the submit <em>ham</em> operation rather than simply publishing content that was identified as spam (false positives). This is necessary in order to let the antispam service learn from its mistakes. Thank you.');
   }
 }
 
 /**
-* Implements hook_requirement().
-*/
-function antispam_requirements($phase) {
-  $t = get_t();
-
-  $provider = antispam_get_service_provider();
-
-  if ($phase == 'runtime') {
-    if ($provider == AKISMET_SERVICE) {
-      if (variable_get('antispam_wpapikey', '') == '') {
-        $requirements['antispam_key'] = array(
-          'title' => t('Akismet API key'),
-          'value' => t('Not present'),
-          'description' => t("Akismet spam protection service requires a <a href='!wpapikey'>Akismet API key</a> to function. Obtain a key by signing up for a free account at <a href='!akismet-com'>Akismet.com</a>, then enter the key on the <a href='!antispam-settings'>AntiSpam settings page</a>.",
-          array(
-            '!wpapikey' => url('http://akismet.com/signup/'),
-            '!akismet-com' => url('http://akismet.com'),
-            '!antispam-settings' => url('admin/config/antispam'),
-          )),
-          'severity' => REQUIREMENT_ERROR,
-        );
-        return $requirements;
-      }
-    }
-    else if ($provider == TYPEPAD_SERVICE) {
-      if (variable_get('antispam_tpapikey', '') == '') {
-        $requirements['antispam_key'] = array(
-          'title' => t('TypePad AntiSpam API key'),
-          'value' => t('Not present'),
-          'description' => t("TypePad AntiSpam service requires a <a href='!tpapikey'>TypePad.com AntiSpam API key</a> to function. Obtain a key by signing up for a free account at <a href='!typepad-com'>Typepad.com</a>. Once you get a free account, visit the <a href='!tpapikey'>TypePad AntiSpam Service</a> and get your free TypePad AntiSpam API Key there, then enter the key on the <a href='!antispam-settings'>AntiSpam settings page</a>.",
-          array(
-            '!tpapikey' => url('http://antispam.typepad.com/info/get-api-key.html'),
-            '!typepad-com' => url('http://typepad.com/connect/register'),
-            '!antispam-settings' => url('admin/config/antispam'),
-          )),
-          'severity' => REQUIREMENT_ERROR,
-        );
-        return $requirements;
-      }
-    }
-    else if ($provider == DEFENSIO_SERVICE) {
-      if (variable_get('antispam_deapikey', '') == '') {
-        $requirements['antispam_key'] = array(
-          'title' => t('Defensio AntiSpam API key'),
-          'value' => t('Not present'),
-          '#description' => t("Defensio spam protection service requires a <a href='!defensio-com'>Defensio API key</a> to function. Obtain a key by signing up for a free account at <a href='!defensio-key'>Defensio.com</a> and get your free Defensio API key there, then enter the key on the <a href='!antispam-settings'>AntiSpam settings page</a>.",
-          array(
-            '!defensio-com' => url('http://defensio.com/'),
-            '!defensio-key' => url('http://defensio.com/signup/'),
-            '!antispam-settings' => url('admin/config/antispam'),
-          )),
-          'severity' => REQUIREMENT_ERROR,
-        );
-        return $requirements;
-      }
-    }
-  }
-}
-
-/**
-* Implements hook_permission().
-*/
+ * Implements hook_permission().
+ */
 function antispam_permission() {
   $permissions = array(
     'administer antispam settings' => array(
@@ -202,14 +145,14 @@ function antispam_permission() {
   );
   $permissions['post with no antispam checking'] = array(
       'title' => t('Post with no spam checking'),
-      'description' => 'Allow to post nodes/comments without being checked by AntiSpam module.',
+      'description' => 'Allow to post nodes/comments without being checked by AntiSpam module. ',
   );
   return $permissions;
 }
 
 /**
-* Implements hook_cron().
-*/
+ * Implements hook_cron().
+ */
 function antispam_cron() {
   module_load_include('inc', 'antispam', 'antispam.cron');
   module_load_include('inc', 'comment', 'comment.admin'); 
@@ -217,15 +160,15 @@ function antispam_cron() {
 }
 
 /**
-* Obtain current service provider
-*/
+ * Obtain current service provider.
+ */
 function antispam_get_service_provider() {
   return (variable_get('antispam_service_provider', 0));
 }
 
 /**
-* Obtain service provider name
-*/
+ * Obtain service provider name.
+ */
 function antispam_get_provider_name($provider, $with_link = FALSE) {
   switch ($provider) {
     case AKISMET_SERVICE:
@@ -240,8 +183,8 @@ function antispam_get_provider_name($provider, $with_link = FALSE) {
 }
 
 /**
-* Obtain API HOST name for the specified service provider
-*/
+ * Obtain API HOST name for the specified service provider.
+ */
 function antispam_get_api_host($provider) {
   switch ($provider) {
     case AKISMET_SERVICE:
@@ -258,8 +201,8 @@ function antispam_get_api_host($provider) {
 }
 
 /**
-* Obtain API key for the specified service provider
-*/
+ * Obtain API key for the specified service provider.
+ */
 function antispam_get_api_key($provider) {
   switch ($provider) {
     case AKISMET_SERVICE:
@@ -276,8 +219,8 @@ function antispam_get_api_key($provider) {
 }
 
 /**
-* Get max counter value for the specified counter type
-*/
+ * Get max counter value for the specified counter type.
+ */
 function antispam_get_max_counter($counter_type = '') {
   $rec = db_query("SELECT MAX(spam_detected) AS max_spam, MAX(ham_detected) AS max_ham, MAX(false_negative) AS max_fnegative, MAX(false_positive) AS max_fpositive FROM {antispam_counter}")->fetchObject();
   if ($rec->max_spam == '') $rec->max_spam = 0;
@@ -285,7 +228,8 @@ function antispam_get_max_counter($counter_type = '') {
   if ($rec->max_fnegative == '') $rec->max_fnegative = 0;
   if ($rec->max_fpositive == '') $rec->max_fpositive = 0;
 
-  if (empty($counter_type)) { // returns an array of all totals
+  // Returns an array of all totals.
+  if (empty($counter_type)) {
     return array('max_spam' => $rec->max_spam, 'max_ham' => $rec->max_ham, 'max_fnegative' => $rec->max_fnegative, 'max_fpositive' => $rec->max_fpositive);
   }
   switch ($counter_type) {
@@ -299,14 +243,16 @@ function antispam_get_max_counter($counter_type = '') {
       return $rec->max_fnegative;
     case ANTISPAM_COUNT_FALSE_POSITIVE:
       return $rec->max_fpositive;
+
+    // Just in case.
     default:
-      return 0; // just in case
+      return 0;
   }
 }
 
 /**
-* Get total counter value for the specified counter type
-*/
+ * Get total counter value for the specified counter type.
+ */
 function antispam_get_total_counter($counter_type = '') {
   $rec = db_query("SELECT SUM(spam_detected) AS total_spam, SUM(ham_detected) AS total_ham, SUM(false_negative) AS total_fnegative, SUM(false_positive) AS total_fpositive FROM {antispam_counter}")->fetchObject();
   if ($rec->total_spam == '') $rec->total_spam = 0;
@@ -314,7 +260,8 @@ function antispam_get_total_counter($counter_type = '') {
   if ($rec->total_fnegative == '') $rec->total_fnegative = 0;
   if ($rec->total_fpositive == '') $rec->total_fpositive = 0;
 
-  if (empty($counter_type)) { // returns an array of all totals
+  // Returns an array of all totals.
+  if (empty($counter_type)) {
     return array('total_spam' => $rec->total_spam, 'total_ham' => $rec->total_ham, 'total_fnegative' => $rec->total_fnegative, 'total_fpositive' => $rec->total_fpositive);
   }
   switch ($counter_type) {
@@ -328,18 +275,22 @@ function antispam_get_total_counter($counter_type = '') {
       return $rec->total_fnegative;
     case ANTISPAM_COUNT_FALSE_POSITIVE:
       return $rec->total_fpositive;
+
+    // Just in case.
     default:
-      return 0; // just in case
+      return 0;
   }
 }
 
 /**
-* Get today's counter value for the specified counter type
+* Get today's counter value for the specified counter type.
 */
-function antispam_get_counter($counter_type) { // for today
+function antispam_get_counter($counter_type) {
   $rec = db_query("SELECT * FROM {antispam_counter} WHERE date=:date", array(':date' => mktime(0, 0, 0, date("m"), date("d"), date("Y"))))->fetchObject();
-  if (!$rec) {
-    return 0; // no counter record for today
+
+  // No counter record for today.
+  if (empty($rec)) {
+    return 0;
   }
   switch ($counter_type) {
     case ANTISPAM_COUNT_ALL:
@@ -352,15 +303,17 @@ function antispam_get_counter($counter_type) { // for today
       return $rec->false_negative;
     case ANTISPAM_COUNT_FALSE_POSITIVE:
       return $rec->false_positive;
+
+    // Just in case.
     default:
-      return 0; // just in case
+      return 0;
   }
 }
 
 /**
-* Set today's counter value for the specified counter type
-*/
-function antispam_set_counter($counter_type, $count) { // for today
+ * Set today's counter value for the specified counter type.
+ */
+function antispam_set_counter($counter_type, $count) {
   switch ($counter_type) {
     case ANTISPAM_COUNT_ALL:
       return;
@@ -382,7 +335,7 @@ function antispam_set_counter($counter_type, $count) { // for today
   $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
   $result = db_query("SELECT * FROM {antispam_counter} WHERE date=:date", array(':date' => $today));
   if ($result->rowCount()) {
-    // update
+    // Update.
     db_update('antispam_counter')
       ->fields(array(
         $field => $count
@@ -391,28 +344,28 @@ function antispam_set_counter($counter_type, $count) { // for today
       ->execute();
   }
   else {
-    // insert
+    // Insert.
     $provider = antispam_get_service_provider();
     db_insert('antispam_counter')
       ->fields(array(
         'date' => strtotime(date('Y-m-d 00:00:00')),
-	    'provider' => $provider,
-	    $field => $count,
+        'provider' => $provider,
+        $field => $count,
       ))
       ->execute();  
   }
 }
 
 /**
-* Increase today's counter value for the specified counter type by 1
-*/
+ * Increase today's counter value for the specified counter type by 1.
+ */
 function antispam_increase_counter($counter_type) {
   antispam_set_counter($counter_type, antispam_get_counter($counter_type) + 1);
 }
 
 /**
-*
-*/
+ *
+ */
 function _antispam_moderator_types_count($types = array()) {
   if (empty($types)) {
     $types = antispam_get_moderator_types();
@@ -421,13 +374,16 @@ function _antispam_moderator_types_count($types = array()) {
 }
 
 /**
-*
-*/
+ *
+ */
 function _antispam_is_moderator($moderator_types = array(), $type = '') {
   global $user;
+
+  // Admin.
   if ($user->uid == 1) {
-    return TRUE;  // admin
+    return TRUE;
   }
+
   if (empty($moderator_types)) {
     $moderator_types = antispam_get_moderator_types();
   }
@@ -444,9 +400,12 @@ function _antispam_is_moderator($moderator_types = array(), $type = '') {
 */
 function _antispam_is_node_moderator($moderator_types = array()) {
   global $user;
+
+  // Admin.
   if ($user->uid == 1) {
-    return TRUE;  // admin
+    return TRUE;
   }
+
   if (empty($moderator_types)) {
     $moderator_types = antispam_get_moderator_types();
   }
@@ -459,8 +418,8 @@ function _antispam_is_node_moderator($moderator_types = array()) {
 }
 
 /**
-*
-*/
+ *
+ */
 function _antispam_is_moderator_type($type, $types = array()) {
   if (empty($types)) {
     $types = antispam_get_moderator_types();
@@ -474,40 +433,43 @@ function _antispam_is_moderator_type($type, $types = array()) {
 }
 
 /**
-* Implements hook_menu().
-*/
+ * Implements hook_menu().
+ */
 function antispam_menu() {
   $items = array();
   $moderator_types = antispam_get_moderator_types();
 
-  $items['admin/config/antispam'] = array(
+  // New menu block.
+  $items['admin/config/spamprevention'] = array(
+    'title' => 'AntiSpam',
+    'description' => 'Use the anti-spam service to protect your site from spam.', 
+    'position' => 'right',
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('access administration pages'),
+    'file' => 'system.admin.inc',
+    'file path' => drupal_get_path('module', 'system'),
+  );
+
+  // A menu item for the menu block.
+  $items['admin/config/spamprevention/antispam'] = array(
     'title' => t('AntiSpam'),
     'description' => t('Use the anti-spam service to protect your site from spam.'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('antispam_settings_form'),
     'access arguments' => array('administer antispam settings'),
     'file' => 'antispam.admin.inc',
-    'type' => MENU_LOCAL_TASK,
+    // Needs to be normal to show up.
+    'type' => MENU_NORMAL_ITEM,
   );
 
-  $items['admin/content/antispam'] = array(
-    'title' => t('AntiSpam moderation queue'),
-    'description' => t('Manage the AntiSpam spam queue, appropving or deleting content in need of moderation.'),
-    'page callback' => 'antispam_callback_queue',
-    'access callback' => '_antispam_is_moderator',
-    'access arguments' => array($moderator_types),
-    'file' => 'antispam.admin.inc',
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 10,
-  );
   $items['admin/content/antispam/overview'] = array(
-    'title' => t('Overview'),
+    'title' => 'Overview',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => 0,
     'file' => 'antispam.admin.inc',
   );
   $items['admin/content/antispam/nodes'] = array(
-    'title' => t('Nodes'),
+    'title' => 'Nodes',
     'page callback' => 'antispam_callback_queue',
     'page arguments' => array('nodes'),
     'access callback' => '_antispam_is_node_moderator',
@@ -517,7 +479,7 @@ function antispam_menu() {
     'file' => 'antispam.admin.inc',
   );
   $items['admin/content/antispam/nodes/spam'] = array(
-    'title' => t('Spam'),
+    'title' => 'Spam',
     'page callback' => 'antispam_callback_queue',
     'page arguments' => array('nodes'),
     'access callback' => '_antispam_is_node_moderator',
@@ -527,7 +489,7 @@ function antispam_menu() {
     'file' => 'antispam.admin.inc',
   );
   $items['admin/content/antispam/nodes/unpublished'] = array(
-    'title' => t('Unpublished nodes'),
+    'title' => 'Unpublished nodes',
     'page callback' => 'antispam_callback_queue',
     'page arguments' => array('nodes', 'unpublished'),
     'access callback' => '_antispam_is_node_moderator',
@@ -537,7 +499,7 @@ function antispam_menu() {
     'file' => 'antispam.admin.inc',
   );
   $items['admin/content/antispam/nodes/published'] = array(
-    'title' => t('Published nodes'),
+    'title' => 'Published nodes',
     'page callback' => 'antispam_callback_queue',
     'page arguments' => array('nodes', 'published'),
     'access callback' => '_antispam_is_node_moderator',
@@ -548,7 +510,7 @@ function antispam_menu() {
   );
   if (module_exists('comment')) {
     $items['admin/content/antispam/comments'] = array(
-      'title' => t('Comments'),
+      'title' => 'Comments',
       'page callback' => 'antispam_callback_queue',
       'page arguments' => array('comments'),
       'access callback' => '_antispam_is_moderator',
@@ -558,7 +520,7 @@ function antispam_menu() {
       'file' => 'antispam.admin.inc',
     );
     $items['admin/content/antispam/comments/spam'] = array(
-      'title' => t('Spam'),
+      'title' => 'Spam',
       'page callback' => 'antispam_callback_queue',
       'page arguments' => array('comments'),
       'access callback' => '_antispam_is_moderator',
@@ -568,7 +530,7 @@ function antispam_menu() {
       'file' => 'antispam.admin.inc',
     );
     $items['admin/content/antispam/comments/unpublished'] = array(
-      'title' => t('Unpublished comments'),
+      'title' => 'Unpublished comments',
       'page callback' => 'antispam_callback_queue',
       'page arguments' => array('comments', 'unpublished'),
       'access callback' => '_antispam_is_moderator',
@@ -578,7 +540,7 @@ function antispam_menu() {
       'file' => 'antispam.admin.inc',
     );
     $items['admin/content/antispam/comments/published'] = array(
-      'title' => t('Published comments'),
+      'title' => 'Published comments',
       'page callback' => 'antispam_callback_queue',
       'page arguments' => array('comments', 'published'),
       'access callback' => '_antispam_is_moderator',
@@ -589,7 +551,7 @@ function antispam_menu() {
     );
   }
   $items['admin/content/antispam/statistics'] = array(
-    'title' => t('Statistics'),
+    'title' => 'Statistics',
     'page callback' => 'antispam_callback_queue',
     'page arguments' => array('statistics'),
     'access callback' => '_antispam_is_moderator',
@@ -607,13 +569,15 @@ function antispam_menu() {
     'access arguments' => array(0, 1, 2, 3),
   );
   foreach (array('publish', 'unpublish', 'submit-spam', 'submit-ham') as $op) {
-    $items['antispam/%antispam/%/'. $op] = $item;
+    $items['antispam/%antispam/%/' . $op] = $item;
   }
   return $items;
 }
 
+/**
+ * Implements hook_load().
+ */
 function antispam_load($arg, &$map, $index) {
-
   if (!is_numeric($map[2])) {
     // Node and comment ids are always numeric!
     return FALSE;
@@ -633,14 +597,16 @@ function antispam_load($arg, &$map, $index) {
   if ($op == 'publish' || $op == 'unpublish') {
     $map[0] = 'antispam_callback_set_published_status';
   }
-  else if ($op == 'submit-spam' || $op == 'submit-ham') {
+  elseif ($op == 'submit-spam' || $op == 'submit-ham') {
     $map[0] = 'antispam_callback_set_spam_status';
   }
   return $map[$index];
 }
 
+/**
+ *
+ */
 function antispam_access_callback($callback, $content_type, $object, $op) {
-
   if ($content_type == 'node' && !node_access('update', $object)) {
     return FALSE;
   }
@@ -648,16 +614,20 @@ function antispam_access_callback($callback, $content_type, $object, $op) {
   if ($content_type == 'node') {
     $content_id = $object->nid;
   }
-  else if($content_type == 'comment') {
+  elseif ($content_type == 'comment') {
     $content_id = $object->cid;
   }
   if (function_exists($callback && !antispam_is_spam_moderator(antispam_content_get_moderator_type($content_type, $content_id)))) {
     return FALSE;
   }
-  // Is there a comment access check we need to run? If yes, then do the same as above.
+  // Is there a comment access check we need to run? If yes, then do the same
+  // as above.
   return TRUE;
 }
 
+/**
+ * Menu callback to build a page for a specific module callback.
+ */
 function antispam_page($callback, $content_type, $object, $op) {
   if (function_exists($callback)) {
     return $callback($content_type, $object, $op);
@@ -667,20 +637,25 @@ function antispam_page($callback, $content_type, $object, $op) {
 
 
 /**
-* Menu callback; publish/unpublish content.
-*
-* @param string Content type; it can be 'node' or 'comment'.
-* @param integer Content ID; can be either a nid or a cid.
-* @param string Operation; it can be 'publish' or 'unpublish'.
-*/
+ * Menu callback; publish/unpublish content.
+ *
+ * @param string $content_type
+ *   Can be 'node' or 'comment'.
+ * @param object $object
+ *   Can be either a nid or a cid.
+ * @param string $op
+ *   The operation being performed, can be 'publish' or 'unpublish'.
+ */
 function antispam_callback_set_published_status($content_type, $object, $op) {
-  // TODO: Should we be passing the object around or just the ID, or should we have antispam_content_load at all?
+  // TODO: Should we be passing the object around or just the ID, or should we
+  // have antispam_content_load at all?
   if ($content_type == 'node') {
     // Load the content (existence has been checked in hook_menu).
     $content = antispam_content_load($content_type, $object->nid);
     $is_published = ($content->status ? TRUE : FALSE);
   }
-  else { // comment
+  // Comment.
+  else {
     // Load the content (existence has been checked in hook_menu).
     $content = antispam_content_load($content_type, $object->cid);
     $is_published = ($content->status == COMMENT_PUBLISHED ? TRUE : FALSE);
@@ -689,27 +664,28 @@ function antispam_callback_set_published_status($content_type, $object, $op) {
   if ($op == 'publish' && !$is_published) {
     antispam_content_publish_operation($content_type, $content, 'publish');
   }
-  else if ($op == 'unpublish' && $is_published) {
+  elseif ($op == 'unpublish' && $is_published) {
     antispam_content_publish_operation($content_type, $content, 'unpublish');
   }
 
   if ($content_type == 'node') {
-    drupal_goto('node/'. $content->nid);
+    drupal_goto('node/' . $content->nid);
   }
   else { // comment
-    drupal_goto('node/'. $content->nid, array('fragment' => 'comment-'. $content->cid));
+    drupal_goto('node/' . $content->nid, array('fragment' => 'comment-' . $content->cid));
   }
 }
 
 /**
-* Menu callback; mark/unmark content as spam.
-*
-* When content is marked as spam, it is also unpublished (if necessary) and vice-versa.
-*
-* @param string Content type; it can be 'node' or 'comment'.
-* @param integer Content ID; can be either a nid or a cid.
-* @param string Operation; it can be 'submit-spam' or 'submit-ham'.
-*/
+ * Menu callback; mark/unmark content as spam.
+ *
+ * When content is marked as spam, it is also unpublished (if necessary) and
+ * vice-versa.
+ *
+ * @param string Content type; it can be 'node' or 'comment' .
+ * @param integer Content ID; can be either a nid or a cid.
+ * @param string Operation; it can be 'submit-spam' or 'submit-ham' .
+ */
 function antispam_callback_set_spam_status($content_type, $object, $op) {
   if ($content_type == 'node') {
     $is_spam = antispam_content_is_spam($content_type, $object->nid);
@@ -717,14 +693,15 @@ function antispam_callback_set_spam_status($content_type, $object, $op) {
     $content = antispam_content_load($content_type, $object->nid);
     $is_published = ($content->status ? TRUE : FALSE);
   }
-  else { // comment
+  // Comment.
+  else {
     $is_spam = antispam_content_is_spam($content_type, $object->cid);
     // Load the content (existence has been checked in hook_menu).
     $content = antispam_content_load($content_type, $object->cid);
     $is_published = ($content->status == COMMENT_PUBLISHED ? TRUE : FALSE);
   }
 
-  // insert or remove the spam marker (publishing/unpublishing if necessary).
+  // Insert or remove the spam marker (publishing/unpublishing if necessary).
   if ($op == 'submit-spam') {
     if (!$is_spam) {
       antispam_content_spam_operation($content_type, $content, 'submit-spam');
@@ -734,7 +711,7 @@ function antispam_callback_set_spam_status($content_type, $object, $op) {
       antispam_content_publish_operation($content_type, $content, 'unpublish');
     }
   }
-  else if ($op == 'submit-ham') {
+  elseif ($op == 'submit-ham') {
     if ($is_spam) {
       antispam_content_spam_operation($content_type, $content, 'submit-ham');
       antispam_increase_counter(ANTISPAM_COUNT_FALSE_POSITIVE);
@@ -745,22 +722,21 @@ function antispam_callback_set_spam_status($content_type, $object, $op) {
   }
 
   if ($content_type == 'node') {
-    drupal_goto('node/'. $content->nid);
+    drupal_goto('node/' . $content->nid);
   }
-  else { // comment
-    drupal_goto('node/'. $content->nid, array('fragment' => 'comment-'. $content->cid));
+  // Comment.
+  else {
+    drupal_goto('node/' . $content->nid, array('fragment' => 'comment-' . $content->cid));
   }
 }
 
-/******************************************************************************************
-*
-* Node operations
-* 
-******************************************************************************************/
+/*******************************************************************************
+ * Node operations
+ ******************************************************************************/
 
 /**
-* Implements hook_node_load().
-*/
+ * Implements hook_node_load().
+ */
 function antispam_node_load($nodes, $types) {
   foreach ($nodes as $node) {
     $rec = db_query("SELECT signature, spaminess FROM {antispam_spam_marks} WHERE content_type='node' AND content_id=:content_id", array(':content_id' => $node->nid))->fetchObject();
@@ -776,34 +752,39 @@ function antispam_node_load($nodes, $types) {
 }
 
 /**
-* Implements hook_node_insert().
-*/
+ * Implements hook_node_insert().
+ */
 function antispam_node_insert($node) {
   _antispam_node_save($node);
 }
+
 /**
-* Implements hook_node_update().
-*/
+ * Implements hook_node_update().
+ */
 function antispam_node_update($node) {
   _antispam_node_save($node);
 }
+
 /**
-* Called from hook_node_insert() and hook_node_update()
-*/
+ * Called from hook_node_insert() and hook_node_update()
+ */
 function _antispam_node_save(&$node) {
-  // If anti-spam servie connections are not enabled, we have nothing else to do here.
+  // If anti-spam servie connections are not enabled, we have nothing else to
+  // do here.
   if (!variable_get('antispam_connection_enabled', 1)) {
     antispam_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE);
     return;
   }
 
-  // Also quit asap, if current user has administration permission or permission to post without spam checking.
+  // Also quit ASAP, if current user has administration permission or
+  // permission to post without spam checking.
   if (antispam_is_spam_moderator($node->type) || user_access('post with no antispam checking')) {
     antispam_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE);
     return;
   }
 
-  // Now, check if it's about a node type that we have not been explicitly requested to check.
+  // Now, check if it's about a node type that we have not been explicitly
+  // requested to check.
   $check_nodetypes = variable_get('antispam_check_nodetypes', array());
   if (!is_array($check_nodetypes) || !isset($check_nodetypes[$node->type]) || !$check_nodetypes[$node->type]) {
     antispam_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE);
@@ -836,30 +817,30 @@ function _antispam_node_save(&$node) {
       antispam_content_publish_operation('node', $node, 'unpublish', FALSE);
     }
 
-    // Since users won't see their content published, show them a polite explanation on why.
+    // Since users won't see their content published, show them a polite
+    // explanation on why.
     $content_type_name = node_type_get_name($node);
     drupal_set_message(t('Your %content-type-name has been queued for moderation by site administrators and will be published after approval.', array('%content-type-name' => $content_type_name)));
     
     // Record the event to watchdog.
     if ($api_result[0] == ANTISPAM_API_RESULT_ERROR) {
-      watchdog('content', 'AntiSpam service seems to be down, %content-type-name queued for manual approval: %title', array('%content-type-name' => $content_type_name, '%title' => $node->title), WATCHDOG_WARNING, l(t('view'), 'node/'. $node->nid));
+      watchdog('content', 'AntiSpam service seems to be down, %content-type-name queued for manual approval: %title', array('%content-type-name' => $content_type_name, '%title' => $node->title), WATCHDOG_WARNING, l(t('view'), 'node/' . $node->nid));
     }
     else {
-      watchdog('content', 'Spam detected by AntiSpam in %content-type-name: %title', array('%content-type-name' => $content_type_name, '%title' => $node->title), WATCHDOG_WARNING, l(t('view'), 'node/'. $node->nid));
-      // If requested to, generate a delay so the spammer has to wait for a while.
+      watchdog('content', 'Spam detected by AntiSpam in %content-type-name: %title', array('%content-type-name' => $content_type_name, '%title' => $node->title), WATCHDOG_WARNING, l(t('view'), 'node/' . $node->nid));
+      // If requested to, generate a delay so the spammer has to wait for a
+      // while.
       if (($seconds = variable_get('antispam_antispambot_delay', 60)) > 0) {
-	    sleep($seconds);
+        sleep($seconds);
       }
     }
   }
 }
 
 /**
-* Implements hook_node_validate().
-*/
+ * Implements hook_node_validate().
+ */
 function antispam_node_validate($node, $form, &$form_state) {
-
-  // Ok, let's build a quick query to see if we can catch a spambot.
   global $user;
 
   $num_condition = 0;
@@ -904,8 +885,8 @@ function antispam_node_validate($node, $form, &$form_state) {
 }
 
 /**
-* Implements hook_node_delete().
-*/
+ * Implements hook_node_delete().
+ */
 function antispam_node_delete($node) {
   db_delete('antispam_spam_marks')
     ->condition('content_type', 'node')
@@ -920,25 +901,24 @@ function antispam_node_view($node, $view_mode, $langcode) {
   // $view_mode: 'full', 'teaser'
 
   if (antispam_is_spam_moderator($node->type)) {
-
     $links = array();
 
-    // adding publish/unpublish links
+    // Adding publish/unpublish links.
     if (variable_get('antispam_node_publish_links', 0)) {
       if ($node->status) {
-	    $links['antispam_node_unpublish'] = array('title' => t('Unpublish'), 'href' => 'antispam/node/'. $node->nid .'/unpublish');
+        $links['antispam_node_unpublish'] = array('title' => t('Unpublish'), 'href' => 'antispam/node/' . $node->nid . '/unpublish');
       }
       else {
-	    $links['antispam_node_publish'] = array('title' => t('Publish'), 'href' => 'antispam/node/'. $node->nid .'/publish');
+        $links['antispam_node_publish'] = array('title' => t('Publish'), 'href' => 'antispam/node/' . $node->nid . '/publish');
       }
     }
-    // adding submit ham/submit spam links
+    // Adding submit ham/submit spam links.
     if (variable_get('antispam_node_spam_links', 0)) {
       if (antispam_content_is_spam('node', $node->nid)) {
-        $links['antispam_node_ham'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit ham') : t('Mark as ham')), 'href' => 'antispam/node/'. $node->nid .'/submit-ham');
+        $links['antispam_node_ham'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit ham') : t('Mark as ham')), 'href' => 'antispam/node/' . $node->nid . '/submit-ham');
       }
       else {
-	    $links['antispam_node_spam'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit spam') : t('Mark as spam')), 'href' => 'antispam/node/'. $node->nid .'/submit-spam');
+        $links['antispam_node_spam'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit spam') : t('Mark as spam')), 'href' => 'antispam/node/' . $node->nid . '/submit-spam');
       }
     }
     $node->content['links']['node']['#links'] = 
@@ -946,18 +926,16 @@ function antispam_node_view($node, $view_mode, $langcode) {
   }
 }
 
-/******************************************************************************************
-*
-* Comment operations
-* 
-*******************************************************************************************/
+/*******************************************************************************
+ * Comment operations
+ ******************************************************************************/
 
 /**
-* Implements hook_comment_load().
-*/
+ * Implements hook_comment_load().
+ *
+ * Add signature and spaminess to the $comments object.
+ */
 function antispam_comment_load($comments) {
-  // add signature and spaminess to the $comments object
-
   foreach ($comments as $comment) {
     $rec = db_query("SELECT signature, spaminess FROM {antispam_spam_marks} WHERE content_type='comment' AND content_id=:content_id", array(':content_id' => $comment->cid))->fetchObject();
     if ($rec) {
@@ -971,16 +949,13 @@ function antispam_comment_load($comments) {
 }
 
 /**
-* Implements hook_comment_presave()
-*/
+ * Implements hook_comment_presave()
+ */
 function antispam_comment_presave($comment) {
-
-  // NOTE:
+  // NOTE: Called from comment_save().
   //
-  // called from comment_save().
-  //
-  // $comment->cid is not yet determined at this moment for a new comment
-  // if this is updating existing comment, then cid is already assigned.
+  // $comment->cid is not yet determined at this moment for a new comment.
+  // If this is updating existing comment, then cid is already assigned.
 
   $num_condition = 0;
   $debug_info = array();
@@ -1028,31 +1003,32 @@ function antispam_comment_presave($comment) {
 }
 
 /**
-* Implements hook_comment_insert().
-*/
+ * Implements hook_comment_insert().
+ */
 function antispam_comment_insert($comment) {
   _antispam_comment_save($comment);
 }
 
 /**
-* Implements hook_comment_update().
-*/
+ * Implements hook_comment_update().
+ */
 function antispam_comment_update($comment) {
   _antispam_comment_save($comment);
 }
 
 /**
-* Called from hook_comment_insert() and hook_comment_update()
-*/
+ * Called from hook_comment_insert() and hook_comment_update().
+ */
 function _antispam_comment_save($comment) {
-
-  // If anti-spam servie connections are not enabled, we have nothing else to do here.
+  // If anti-spam servie connections are not enabled, we have nothing else to
+  // do here.
   if (!variable_get('antispam_connection_enabled', 1)) {
     antispam_notify_moderators('node', $node, ($node->status ? TRUE : FALSE), FALSE);
     return;
   }
 
-  // Also quit asap, if current user has administration permission or permission to post without spam checking.
+  // Also quit asap, if current user has administration permission or
+  // permission to post without spam checking.
   if (antispam_is_spam_moderator('comments') || user_access('post with no antispam checking')) {
     antispam_notify_moderators('comment', $comment, ($comment->status == COMMENT_PUBLISHED ? TRUE : FALSE), FALSE);
     return;
@@ -1087,26 +1063,28 @@ function _antispam_comment_save($comment) {
       antispam_content_publish_operation('comment', $comment, 'unpublish', FALSE);
     }
 
-    // Since users won't see their replies published, show them a polite explanation on why.
+    // Since users won't see their replies published, show them a polite
+    // explanation on why.
     drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
 
     // Record the event to watchdog.
     if ($api_result[0] == ANTISPAM_API_RESULT_ERROR) {
-      watchdog('content', 'AntiSpam service seems to be down, comment queued for manual approval: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)));
+      watchdog('content', 'AntiSpam service seems to be down, comment queued for manual approval: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)));
     }
     else {
-      watchdog('content', 'Spam detected by AntiSpam in comment: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)));
-      // If requested to, generate a delay so the spammer has to wait for a while.
+      watchdog('content', 'Spam detected by AntiSpam in comment: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)));
+      // If requested to, generate a delay so the spammer has to wait for a
+      // while.
       if (($seconds = variable_get('antispam_antispambot_delay', 60)) > 0) {
-	    sleep($seconds);
+        sleep($seconds);
       }
     }
   }
 }
 
 /**
-* Implements hook_comment_delete().
-*/
+ * Implements hook_comment_delete().
+ */
 function antispam_comment_delete($comment) {
   db_delete('antispam_spam_marks')
     ->condition('content_type', 'comment')
@@ -1121,23 +1099,22 @@ function antispam_comment_view($comment, $view_mode, $langcode) {
   // $view_mode: 'full', 'teaser'
 
   if (antispam_is_spam_moderator('comments')) {
-
     $links = array();
 
     if (variable_get('antispam_comment_publish_links', 1)) {
       if ($comment->status == COMMENT_PUBLISHED) {
-	    $links['antispam_comment_unpublish'] = array('title' => t('Unpublish'), 'href' => 'antispam/comment/'. $comment->cid .'/unpublish');
+        $links['antispam_comment_unpublish'] = array('title' => t('Unpublish'), 'href' => 'antispam/comment/' . $comment->cid . '/unpublish');
       }
-      else if ($comment->status == COMMENT_NOT_PUBLISHED) {
-	    $links['antispam_comment_publish'] = array('title' => t('Publish'), 'href' => 'antispam/comment/'. $comment->cid .'/publish');
+      elseif ($comment->status == COMMENT_NOT_PUBLISHED) {
+        $links['antispam_comment_publish'] = array('title' => t('Publish'), 'href' => 'antispam/comment/' . $comment->cid . '/publish');
       }
     }
     if (variable_get('antispam_comment_spam_links', 1)) {
       if (antispam_content_is_spam('comment', $comment->cid)) {
-	    $links['antispam_comment_ham'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit ham') : t('Mark as ham')), 'href' => 'antispam/comment/'. $comment->cid .'/submit-ham');
+        $links['antispam_comment_ham'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit ham') : t('Mark as ham')), 'href' => 'antispam/comment/' . $comment->cid . '/submit-ham');
       }
       else {
-	    $links['antispam_comment_spam'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit spam') : t('Mark as spam')), 'href' => 'antispam/comment/'. $comment->cid .'/submit-spam');
+        $links['antispam_comment_spam'] = array('title' => (variable_get('antispam_connection_enabled', 1) ? t('Submit spam') : t('Mark as spam')), 'href' => 'antispam/comment/' . $comment->cid . '/submit-spam');
       }
     }
     $comment->content['links']['comment']['#links'] 
@@ -1145,10 +1122,6 @@ function antispam_comment_view($comment, $view_mode, $langcode) {
   }
 }
 
-
-
-
-
 /**
  * Get anti-spambot rules.
  *
@@ -1173,7 +1146,7 @@ function antispam_get_anti_spambot_rules() {
 /**
  * Check if anti-spambot options are enabled.
  *
- * @return boolean TRUE if enabled; FALSE otherwise.
+ * @return boolean
  */
 function antispam_is_anti_spambot_enabled() {
   $antispambot_rules = antispam_get_anti_spambot_rules();
@@ -1183,7 +1156,9 @@ function antispam_is_anti_spambot_enabled() {
 /**
  * Perform an anti-spambot action based on module settings.
  *
- * @param array Extra data, used here to enhance the logged information, for debugging purposes.
+ * @param array $debug_info
+ *   Extra data, used here to enhance the logged information, for debugging
+ *   purposes.
  */
 function antispam_anti_spambot_action($debug_info) {
   $antispambot_action = variable_get('antispam_antispambot_action', '503');
@@ -1200,7 +1175,7 @@ function antispam_anti_spambot_action($debug_info) {
 
   $items = array();
   foreach ($debug_info as $label => $value) {
-    $items[] = '<strong>'. check_plain($label) .'</strong>: '. check_plain($value);
+    $items[] = '<strong>' . check_plain($label) . '</strong>: ' . check_plain($value);
   }
 
   // From here on, the request is killed using different methods.
@@ -1208,7 +1183,7 @@ function antispam_anti_spambot_action($debug_info) {
     drupal_access_denied();
     $message = t('Spambot detected (action: 403 Forbidden).');
   }
-  else if ($antispambot_action == '403') {
+  elseif ($antispambot_action == '403') {
     @header('HTTP/1.0 403 Forbidden');
     print t('Access denied');
     $message = t('Spambot detected (action: 403 Forbidden).');
@@ -1228,14 +1203,17 @@ function antispam_anti_spambot_action($debug_info) {
 /**
  * Expand query for debugging purposes.
  *
- * @param string SQL statement.
- * @param mixed array or variable list of arguments.
+ * @param string $query
+ *   SQL statement.
+ * @param mixed
+ *   Array or variable list of arguments.
  */
 function _antispam_translate_query($query) {
   $args = func_get_args();
   array_shift($args);
   $query = db_prefix_tables($query);
-  if (isset($args[0]) && is_array($args[0])) { // 'All arguments in one array' syntax
+  // 'All arguments in one array' syntax.
+  if (isset($args[0]) && is_array($args[0])) {
     $args = $args[0];
   }
   _db_query_callback($args, TRUE);
@@ -1246,9 +1224,13 @@ function _antispam_translate_query($query) {
 /**
  * Check if specified content is marked as spam.
  *
- * @param string Content type; can be either 'node' or 'comment'.
- * @param integer Content ID; can be either a nid or a cid.
- * @return boolean TRUE if content is marked as spam; FALSE otherwise.
+ * @param string $content_type
+ *   Content type; can be either 'node' or 'comment' .
+ * @param integer $content_id
+ *   Content ID; can be either a nid or a cid.
+ *
+ * @return boolean
+ *   TRUE if content is marked as spam; FALSE otherwise.
  */
 function antispam_content_is_spam($content_type, $content_id) {
   return db_query_range('SELECT 1 FROM {antispam_spam_marks} WHERE content_type=:content_type AND content_id=:content_id', 0, 1, array(':content_type' => $content_type, ':content_id' => $content_id))->fetchField();
@@ -1257,9 +1239,13 @@ function antispam_content_is_spam($content_type, $content_id) {
 /**
  * Get moderator type required for specified content.
  *
- * @param string Content type; can be either 'node' or 'comment'.
- * @param integer Content ID; can be either a nid or a cid.
- * @return string Moderator Type or empty string if content is not found.
+ * @param string $content_type
+ *   Content type; can be either 'node' or 'comment' .
+ * @param integer $content_id
+ *   Content ID; can be either a nid or a cid.
+ *
+ * @return boolean
+ *   Moderator Type or empty string if content is not found.
  */
 function antispam_content_get_moderator_type($content_type, $content_id) {
   watchdog('antispam', 'antispam_content_get_moderator_type is called. type=' . $content_type . ', id=' . $content_id);
@@ -1269,7 +1255,7 @@ function antispam_content_get_moderator_type($content_type, $content_id) {
       $moderator_type = '';
     }
   }
-  else if ($content_type == 'comment') {
+  elseif ($content_type == 'comment') {
     $has_rows = db_query_range('SELECT 1 FROM {comment} WHERE cid=:cid', 0, 1, array(':cid' => $content_id))->fetchField();
     $moderator_type = $has_rows ? 'comments' : '';
   }
@@ -1282,8 +1268,11 @@ function antispam_content_get_moderator_type($content_type, $content_id) {
 /**
  * Get the types the current user is allowed to moderate.
  *
- * @param object The account to check; use current user if not given.
- * @return array Moderator Types.
+ * @param object $account
+ *   The account to check; use current user if not given.
+ *
+ * @return array
+ *   Moderator Types.
  */
 function antispam_get_moderator_types($account = NULL) {
   global $user;
@@ -1298,7 +1287,7 @@ function antispam_get_moderator_types($account = NULL) {
     $node_types = node_type_get_names();
   }
 
-  // suppress warning message
+  // Suppress warning message.
   $moderator_types[$account->uid] = NULL;
 
   if (!isset($moderator_types[$account->uid])) {
@@ -1309,7 +1298,7 @@ function antispam_get_moderator_types($account = NULL) {
     }
     else {
       foreach ($node_types as $type => $name) {
-        if (user_access('moderate spam in nodes of type '. $node_types[$type], $account)) {
+        if (user_access('moderate spam in nodes of type ' . $node_types[$type], $account)) {
           $moderator_types[$account->uid][$type] = $name;
         }
       }
@@ -1325,9 +1314,13 @@ function antispam_get_moderator_types($account = NULL) {
 /**
  * Is current user spam moderator?
  *
- * @param string Moderator Type (comments, node type or NULL).
- * @param object The account to check; use current user if not given.
- * @return boolean TRUE if current user is moderator of specified type; FALSE otherwise.
+ * @param string $moderator_type
+ *   Moderator Type - comments, node type or NULL.
+ * @param object $account
+ *   The user account to check; use current user if not given.
+ *
+ * @return boolean
+ *   TRUE if current user is moderator of specified type; FALSE otherwise.
  */
 function antispam_is_spam_moderator($moderator_type = NULL, $account = NULL) {
   global $user;
@@ -1344,10 +1337,14 @@ function antispam_is_spam_moderator($moderator_type = NULL, $account = NULL) {
 /**
  * Notify moderators of new/updated content, only content needing approval or nothing at all.
  *
- * @param string Content type; can be either 'node' or 'comment'.
- * @param object Content object.
- * @param boolean TRUE if content is in published status.
- * @param boolean TRUE if content has been marked as spam.
+ * @param string $content_type
+ *   Content type; can be either 'node' or 'comment' .
+ * @param object $content
+ *   The content object to work on.
+ * @param boolean $is_published
+ *   TRUE if content is in published status.
+ * @param boolean $is_spam
+ *   TRUE if content has been marked as spam.
  */
 function antispam_notify_moderators($content_type, $content, $is_published, $is_spam) {
   global $user, $base_url;
@@ -1367,24 +1364,24 @@ function antispam_notify_moderators($content_type, $content, $is_published, $is_
   }
   else {
     $moderator_types = antispam_get_moderator_types();
-    $moderator_permission = 'moderate spam in nodes of type '. $moderator_types[$content->type];
+    $moderator_permission = 'moderate spam in nodes of type ' . $moderator_types[$content->type];
     $administer_permission = 'administer nodes';
   }
 
   // Obtain list of moderators of the specified content type.
-  $sql = 'SELECT u.uid, u.name, u.mail, m.email_for'.
-          ' FROM {role_permission} p'.
-         ' INNER JOIN {users_roles} r ON r.rid = p.rid'.
-         ' INNER JOIN {users} u ON u.uid = r.uid OR u.uid = 1'.
-          ' LEFT JOIN {antispam_moderator} m ON m.uid = u.uid'.
-         ' WHERE p.permission LIKE \'%:perm1%\''.
-            ' OR p.permission LIKE \'%:perm2%\'';
+  $sql = 'SELECT u.uid, u.name, u.mail, m.email_for'
+    . ' FROM {role_permission} p'
+    . '   INNER JOIN {users_roles} r ON r.rid = p.rid'
+    . '   INNER JOIN {users} u ON u.uid = r.uid OR u.uid = 1'
+    . '   LEFT JOIN {antispam_moderator} m ON m.uid = u.uid'
+    . ' WHERE p.permission LIKE \'%:perm1%\''
+    . ' OR p.permission LIKE \'%:perm2%\'';
   $result = db_query($sql, array(':perm1' => $moderator_permission, ':perm2' => $administer_permission));
   $moderators = array();
   foreach ($result as $u) {
-    // if a moderator submit a new node/comment, then exclude him/her from the list
+    // If a moderator submit a new node/comment, then exclude them from the
+    // list.
     if ($u->uid != $user->uid) { 
-       
       $moderators[$u->uid] = array(
         'name' => $u->name,
         'email_to' => $u->mail,
@@ -1392,14 +1389,15 @@ function antispam_notify_moderators($content_type, $content, $is_published, $is_
       );
     }
   }
-  // check to see if we need to add the admin to the notification moderator list
-  $sql = 'SELECT u.uid, u.name, u.mail, m.email_for'.
-         ' FROM {users} u'.
-         ' LEFT JOIN {antispam_moderator} m ON m.uid = u.uid'.
-         ' WHERE u.uid=1';
+  // Check to see if we need to add the admin to the notification moderator
+  // list.
+  $sql = 'SELECT u.uid, u.name, u.mail, m.email_for'
+    . ' FROM {users} u'
+    . ' LEFT JOIN {antispam_moderator} m ON m.uid = u.uid'
+    . ' WHERE u.uid=1';
   $u = db_query($sql)->fetchObject();
-  if ($u) {
-    // if the admin submit a new node/comment, then exclude from the list
+  if (!empty($u)) {
+    // If the admin submit a new node/comment, then exclude from the list.
     if ($u->uid != $user->uid) { 
       $moderators[$u->uid] = array(
         'name' => $u->name,
@@ -1409,7 +1407,8 @@ function antispam_notify_moderators($content_type, $content, $is_published, $is_
     }
   }
 
-  // Extract unique email addresses and ignore those who have requested to not get e-mail notifications.
+  // Extract unique email addresses and ignore those who have requested to not
+  // get e-mail notifications.
   $unique_emails = array();
   foreach ($moderators as $uid => $moderator) {
     if ($moderator['email_for'] == 'all' || ($moderator['email_for'] == 'approval' && !$is_published)) {
@@ -1422,19 +1421,19 @@ function antispam_notify_moderators($content_type, $content, $is_published, $is_
     return;
   }
 
-  // If this is about a comment, try to load the node.
-  // Also, prepare arguments for notification message.
+  // If this is about a comment, try to load the node. Also, prepare arguments
+  // for notification message.
   $site_name = variable_get('site_name', t('Drupal'));
   if ($content_type == 'comment') {
     if (!($node = antispam_content_load('node', $content->nid))) {
-      watchdog('antispam', 'An error has ocurred while trying to notify moderators about a comment. The associated node could not be loaded.', array(), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, array('fragment' => 'comment-'. $content->cid)));
+      watchdog('antispam', 'An error has ocurred while trying to notify moderators about a comment. The associated node could not be loaded. ', array(), WATCHDOG_NOTICE, l(t('view'), 'node/' . $content->nid, array('fragment' => 'comment-' . $content->cid)));
       return;
     }
     $message_args = array(
       '@title-label' => t('Subject'),
       '@content-title' => $content->subject,
       '@content-type' => t('comment'),
-      '!content-link' => url('node/'. $content->nid, array('fragment' => 'comment-'. $content->cid, 'absolute' => TRUE))
+      '!content-link' => url('node/' . $content->nid, array('fragment' => 'comment-' . $content->cid, 'absolute' => TRUE))
     );
   }
   else {
@@ -1442,10 +1441,10 @@ function antispam_notify_moderators($content_type, $content, $is_published, $is_
       '@title-label' => t('Title'),
       '@content-title' => $content->title,
       '@content-type' => $moderator_types[$content->type],
-      '!content-link' => url('node/'. $content->nid, array('absolute' => TRUE))
+      '!content-link' => url('node/' . $content->nid, array('absolute' => TRUE))
     );
   }
-  $message_args['@content-status'] = ($is_published ? t('published') : t('not published')) . ($is_spam ? ' ('. t('marked as spam') .')' : '');
+  $message_args['@content-status'] = ($is_published ? t('published') : t('not published')) . ($is_spam ? ' (' . t('marked as spam') . ')' : '');
   $message_args['@site-name'] = $site_name;
   $message_args['!site-link'] = $base_url . base_path();
 
@@ -1473,7 +1472,6 @@ EOT
 
   // Send e-mails.
   foreach ($unique_emails as $email_to => $uid) {
-
     $message_body = str_replace('@user-name', check_plain($moderators[$uid]['name']), $message_body);
     $params = array(
       'body' => $message_body,
@@ -1500,14 +1498,13 @@ function antispam_mail($key, &$message, $params) {
   $message['body'][] = $params['body'];
 }
 
-/******************************************************************************************
-*
-* User operations
-* 
-*******************************************************************************************/
+/*******************************************************************************
+ * User operations.
+ ******************************************************************************/
+
 /**
- * Returns the array of fields for AntiSpam block configuration
- * Called from hook_block_view(), hook_block_save() and hook_block_configure()
+ * Returns the array of fields for AntiSpam block configuration.
+ * Called from hook_block_view(), hook_block_save() and hook_block_configure().
  */
 function _antispam_get_email_for_options() {
   return array(
@@ -1617,7 +1614,8 @@ function antispam_user_delete($account) {
 /**
  * Format the 'Counting since' date.
  *
- * @return string Counting since date formatted according to module settings.
+ * @return string
+ *   Counting since date formatted according to module settings.
  */
 function antispam_get_counting_since() {
   $since = variable_get('antispam_counter_since', array('day' => date('j'), 'month' => date('n'), 'year' => date('Y')));
@@ -1634,8 +1632,8 @@ function antispam_get_counting_since() {
 }
 
 /**
- * Returns the array of fields for AntiSpam block configuration
- * Called from hook_block_view(), hook_block_save() and hook_block_configure()
+ * Returns the array of fields for AntiSpam block configuration.
+ * Called from hook_block_view(), hook_block_save() and hook_block_configure().
  */
 function _antispam_get_block_fields() {
   return array(
@@ -1681,11 +1679,11 @@ function antispam_block_configure($delta = '') {
     $form = array();
     $form['description'] = array(
       '#type' => 'item',
-      '#markup' => '<div class="description">'. t('These options allow to customize the look of this <em>antispam spam counter</em> block.') .'</div>'
+      '#markup' => '<div class="description">' . t('These options allow to customize the look of this <em>antispam spam counter</em> block.') . '</div>'
     );
-    $block_settings = variable_get('antispam_blocks_'. $delta, FALSE);
+    $block_settings = variable_get('antispam_blocks_' . $delta, FALSE);
     foreach ($block_fields as $field_key => $field_info) {
-      $field_name = 'antispam_blocks_'. $delta .'_'. $field_key;
+      $field_name = 'antispam_blocks_' . $delta . '_' . $field_key;
       $form[$field_name] = array();
       foreach ($field_info as $key => $value) {
         $form[$field_name][$key] = $value;
@@ -1706,10 +1704,10 @@ function antispam_block_save($delta = '', $edit = array()) {
   if ($delta >= 0 && $delta < variable_get('antispam_blocks_counter', 1)) {
     $block_settings = array();
     foreach ($block_fields as $field_key => $field_info) {
-      $field_name = 'antispam_blocks_'. $delta .'_'. $field_key;
+      $field_name = 'antispam_blocks_' . $delta . '_' . $field_key;
       $block_settings[$field_key] = $edit[$field_name];
     }
-    variable_set('antispam_blocks_'. $delta, $block_settings);
+    variable_set('antispam_blocks_' . $delta, $block_settings);
   }
 }
 
@@ -1719,17 +1717,18 @@ function antispam_block_save($delta = '', $edit = array()) {
 function antispam_block_view($delta = '') {
   $block_fields = _antispam_get_block_fields();
   if ($delta >= 0 && $delta < variable_get('antispam_blocks_counter', 1)) {
-    $block_settings = variable_get('antispam_blocks_'. $delta, FALSE);
+    $block_settings = variable_get('antispam_blocks_' . $delta, FALSE);
     if (!$block_settings) {
       $block_settings = array();
     }
     $block_args = array(
-      'content' => '', // Built below.
+      'content' => '',
       'counter' => antispam_get_total_counter(ANTISPAM_COUNT_SPAM_DETECTED),
       'since'   => antispam_get_counting_since(),
-      'text'    => '', // Built below.
-      'image'   => '', // Built below.
-      'block'   => array('delta' => $delta) // completed below with current block settings.
+      'text'    => '',
+      'image'   => '',
+      // Completed below with current block settings.
+      'block'   => array('delta' => $delta),
     );
     foreach ($block_fields as $field_key => $field_info) {
       if (!isset($block_settings[$field_key])) {
@@ -1747,11 +1746,11 @@ function antispam_block_view($delta = '') {
       'html' => t('@site_name is proudly protected by <a href="!antispam"@target>AntiSpam</a>, %spams caught since @since', array('@site_name' => $sitename, '!antispam' => url('http://drupal.org/project/antispam'), '@target' => $target, '%spams' => format_plural($block_args['counter'], '1 spam', '@count spams'), '@since' => $block_args['since']))
     );
     $title_text = $block_args['text']['plain'];
-    $image_url = base_path() . drupal_get_path('module', 'antispam') .'/antispam.png';
-    $block_args['image'] = '<img src="'. $image_url .'" title="'. $title_text .'" alt="'. $title_text .'" />';
+    $image_url = base_path() . drupal_get_path('module', 'antispam') . '/antispam.png';
+    $block_args['image'] = '<img src="' . $image_url . '" title="' . $title_text . '" alt="' . $title_text . '" />';
 
     if ($block_settings['type'] == 'image') {
-      $block_args['content'] = '<a href="http://drupal.org/project/antispam" title="'. $title_text .'"'. $target .'>'. $block_args['image'] .'</a>';
+      $block_args['content'] = '<a href="http://drupal.org/project/antispam" title="' . $title_text . '"' . $target . '>' . $block_args['image'] . '</a>';
     }
     else {
       $block_args['content'] = $block_args['text']['html'];
@@ -1794,16 +1793,19 @@ function antispam_theme() {
 /**
  * Allow themes customize the content of the antispam spam counter block.
  *
- * @param array arguments where each element is:
- *              content: String; the completely built block content.
- *              counter: Integer; the current spam counter.
- *              since  : String; the formatted 'counting since' date.
- *              text   : Array; with 2 subarrays defined as follows:
- *                       plain: Array with 2 elements ('short' and 'long').
- *                       html : Array with 2 elements ('short' and 'long').
- *              image  : String; the completely built IMG tag.
- *              block  : Array; Block settings.
- * @return string The content of the block.
+ * @param array $args
+ *   A nested array where each element is:
+ *     content: String; the completely built block content.
+ *     counter: Integer; the current spam counter.
+ *     since  : String; the formatted 'counting since' date.
+ *     text   : Array; with 2 subarrays defined as follows:
+ *              plain: Array with 2 elements ('short' and 'long').
+ *              html : Array with 2 elements ('short' and 'long').
+ *     image  : String; the completely built IMG tag.
+ *     block  : Array; Block settings.
+ *
+ * @return string
+ *   The content of the block.
  */
 function theme_antispam_counter_block($args) {
   return $args['content'];
@@ -1812,9 +1814,13 @@ function theme_antispam_counter_block($args) {
 /**
  * Load a node or a comment.
  *
- * @param string Content type; can be either 'node' or 'comment'.
- * @param integer Content ID; can be either a nid or a cid.
- * @return mixed An object with requested content; FALSE on failure.
+ * @param string $content_type
+ *   Content type; can be either 'node' or 'comment' .
+ * @param integer $content_id
+ *   Content ID; can be either a nid or a cid.
+ *
+ * @return mixed
+ *  An object with requested content; FALSE on failure.
  */
 function antispam_content_load($content_type, $content_id) {
 
@@ -1832,9 +1838,13 @@ function antispam_content_load($content_type, $content_id) {
 /**
  * Delete a node or a comment.
  *
- * @param string Content type; can be either 'node' or 'comment'.
- * @param integer Content ID; can be either a nid or a cid.
- * @return boolean TRUE if specified was there; FALSE otherwise.
+ * @param string $content_type
+ *   Content type; can be either 'node' or 'comment' .
+ * @param integer $content_id
+ *   Content ID; can be either a nid or a cid.
+ *
+ * @return boolean
+ *  TRUE if specified was there; FALSE otherwise.
  */
 function antispam_content_delete($content_type, $content_id) {
   module_load_include('inc', 'comment', 'comment.admin'); 
@@ -1843,7 +1853,7 @@ function antispam_content_delete($content_type, $content_id) {
     node_delete($content_id);
     return TRUE;
   }
-  else if ($content_type == 'comment') {
+  elseif ($content_type == 'comment') {
     comment_delete($content_id);
     return TRUE;
   }
@@ -1851,10 +1861,10 @@ function antispam_content_delete($content_type, $content_id) {
 }
 
 /**
- * Clear Drupal cache.
+ * Implements hook_clear_cache().
  *
- * This function needs to be called so anonymous users get updated content
- * when certain operations have been executed.
+ * This function needs to be called so anonymous users get updated content when
+ * certain operations have been executed.
  */
 function antispam_clear_cache() {
   static $already_done = FALSE;
@@ -1867,41 +1877,47 @@ function antispam_clear_cache() {
 /**
  * Mark content as spam or remove the mark.
  *
- * @param string Content type; can be either 'node' or 'comment'.
- * @param object Content object.
- * @param string Operation; it can be 'submit-spam' or 'submit-ham'.
- * @param boolean TRUE to log action (default); FALSE otherwise (ie. the caller logs the action).
- * @param string Signature; Currently DEFENSIO is the only one that returns this.
- * @param float Spaminess; Currently DEFENSIO is the only one that returns this.
+ * @param string $content_type
+ *   Content type; can be either 'node' or 'comment'.
+ * @param object $content
+ *   Content object.
+ * @param string $op
+ *   Operation; it can be 'submit-spam' or 'submit-ham'.
+ * @param boolean $log_action
+ *   TRUE to log action (default), otherwise the caller logs the action.
  */
 function antispam_content_spam_operation($content_type, $content, $op, $log_action = TRUE) {
-  watchdog('antispam', 'antispam_content_spam_operation: type=' . $content_type . '. op=' . $op);
+  watchdog('antispam', 'antispam_content_spam_operation: type=' . $content_type . ' . op=' . $op);
   if ($content_type == 'node') {
     global $user;
     $content_id = $content->nid;
     $content_title = $content->title;
-    $content_link = l(t('view'), 'node/'. $content->nid);
+    $content_link = l(t('view'), 'node/' . $content->nid);
     $user_mail = (isset($user->mail) ? $user->mail : '');
   }
-  else { // comment
+  // Comment.
+  else {
     $content_id = $content->cid;
     $content_title = $content->subject;
-    $content_link = l(t('view'), 'node/'. $content->nid, array('fragment' => 'comment-'. $content->cid));
+    $content_link = l(t('view'), 'node/' . $content->nid, array('fragment' => 'comment-' . $content->cid));
     $user_mail = $content->mail;
   }
 
   watchdog('antispam', 'antispam_content_spam_operation: content_id=' . $content_id);
-  if(!isset($content->signature)) $content->signature = '';
-  if(!isset($content->spaminess)) $content->spaminess = 0.0;
+  if (!isset($content->signature)) {
+    $content->signature = '';
+  }
+  if (!isset($content->spaminess)) {
+    $content->spaminess = 0.0;
+  }
 
   if ($op == 'submit-spam') {
-
     if (variable_get('antispam_connection_enabled', 1)) {
+      // Defensio.
       if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
-        // DEFENSIO
         if ($content->signature == '') {
           // In we do not have the content signature, then we first need to
-          // audit the comment and obtain the signature
+          // audit the comment and obtain the signature.
           $api_result = antispam_api_cmd_comment_check($content_type, $content);
           $content->signature = $api_result[1];
           $content->spaminess = $api_result[2];
@@ -1926,14 +1942,15 @@ function antispam_content_spam_operation($content_type, $content, $op, $log_acti
       ))
       ->execute();
   }
-  else { // submit-ham
 
+  // Submit-ham.
+  else {
     if (variable_get('antispam_connection_enabled', 1)) {
+      // Defensio.
       if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
-        // DEFENSIO
         if ($content->signature == '') {
           // In we do not have the content signature, then we first need to
-          // audit the comment and obtain the signature
+          // audit the comment and obtain the signature.
           $api_result = antispam_api_cmd_comment_check($content_type, $content);
           $content->signature = $api_result[1];
           $content->spaminess = $api_result[2];
@@ -1960,19 +1977,23 @@ function antispam_content_spam_operation($content_type, $content, $op, $log_acti
 /**
  * Execute content publish/unpublish operations.
  *
- * @param string Content type; it can be 'node' or 'comment'.
- * @param object Content object.
- * @param string Operation; it can be 'publish' or 'unpublish'.
- * @param boolean TRUE to log action (default); FALSE otherwise (ie. the caller logs the action).
+ * @param string $content_type
+ *   Content type; it can be 'node' or 'comment' .
+ * @param object $content
+ *   Content object.
+ * @param string $op
+ *   Operation; it can be 'publish' or 'unpublish' .
+ * @param boolean $log_action
+ *   TRUE to log action (default), otherwise the caller logs the action.
  */
 function antispam_content_publish_operation($content_type, $content, $op, $log_action = TRUE) {
   module_load_include('inc', 'comment', 'comment.admin'); 
 
   if ($content_type == 'node') {
-    // This code snippet is based on node.module::node_admin_nodes_submit()
+    // This code snippet is based on node.module::node_admin_nodes_submit().
     // Only the node record is updated, no other hooks are invoked.
 
-    // perform the update action.
+    // Perform the update action.
     db_update('node')
       ->fields(array(
         'status' => ($op == 'publish'? 1:0)
@@ -1982,11 +2003,12 @@ function antispam_content_publish_operation($content_type, $content, $op, $log_a
 
     if ($log_action) {
       $action = ($op == 'publish' ? t('Content published') : t('Content unpublished'));
-      watchdog('content', '@action: @title', array('@action' => $action, '@title' => $content->title), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid));
+      watchdog('content', '@action: @title', array('@action' => $action, '@title' => $content->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $content->nid));
     }
   }
-  else { // comment
 
+  // Comment.
+  else {
     if ($op == 'publish') {
       comment_publish_action($content, array('cid' => $content->cid));
       db_update('comment')
@@ -1995,7 +2017,7 @@ function antispam_content_publish_operation($content_type, $content, $op, $log_a
         ->execute();
       module_invoke_all('comment_published', $content);
     }
-    else if ($op == 'unpublish') {
+    elseif ($op == 'unpublish') {
       comment_unpublish_action($content, array('cid' => $content->cid));
       db_update('comment')
         ->fields(array('status' => COMMENT_NOT_PUBLISHED))
@@ -2004,12 +2026,12 @@ function antispam_content_publish_operation($content_type, $content, $op, $log_a
       // Allow modules to respond to the updating of a comment.
       module_invoke_all('comment_unpublished', $content);
     }
-    // update comment statistics.
+    // Update comment statistics.
     _comment_update_node_statistics($content->nid);
 
     if ($log_action) {
       $action = ($op == 'publish' ? t('Comment published') : t('Comment unpublished'));
-      watchdog('content', '@action: %subject', array('@action' => $action, '%subject' => $content->subject), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, array('fragment' => 'comment-'. $content->cid)));
+      watchdog('content', '@action: %subject', array('@action' => $action, '%subject' => $content->subject), WATCHDOG_NOTICE, l(t('view'), 'node/' . $content->nid, array('fragment' => 'comment-' . $content->cid)));
     }
   }
   antispam_clear_cache();
@@ -2018,20 +2040,23 @@ function antispam_content_publish_operation($content_type, $content, $op, $log_a
 /**
  * Prepare comment data for AntiSpam requests.
  *
- * @param $content_type: string 'node' or 'comment' or 'other'
- * @param $content: object $node or $comment or $other
- * @param $provider: integer AKISMET_SERVIE/TYPEPAD_SERVICE/DEFENSIO_SERVICE
+ * @param string $content_type
+ *   Content type; it can be 'node' or 'comment' .
+ * @param object $content
+ *   Content object.
+ * @param integer $provider
+ *   AKISMET_SERVIE/TYPEPAD_SERVICE/DEFENSIO_SERVICE
+ *
  * @return array
  */
 function antispam_prepare_comment_data($content_type, $content, $provider) {
   // Prepare data that is common to nodes/comments.
   global $user, $base_url;
 
+  // Defensio.
   if ($provider == DEFENSIO_SERVICE) {
-    // DEFENSIO
-    if (isset($content->signature) && $content->signature != '') { // 2011.1.8
-    // if ($content->signature != '') {
-      // for submit spam/ham, we only needs signature
+    if (isset($content->signature) && $content->signature != '') {
+      // For submit spam/ham, we only needs signature.
       $comment_data = array(
         'signature' => $content->signature,
       );
@@ -2049,24 +2074,24 @@ function antispam_prepare_comment_data($content_type, $content, $provider) {
         'comment-author' => $content->name,
       );
       if ($content_type == 'comment') {
-        $comment_data['permalink'] = url('node/'. $content->nid, array('fragment' => 'comment-'. $content->cid));
+        $comment_data['permalink'] = url('node/' . $content->nid, array('fragment' => 'comment-' . $content->cid));
         $comment_data['comment-author-email'] = $content->mail;
         $comment_data['comment-author-url'] = $content->homepage;
         $comment_data['comment-content'] = render($content->comment_body[$content->language][0]['value']);
-        // date when the original article was created
+        // Date when the original article was created.
         $node_created = db_query("SELECT created FROM {node} WHERE nid=:nid", array(':nid' => $content->nid))->fetchField();
         $comment_data['article-date'] = date("Y/m/d", $node_created);
         $comment_data['comment-type'] = 'comment';
       }
-      else if ($content_type == 'node') {
-        $comment_data['permalink'] = url('node/'. $content->nid);
+      elseif ($content_type == 'node') {
+        $comment_data['permalink'] = url('node/' . $content->nid);
         $comment_data['comment-author_email'] = (isset($user->mail) ? $user->mail : '');
         $comment_data['comment-author_url'] = '';
         $comment_data['comment-content'] = render($content->body[$content->language][0]['value']);
         $comment_data['article-date'] = date("Y/m/d");  // now
         $comment_data['comment-type'] = 'other';
       }
-      else { // other
+      else {
         $comment_data['permalink'] = '';
         $comment_data['comment-author_email'] = (isset($user->mail) ? $user->mail : isset($content->mail)? $content->mail : '');
         $comment_data['comment-author_url'] = (isset($content->homepage) ? $content->homepage : '');
@@ -2087,8 +2112,8 @@ function antispam_prepare_comment_data($content_type, $content, $provider) {
       }
     }
   }
+  // Akismet or Typepad.
   else {
-    // AKISMET, TYPEPAD
     $comment_data = array(
       // IP address of the comment submitter.
       'user_ip' => (!empty($content->hostname) ? $content->hostname : ip_address()),
@@ -2096,24 +2121,25 @@ function antispam_prepare_comment_data($content_type, $content, $provider) {
       'user_agent' => $_SERVER['HTTP_USER_AGENT'],
       // The content of the HTTP_REFERER header should be sent here.
       'referrer' => $_SERVER['HTTP_REFERER'],
-      // May be blank, comment, trackback, pingback, or a made up value like "registration".
+      // May be blank, comment, trackback, pingback, or a made up value like
+      // "registration".
       'comment_type' => '',
       // Submitted name with the comment.
       'comment_author' => $content->name,
     );
     if ($content_type == 'comment') {
-      $comment_data['permalink'] = url('node/'. $content->nid, array('fragment' => 'comment-'. $content->cid));
+      $comment_data['permalink'] = url('node/' . $content->nid, array('fragment' => 'comment-' . $content->cid));
       $comment_data['comment_author_email'] = $content->mail;
       $comment_data['comment_author_url'] = $content->homepage;
       $comment_data['comment_content'] = render($content->comment_body[$content->language][0]['value']);
     }
-    else if ($content_type == 'node') {
-      $comment_data['permalink'] = url('node/'. $content->nid);
+    elseif ($content_type == 'node') {
+      $comment_data['permalink'] = url('node/' . $content->nid);
       $comment_data['comment_author_email'] = (isset($user->mail) ? $user->mail : '');
       $comment_data['comment_author_url'] = '';
       $comment_data['comment_content'] = render($content->body[$content->language][0]['value']);
     }
-    else { // other
+    else {
       $comment_data['permalink'] = '';
       $comment_data['comment-author_email'] = (isset($user->mail) ? $user->mail : isset($content->mail)? $content->mail : '');
       $comment_data['comment-author_url'] = (isset($content->homepage) ? $content->homepage : '');
@@ -2124,7 +2150,7 @@ function antispam_prepare_comment_data($content_type, $content, $provider) {
 }
 
 /**
- * Parse response data (in yaml format) from DEFENSIO service
+ * Parse response data (in yaml format) from Defensio service.
  */
 function _antispam_parse_yaml_response($response, $field = '') {
   $lines = explode("\n", $response);
@@ -2147,15 +2173,19 @@ function _antispam_parse_yaml_response($response, $field = '') {
   }
 }
 
-/************************************************************\
-  AntiSpam API implementation
-\************************************************************/
+/*******************************************************************************
+ * AntiSpam API implementation
+ ******************************************************************************/
 
 /**
- * AntiSpam API: Key Verification 
+ * AntiSpam API: Key Verification.
  *
- * @param string API Key.
- * @return integer See constants ANTISPAM_API_RESULT_xxx.
+ * @param string $key
+ *   API Key.
+ * @param integer $provider
+ *
+ * @return integer
+ *   See constants ANTISPAM_API_RESULT_xxx.
  */
 function antispam_api_cmd_verify_key($key, $provider) {
   global $base_url;
@@ -2165,8 +2195,8 @@ function antispam_api_cmd_verify_key($key, $provider) {
   $api_host = antispam_get_api_host($provider);
   if ($provider == DEFENSIO_SERVICE) {
     // DEFENSIO
-    $request = 'owner-url='. $base_url . base_path();
-    $response = _antispam_api_http_post($request, $api_host, '/blog/'. DEFENSIO_API_VERSION .'/validate-key/' . $key . '.yaml');
+    $request = 'owner-url=' . $base_url . base_path();
+    $response = _antispam_api_http_post($request, $api_host, '/blog/' . DEFENSIO_API_VERSION . '/validate-key/' . $key . ' .yaml');
     if (!isset($response[1])) {
       watchdog('antispam', "verifying a key: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return ANTISPAM_API_RESULT_ERROR;
@@ -2175,8 +2205,8 @@ function antispam_api_cmd_verify_key($key, $provider) {
   }
   else {
     // AKISMET, TYPEPAD
-    $request = 'key='. $key .'&blog='. $base_url . base_path();
-    $response = _antispam_api_http_post($request, $api_host, '/'. AKISMET_API_VERSION .'/verify-key');
+    $request = 'key=' . $key . '&blog=' . $base_url . base_path();
+    $response = _antispam_api_http_post($request, $api_host, '/' . AKISMET_API_VERSION . '/verify-key');
     if (!isset($response[1])) {
       watchdog('antispam', "verifying a key: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return ANTISPAM_API_RESULT_ERROR;
@@ -2185,13 +2215,11 @@ function antispam_api_cmd_verify_key($key, $provider) {
   }
 }
 
-
 /**
- * AntiSpam API: Generic Data Check 
+ * AntiSpam API: Generic Data Check.
  *
- * return: -1  Error
- *          0  Ham
- *          1  Spam
+ * @return integer
+ *   -1 = Error, 0 = Ham, 1 = Spam.
  */
 function antispam_api_cmd_spam_check($body, $name = NULL, $mail = NULL, $homepage = NULL) {
   $provider = antispam_get_service_provider();
@@ -2208,26 +2236,29 @@ function antispam_api_cmd_spam_check($body, $name = NULL, $mail = NULL, $homepag
   );
   $api_result = antispam_api_cmd_comment_check('other', $content);
   if ($api_result[0] == ANTISPAM_API_RESULT_IS_HAM) {
-    return 0; // Ham
+    return 0;
   }
-  else if ($api_result[0] == ANTISPAM_API_RESULT_IS_SPAM) {
-    return 1; // Spam
+  elseif ($api_result[0] == ANTISPAM_API_RESULT_IS_SPAM) {
+    return 1;
   }
+  // Error - shouldn't happen.
   else {
-    return -1; // Error
+    return -1;
   }
 }
 
 /**
- * AntiSpam API: Comment Check 
+ * AntiSpam API: Comment Check.
  *
- * @param $content_type: string 'node' or 'comment' or 'other'
- * @param $content: object $node or $comment
+ * @param string $content_type
+ *   Content type; it can be 'node' or 'comment' .
+ * @param object $content
+ *   Content object.
  *
  * @return array 
- *           result[0] - return status (int) See constants ANTISPAM_API_RESULT_xxx.
- *           result[1] - signature (string) - DEFENSIO only
- *           result[2] - spaminess (float) value between 0 to 1 - DEFENSIO only
+ *   result[0] - return status (int) See constants ANTISPAM_API_RESULT_xxx.
+ *   result[1] - signature (string) - DEFENSIO only.
+ *   result[2] - spaminess (float) value between 0 to 1 - DEFENSIO only.
  */
 function antispam_api_cmd_comment_check($content_type, $content) {
   if (!variable_get('antispam_connection_enabled', 1)) {
@@ -2243,11 +2274,11 @@ function antispam_api_cmd_comment_check($content_type, $content) {
     return array(ANTISPAM_API_RESULT_ERROR);
   }
 
+  // Defensio.
   if ($provider == DEFENSIO_SERVICE) {
-    // DEFENSIO
     $comment_data = array_merge(_antispam_api_prepare_request_data(), $comment_data);
     $query_string = _antispam_api_build_query_string($comment_data);
-    $response = _antispam_api_http_post($query_string, $api_host, '/app/'. DEFENSIO_API_VERSION .'/audit-comment/' . $api_key . '.yaml');
+    $response = _antispam_api_http_post($query_string, $api_host, '/app/' . DEFENSIO_API_VERSION . '/audit-comment/' . $api_key . ' .yaml');
     if (!isset($response[1])) {
       watchdog('antispam', "cheking a content failed: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return array(ANTISPAM_API_RESULT_ERROR);
@@ -2266,20 +2297,23 @@ function antispam_api_cmd_comment_check($content_type, $content) {
       return array(ANTISPAM_API_RESULT_ERROR);
     }
   }
+
+  // Akismet or Typepad.
   else {
-    // AKISMET, TYPEPAD
     $comment_data = array_merge(_antispam_api_prepare_request_data(), $comment_data);
     $query_string = _antispam_api_build_query_string($comment_data);
-    $host = $api_key .'.'. $api_host;
-    $response = _antispam_api_http_post($query_string, $host, '/'. AKISMET_API_VERSION .'/comment-check');
+    $host = $api_key . ' . ' . $api_host;
+    $response = _antispam_api_http_post($query_string, $host, '/' . AKISMET_API_VERSION . '/comment-check');
 
     if (!isset($response[1])) {
       watchdog('antispam', "cheking a content failed: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return array(ANTISPAM_API_RESULT_ERROR);
     }
     $result[0] = ('true' == $response[1] ? ANTISPAM_API_RESULT_IS_SPAM : ANTISPAM_API_RESULT_IS_HAM);
-    $result[1] = '';  // signature
-    $result[2] = 0.0; // spaminess
+    // Signature.
+    $result[1] = '';
+    // Spaminess.
+    $result[2] = 0.0;
     return $result;
   }
 }
@@ -2287,10 +2321,13 @@ function antispam_api_cmd_comment_check($content_type, $content) {
 /**
  * AntiSpam API: Submit Spam 
  *
- * @param $content_type: string 'node' or 'comment'
- * @param $content: object $node or $comment
+ * @param string $content_type
+ *   Content type; it can be 'node' or 'comment' .
+ * @param object $content
+ *   Content object.
  *
- * @return integer See constants ANTISPAM_API_RESULT_xxx.
+ * @return integer
+ *   See constants ANTISPAM_API_RESULT_xxx.
  */
 function antispam_api_cmd_submit_spam($content_type, $content) {
   if (!variable_get('antispam_connection_enabled', 1)) {
@@ -2304,21 +2341,23 @@ function antispam_api_cmd_submit_spam($content_type, $content) {
   if (empty($api_key)) {
     return ANTISPAM_API_RESULT_ERROR;
   }
+
+  // Defensio.
   if ($provider == DEFENSIO_SERVICE) {
-    // DEFENSIO
     $query_string = _antispam_api_build_query_string($comment_data);
-    $response = _antispam_api_http_post($query_string, $api_host, '/blog/'. DEFENSIO_API_VERSION .'/report-false-negatives/' . $api_key . '.yaml');
+    $response = _antispam_api_http_post($query_string, $api_host, '/blog/' . DEFENSIO_API_VERSION . '/report-false-negatives/' . $api_key . ' .yaml');
     if (!isset($response[1])) {
       watchdog('antispam', "submitting spam: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return ANTISPAM_API_RESULT_ERROR;
     }
     return (_antispam_parse_yaml_response($response[1], 'status') == 'success' ? ANTISPAM_API_RESULT_SUCCESS : ANTISPAM_API_RESULT_ERROR);
   }
+
+  // Akismet or Typepad.
   else {
-    // AKISMET, TYPEPAD
     $query_string = _antispam_api_build_query_string($comment_data);
-    $host = $api_key .'.'. $api_host;
-    $response = _antispam_api_http_post($query_string, $host, '/'. AKISMET_API_VERSION .'/submit-spam');
+    $host = $api_key . ' . ' . $api_host;
+    $response = _antispam_api_http_post($query_string, $host, '/' . AKISMET_API_VERSION . '/submit-spam');
     if (!isset($response[1])) {
       watchdog('antispam', "submitting spam: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return ANTISPAM_API_RESULT_ERROR;
@@ -2332,10 +2371,13 @@ function antispam_api_cmd_submit_spam($content_type, $content) {
 /**
  * AntiSpam API: Submit Ham 
  *
- * @param $content_type: string 'node' or 'comment'
- * @param $content: object $node or $comment
+ * @param string $content_type
+ *   Content type; it can be 'node' or 'comment' .
+ * @param object $content
+ *   Content object.
  *
- * @return integer See constants ANTISPAM_API_RESULT_xxx.
+ * @return integer
+ *   See constants ANTISPAM_API_RESULT_xxx.
  */
 function antispam_api_cmd_submit_ham($content_type, $content) {
   if (!variable_get('antispam_connection_enabled', 1)) {
@@ -2349,21 +2391,23 @@ function antispam_api_cmd_submit_ham($content_type, $content) {
   if (empty($api_key)) {
     return ANTISPAM_API_RESULT_ERROR;
   }
+
+  // Defensio.
   if ($provider == DEFENSIO_SERVICE) {
-    // DEFENSIO
     $query_string = _antispam_api_build_query_string($comment_data);
-    $response = _antispam_api_http_post($query_string, $api_host, '/blog/'. DEFENSIO_API_VERSION .'/report-false-positives/' . $api_key . '.yaml');
+    $response = _antispam_api_http_post($query_string, $api_host, '/blog/' . DEFENSIO_API_VERSION . '/report-false-positives/' . $api_key . ' .yaml');
     if (!isset($response[1])) {
       watchdog('antispam', "submitting ham: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return ANTISPAM_API_RESULT_ERROR;
     }
     return (_antispam_parse_yaml_response($response[1], 'status') == 'success' ? ANTISPAM_API_RESULT_SUCCESS : ANTISPAM_API_RESULT_ERROR);
   }
+
+  // Akismet or Typepad.
   else {
-    // AKISMET, TYPEPAD
     $query_string = _antispam_api_build_query_string($comment_data);
-    $host = $api_key .'.'. $api_host;
-    $response = _antispam_api_http_post($query_string, $host, '/'. AKISMET_API_VERSION .'/submit-ham');
+    $host = $api_key . ' . ' . $api_host;
+    $response = _antispam_api_http_post($query_string, $host, '/' . AKISMET_API_VERSION . '/submit-ham');
     if (!isset($response[1])) {
       watchdog('antispam', "submitting ham: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
       return ANTISPAM_API_RESULT_ERROR;
@@ -2377,12 +2421,14 @@ function antispam_api_cmd_submit_ham($content_type, $content) {
 /**
  * Prepare user request data for AntiSpam requests.
  *
- * @return array Relevant information extracted from $_SERVER superglobal.
+ * @return array
+ *   Relevant information extracted from $_SERVER superglobal.
  */
 function _antispam_api_prepare_request_data() {
-  // You may add more elements here, but they are often related to internal server
-  // data that makes little sense to check whether a comment is spam or not.
-  // Be sure to not send HTTP_COOKIE as it may compromise your user's privacy!
+  // You may add more elements here, but they are often related to internal 
+  // server data that makes little sense to check whether a comment is spam or 
+  // not. Be sure to not send HTTP_COOKIE as it may compromise your user's 
+  // privacy!
   static $safe_to_send = array(
     'CONTENT_LENGTH',
     'CONTENT_TYPE',
@@ -2403,8 +2449,8 @@ function _antispam_api_prepare_request_data() {
     'SCRIPT_NAME'
   );
 
-  // The contents of $_SERVER doesn't change between requests,
-  // so we can have this cached in static storage.
+  // The contents of $_SERVER doesn't change between requests, so we can have
+  // this cached in static storage.
   static $server_data;
   if (!$server_data) {
     $server_data = array();
@@ -2421,49 +2467,60 @@ function _antispam_api_prepare_request_data() {
  * Build query string for AntiSpam request.
  *
  * @param array
+ *
  * @return string
  */
 function _antispam_api_build_query_string($array) {
   global $base_url;
 
+  // Defensio.
   if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
-    // DEFENSIO
     $string = 'owner-url=' . $base_url . base_path();
   }
+
+  // Akismet or Typepad.
   else {
-    // AKISMET, TYPEPAD
-    $string = 'blog='. $base_url . base_path();
+    $string = 'blog=' . $base_url . base_path();
   }
+
   foreach ($array as $key => $value) {
     $string .= '&' . $key . '=' . urlencode(stripslashes($value));
   }
+
   return $string;
 }
 
 /**
  * Perform a HTTP POST request against the antispam server.
  *
- * @param string The request.
- * @param string The antispam host, prefixed with the API key (except when checking for the key itself).
- * @param string The path where to perform the request.
- * @return array Headers in $response[0] and entity in $response[1].
+ * @param string $request
+ *   The request.
+ * @param string $host
+ *   The antispam host, prefixed with the API key (except when checking for the
+ *   key itself).
+ * @param string $path
+ *   The path where to perform the request.
+ *
+ * @return array
+ *   Headers in $response[0] and entity in $response[1].
  */
 function _antispam_api_http_post($request, $host, $path) {
   $fsock_timeout = (int)variable_get('antispam_connection_timeout', 10);
 
   $http_request = "POST $path HTTP/1.0\r\n"
-    ."Host: $host\r\n"
-    ."Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"
-    .'Content-Length: '. strlen($request) ."\r\n"
-    .'User-Agent: '. ANTISPAM_API_USERAGENT ."\r\n"
-    ."\r\n"
-    .$request;
+    . "Host: $host\r\n"
+    . "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"
+    . 'Content-Length: ' . strlen($request) . "\r\n"
+    . 'User-Agent: ' . ANTISPAM_API_USERAGENT . "\r\n"
+    . "\r\n"
+    . $request;
 
   $response = '';
   if (false !== ($fs = @fsockopen($host, ANTISPAM_API_PORT, $errno, $errstr, $fsock_timeout))) {
     fwrite($fs, $http_request);
     while (!feof($fs)) {
-      $response .= fgets($fs, 1160); // One TCP-IP packet
+      // One TCP-IP packet.
+      $response .= fgets($fs, 1160);
     }
     fclose($fs);
     $response = explode("\r\n\r\n", $response, 2);
