diff --git a/mailcomment.info b/mailcomment.info
index ccd811a..87841be 100644
--- a/mailcomment.info
+++ b/mailcomment.info
@@ -3,4 +3,5 @@ description = Gateway module for responding to posts via mail
 package = "Mailhandler"
 dependencies[] = notifications
 dependencies[] = mailhandler
+files[] = tests/mailcomment.test
 core = 6.x
diff --git a/mailcomment.module b/mailcomment.module
index 037c378..edf366e 100644
--- a/mailcomment.module
+++ b/mailcomment.module
@@ -534,18 +534,39 @@ function mailcomment_signature($params) {
   return md5(implode('-', $params));
 }
 
-// Need to clean up body text after the comment is parsed and before it is processed
+/**
+ * Implementation of hook_feeds_after_parse()
+ *
+ * Cleans up message body.
+ */
 function mailcomment_feeds_after_parse(FeedsImporter $importer, FeedsSource $source) {
-  // Now trim out the rest of the message if separator text exists
-  // @ TODO May fail for html mails
+  // @TODO May fail for html mails
+  $delimiters = array();
+  if (variable_get('mailcomment_strip_quoted_text', 1)) {
+    $delimiters += array(
+      "On \d{1,2}[\/\-]{1}\d{1,2}[\/\-]{1}\d{1,2},", // Gmail form 1
+      "On \w{3}, \w{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2} [AP]M", // Gmail form 1
+      "On \w{3}, \w{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2} [AP]M", // Gmail form 2
+      "On \d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{1,2} [AP]M,", // Thunderbird
+      "On [A-Z][a-z]{2} [0-9]{1,2}, [0-9]{4}, at [0-9]{1,2}:[0-9]{2} [AP]M, [a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4} wrote", // Mac mail
+      "On [A-Z][a-z]{2} [0-9]{1,2}, [0-9]{4}, at [0-9]{1,2}:[0-9]{2} [AP]M,", // Mac mail
+      '-----\s?Original Message\s?-----', // Outlook express
+      'From:(\s*)[A-Za-z0-9._%+-]+@[A-Za-z0-9._%+-]+\.[A-Za-z]{2,3}(\s*)\[mailto:[A-Za-z0-9._%+-]+@[A-Za-z0-9._%+-]+\.[A-Za-z]{2,3}\]', // Outlook legacy
+      '[_]*\nFrom:', // Outlook web
+      'From:.*Sent:.*To:.*Subject:', // Fallback
+    );
+  }
   if ($marker = variable_get('mailcomment_reply_text', t('((( Reply ABOVE this LINE to POST a COMMENT )))'))) {
-    // Allow other modules to act on the text and node object before we start stripping things from it.
-    mailcomment_invoke_mailcomment_alter($node, 'pre');
-    // Now the dirty part. May need some more clean up for line endings, spare html, etc...
-    $pos = strpos($node->body, $marker);
-    if ($pos !== FALSE) {
-      // Mailhandler brings this in as a full node with teaser/body but we need to change context to comment
-      $node->body = drupal_substr($node->body, 0, $pos);
+    $delimiters[] = '[> ]*'. preg_quote($marker);
+  }
+
+  $expression = '/('. implode('|', $delimiters) .')/';
+
+  foreach ($source->batch->items as $key => $message) {
+    $matches = array();
+    mailcomment_invoke_mailcomment_alter($message, 'pre');
+    if (preg_match($expression, $message['origbody'], $matches, PREG_OFFSET_CAPTURE)) {
+      $source->batch->items[$key]['origbody'] = trim(drupal_substr($message['origbody'], 0, $matches[0][1]));
     }
   }
 }
diff --git a/tests/mailcomment.test b/tests/mailcomment.test
new file mode 100644
index 0000000..a8e2cec
--- /dev/null
+++ b/tests/mailcomment.test
@@ -0,0 +1,101 @@
+<?php
+
+// Mock necessary Feeds classes
+class FeedsImporter {}
+class FeedsSource {}
+
+class MailCommentTestCase extends DrupalUnitTestCase {
+  /**
+   * getInfo() returns properties that are displayed in the test selection form.
+   */
+  public static function getinfo() {
+    return array(
+      'name' => 'Mailcomment',
+      'description' => 'Test mailcomment message parsing.',
+      'group' => 'mailcomment',
+    );
+  }
+
+  /**
+   * setUp() performs any pre-requisite tasks that need to happen. 
+   */
+  public function setUp() {
+    // Enable any modules required for the test.
+    parent::setUp(
+      'ctools',
+      'notifications',
+      'messaging', 
+      'feeds',
+      'autoload',
+      'token',
+      'job_scheduler',
+      'messaging_template',
+      'mailhandler',
+      'mailcomment'
+    );
+  }
+
+  public function testMailCommentParseMessage() {
+    $importer = new FeedsImporter;
+    $source = new FeedsSource;
+
+    $source->batch = new stdClass;
+    $source->batch->items = array(
+      'gmail_reply' => array('origbody' => "Hello world.
+
+On Fri, Aug 19, 2011 at 9:51 AM, test person <user@hostname.tld> wrote:
+> ((( Reply ABOVE this LINE to POST a COMMENT )))
+>
+> user said:
+>
+> Courgette lettuce bell pepper asparagus collard greens epazote broccoli rabe. Wattle 
+> seed cress welsh onion broccoli rabe pea sprouts tomatillo celery ricebean napa cabbage
+> bush tomato daikon horseradish turnip winter purslane. Chickweed radicchio taro tigernut 
+> spinach tomatillo black-eyed pea avocado.
+
+-- 
+Test person name | http://hostname.tld",),
+      
+      'thunderbird_reply' => array('origbody' => "Hello world.
+
+On 08/18/2011 04:19 PM, Test Person wrote:
+> ((( Reply ABOVE this LINE to POST a COMMENT )))
+> 
+> user said:
+> 
+> Mustard scallion yarrow aubergine sierra leone bologi sea lettuce
+> chicory broccoli collard greens turnip greens shallot radicchio komatsuna.
+> Broccoli celery grape bell pepper kohlrabi radicchio sierra leone bologi.",),
+      
+      'outlook_web' => array('origbody' => "Hello world.
+________________________________________
+From: user@hostname.tld [user@hostname.tld]
+Sent: Thursday, August 18, 2011 4:19 PM
+To: Recipient Name
+Subject: Re: [Site-name] Subject
+
+((( Reply ABOVE this LINE to POST a COMMENT )))
+
+ said:
+
+Well, hello there, Dave.",),
+
+      'generic_reply' => array('origbody' => "Hello world.
+
+> ((( Reply ABOVE this LINE to POST a COMMENT )))
+> 
+> user said:
+> 
+> Mustard scallion yarrow aubergine sierra leone bologi sea lettuce
+> chicory broccoli collard greens turnip greens shallot radicchio komatsuna.
+> Broccoli celery grape bell pepper kohlrabi radicchio sierra leone bologi.",),
+
+    );
+
+    mailcomment_feeds_after_parse($importer, $source);
+
+    foreach ($source->batch->items as $key => $item) {
+      $this->assertEqual($item['origbody'], 'Hello world.', $key .' stripped properly.');
+    }
+  }
+}
