diff --git a/filters/spam_filter_bayesian/spam_filter_bayesian.module b/filters/spam_filter_bayesian/spam_filter_bayesian.module
index a01901d..0a7796b 100644
--- a/filters/spam_filter_bayesian/spam_filter_bayesian.module
+++ b/filters/spam_filter_bayesian/spam_filter_bayesian.module
@@ -111,24 +111,26 @@ function spam_filter_bayesian_spam_filter($content, $type, $fields, $extra = arr
  * Update token probabilities in database.
  */
 function spam_filter_bayesian_tokens_update($class, $tokens, $yes, $type = NULL, $id = 0) {
-  foreach ($tokens as $token) {
-    $old = db_fetch_object(db_query("SELECT probability, yes_count, no_count FROM {spam_filter_bayesian_tokens} WHERE class = '%s' AND token = '%s'", $class, $token));
-    if ($old) {
-      $total = $old->yes_count + $old->no_count + 1;
-      $probability = spam_sanitize_score(($old->yes_count + ($yes ? 1 : 0)) / $total * 100);
-      spam_log(SPAM_DEBUG, 'spam_filter_bayesian_tokens_update', t('update token(@token) class(@class) yes(@yes) no(@no) prob(@prob): added @new', array('@token' => $token, '@class' => $class, '@yes' => $old->yes_count + ($yes ? 1 : 0), '@no' => $old->no_count + ($yes ? 0 : 1), '@prob' => $probability, '@new' => $yes ? 'yes' : 'no')), $type, $id);
-      if ($yes) {
-        db_query("UPDATE {spam_filter_bayesian_tokens} SET yes_count = yes_count + 1, probability = %d, last = %d WHERE class = '%s' AND token = '%s'", $probability, time(), $class, $token);
+  if (is_array($tokens)) {
+    foreach ($tokens as $token) {
+      $old = db_fetch_object(db_query("SELECT probability, yes_count, no_count FROM {spam_filter_bayesian_tokens} WHERE class = '%s' AND token = '%s'", $class, $token));
+      if ($old) {
+        $total = $old->yes_count + $old->no_count + 1;
+        $probability = spam_sanitize_score(($old->yes_count + ($yes ? 1 : 0)) / $total * 100);
+        spam_log(SPAM_DEBUG, 'spam_filter_bayesian_tokens_update', t('update token(@token) class(@class) yes(@yes) no(@no) prob(@prob): added @new', array('@token' => $token, '@class' => $class, '@yes' => $old->yes_count + ($yes ? 1 : 0), '@no' => $old->no_count + ($yes ? 0 : 1), '@prob' => $probability, '@new' => $yes ? 'yes' : 'no')), $type, $id);
+        if ($yes) {
+          db_query("UPDATE {spam_filter_bayesian_tokens} SET yes_count = yes_count + 1, probability = %d, last = %d WHERE class = '%s' AND token = '%s'", $probability, time(), $class, $token);
+        }
+        else {
+          db_query("UPDATE {spam_filter_bayesian_tokens} SET no_count = no_count + 1, probability = %d, last = %d WHERE class = '%s' AND token = '%s'", $probability, time(), $class, $token);
+        }
       }
       else {
-        db_query("UPDATE {spam_filter_bayesian_tokens} SET no_count = no_count + 1, probability = %d, last = %d WHERE class = '%s' AND token = '%s'", $probability, time(), $class, $token);
+        $probability = ($yes ? 99 : 1);
+        spam_log(SPAM_DEBUG, 'spam_filter_bayesian_tokens_update', t('insert token(@token) class(@class) probability(@probability)', array('@token' => $token, '@class' => $class, '@probability' => $probability)), $type, $id);
+        db_query("INSERT INTO {spam_filter_bayesian_tokens} (class, token, yes_count, no_count, probability, last) VALUES('%s', '%s', %d, %d, %d, %d)", $class, $token, ($yes ? 1 : 0), ($yes ? 0 : 1), $probability, time());
       }
     }
-    else {
-      $probability = ($yes ? 99 : 1);
-      spam_log(SPAM_DEBUG, 'spam_filter_bayesian_tokens_update', t('insert token(@token) class(@class) probability(@probability)', array('@token' => $token, '@class' => $class, '@probability' => $probability)), $type, $id);
-      db_query("INSERT INTO {spam_filter_bayesian_tokens} (class, token, yes_count, no_count, probability, last) VALUES('%s', '%s', %d, %d, %d, %d)", $class, $token, ($yes ? 1 : 0), ($yes ? 0 : 1), $probability, time());
-    }
   }
 }
 
diff --git a/filters/spam_filter_duplicate/spam_filter_duplicate.module b/filters/spam_filter_duplicate/spam_filter_duplicate.module
index 2408482..88faa1e 100644
--- a/filters/spam_filter_duplicate/spam_filter_duplicate.module
+++ b/filters/spam_filter_duplicate/spam_filter_duplicate.module
@@ -286,9 +286,13 @@ function _spam_filter_duplicate_content_hash($content, $fields) {
     $content = (array)$content;
   }
   $hash = '';
-  foreach ($fields['main'] as $field) {
-    $hash .= $content[$field];
+  
+  if (isset($fields['main']) && is_array($fields['main'])) {
+    foreach ($fields['main'] as $field) {
+      $hash .= $content[$field];
+    }
   }
+
   return md5($hash);
 }
 
diff --git a/filters/spam_filter_url/spam_filter_url.module b/filters/spam_filter_url/spam_filter_url.module
index 3eb919b..6180476 100644
--- a/filters/spam_filter_url/spam_filter_url.module
+++ b/filters/spam_filter_url/spam_filter_url.module
@@ -56,8 +56,10 @@ function _spam_filter_url_extract($content, $type, $fields, $extra = array()) {
 
   if (!isset($spam_filter_urls["$type-$id"])) {
     $string = '';
-    foreach ($fields['main'] as $field) {
-      $string .= $content["$field"] .' ';
+    if (isset($fields['main']) && is_array($fields['main'])) {
+      foreach ($fields['main'] as $field) {
+        $string .= $content["$field"] .' ';
+      }
     }
     if (is_array($fields['other'])) {
       foreach ($fields['other'] as $field) {
diff --git a/spam.module b/spam.module
index db1a048..12c0410 100644
--- a/spam.module
+++ b/spam.module
@@ -575,7 +592,7 @@ function spam_mark_load($type, $id, $action) {
       return $type;
     }
   }
-  return $false;
+  return FALSE;
 }
 
 /**
@@ -945,7 +962,7 @@ function spam_install_filter($filter) {
  * As the spam module isn't a core Drupal module, many important modules won't
  * utilize its API.  We define the appropriate hooks for these modules in the
  * modules/ subdirectory.  For example, we define the spam api hooks for the
- * node module in modules/spam_node.inc.
+ * node module in content/spam_content_node.inc.
  */
 function spam_init() {
   $path = drupal_get_path('module', 'spam') .'/content';
@@ -1792,9 +1811,10 @@ function spam_get_text($content, $type, $fields, $extra = array(), $full = TRUE)
   }
 
   $text = '';
-
-  foreach ($fields['main'] as $field) {
-    $text .= $content[$field] .' ';
+  if (isset($fields['main']) && is_array($fields['main'])) {
+    foreach ($fields['main'] as $field) {
+      $text .= $content[$field] .' ';
+    }
   }
   if ($full && is_array($fields['other'])) {
     foreach ($fields['other'] as $field) {
