diff --git a/mailcomment.module b/mailcomment.module
index 7ba3b96..574b2a0 100644
--- a/mailcomment.module
+++ b/mailcomment.module
@@ -21,6 +21,9 @@ define('MAILCOMMENT_FILTER_NONE', 0);
 define('MAILCOMMENT_FILTER_BASIC', 1);
 define('MAILCOMMENT_FILTER_AGGRESSIVE', 2);
 
+// Valid Message-ID Regex
+define('MAILCOMMENT_MESSAGEID', "/\<(\d+[.]\d+[.]\d+[.]\d+[.]\w+\@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5})\>/");
+
 /**
  * Implements hook_menu().
  */
@@ -270,6 +273,46 @@ function mailcomment_build_messageid($params) {
 }
 
 /**
+ * Parse messageid from email header
+ *
+ * Also used by mailhandler filter plugins and feeds importer source mappings
+ *
+ * @param $header
+ *   An email header containing a mailcomment formatted message id.
+ *   Valid email headers are Message-ID, References and In-Reply-To.
+ *
+ *   Format:
+ *     format: 4 digits and 1 hash divided by dots then an @ symbol then a domain
+ *   Example 1:
+ *     <1234.4666.5056.1486965753.cb17604ac1434f792f04f724d2af7ee6@domain.com>
+ *   Example 2: (References header - only first line is actually line breaked):
+ *     7356
+ *     <4431.5196.7356.1487571103.20e2a3d69bef550a990d7c751beb84de@domain.com>
+ *     <CAPbhD2K4MvcCPqSNRhp33P+CoNkY5xyb+qNqeJBuhMrxeMCBsg@mail.gmail.com>
+ *     <CAPbhD2JZdgQj==1AxDWqaR2N=jrQtvrz3hQ-03b9jkgJg5eoFA@mail.gmail.com>
+ *
+ * @return Message ID
+ *   format: uid.nid.cid.timestamp.hash@domain
+ *   example: 4431.5196.7356.1487271103.30e2a8def550a990d7c751beb84de@domain.com
+ *
+ * @see mailcomment_source_get_source
+ */
+function mailcomment_parse_messageid($header) {
+
+  // Find the first element that matches pattern.
+  preg_match(MAILCOMMENT_MESSAGEID, $header, $matches);
+
+  if (!empty($matches)) {
+    // Value inside the brackets "()".
+    return $matches[1];
+  }
+  else {
+    // No matches found.
+    return NULL;
+  }
+}
+
+/**
  * Determines whether the mail comment signature exists in the body.
  *
  * @param string $body
@@ -390,27 +433,26 @@ function mailcomment_feeds_parser_sources_alter(&$sources, $content_type) {
  * @see locale_feeds_get_source()
  */
 function mailcomment_source_get_source($source, FeedsParserResult $result, $key) {
-  $item = $result->currentItem();
-  $identifier = _mailcomment_get_signature(rawurldecode($item['body_original']));
+  // Get email.
+  $email = $result->currentItem();
+  // Get identifier from signature in email body.
+  $identifier = _mailcomment_get_signature(rawurldecode($email['body_original']));
+  // Get identifier from email headers.
   if (!$identifier) {
-    // Failed to find signature in body -- replicate mailhandler functionality to find node->threading.
-    if (!empty($item['header']->references)) {
-      // We want the final element in references header, watching out for white space.
-      $identifier = drupal_substr(strrchr($item['header']->references, '<'), 0);
+    // A singular value.
+    if (!empty($email['header']->in_reply_to) && ($id = mailcomment_parse_messageid($email['header']->in_reply_to))) {
+      $identifier = $id;
     }
-    elseif (!empty($item['header']->in_reply_to)) {
-      // Some MUAs send more info in this header.
-      $identifier = str_replace(strstr($item['header']->in_reply_to, '>'), '>', $item['header']->in_reply_to);
-    }
-    if (isset($identifier)) {
-      $identifier = rtrim(ltrim($identifier, '<'), '>');
+    // The first reference found is our original Message-ID.
+    elseif (!empty($email['header']->references) && ($id = mailcomment_parse_messageid($email['header']->references))) {
+      $identifier = $id;
     }
   }
+  // Return requested value.
   $params = mailcomment_check_messageparams($identifier);
   switch ($key) {
     case 'parent_nid':
       return $params['nid'];
-
     case 'parent_cid':
       return $params['cid'];
   }
