diff --git a/include/class.faq.php b/include/class.faq.php
index c2a1958917b834d8a74d92488e8b333547532059..1a2ec4c4bbf1470c67394f88fcdce492a6e7975a 100644
--- a/include/class.faq.php
+++ b/include/class.faq.php
@@ -204,7 +204,7 @@ class FAQ {
             if($attachment['size'])
                 $size=sprintf('&nbsp;<small>(<i>%s</i>)</small>',Format::file_size($attachment['size']));
 
-            $str.=sprintf('<a class="Icon file" href="file.php?h=%s" target="%s">%s</a>%s&nbsp;%s',
+            $str.=sprintf('<a class="Icon file no-pjax" href="file.php?h=%s" target="%s">%s</a>%s&nbsp;%s',
                     $hash, $target, Format::htmlchars($attachment['name']), $size, $separator);
 
             }
diff --git a/include/class.mailer.php b/include/class.mailer.php
index 2a0ebd768b1640851491c2eaa77254760a6e5e96..a3093c203a14eac9f8e7a2082830f715352b2128 100644
--- a/include/class.mailer.php
+++ b/include/class.mailer.php
@@ -155,6 +155,13 @@ class Mailer {
             }
         }
 
+        // Use Mail_mime default initially
+        $eol = null;
+
+        // MAIL_EOL setting can be defined in `ost-config.php`
+        if (defined('MAIL_EOL') && is_string(MAIL_EOL)) {
+            $eol = MAIL_EOL;
+        }
         // The Suhosin patch will muck up the line endings in some
         // cases
         //
@@ -162,12 +169,12 @@ class Mailer {
         // https://github.com/osTicket/osTicket-1.8/issues/202
         // http://pear.php.net/bugs/bug.php?id=12032
         // http://us2.php.net/manual/en/function.mail.php#97680
-        if ((extension_loaded('suhosin') || defined("SUHOSIN_PATCH"))
-                && !$this->getSMTPInfo())
-            $mime = new Mail_mime("\n");
-        else
-            // Use defaults
-            $mime = new Mail_mime();
+        elseif ((extension_loaded('suhosin') || defined("SUHOSIN_PATCH"))
+            && !$this->getSMTPInfo()
+        ) {
+            $eol = "\n";
+        }
+        $mime = new Mail_mime($eol);
 
         // If the message is not explicitly declared to be a text message,
         // then assume that it needs html processing to create a valid text
diff --git a/include/class.thread.php b/include/class.thread.php
index eef0e6b7a6c2c969fea0bc454bf9247aa402b95c..70535dbd3dca11a7ec056ce22ce32c6a6d622348 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -357,14 +357,14 @@ Class ThreadEntry {
         return $this->ht['@headers'];
     }
 
-    function getEmailReferences() {
-        if (!isset($this->_references)) {
-            $headers = self::getEmailHeaderArray();
-            if (isset($headers['References']) && $headers['References'])
-                $this->_references = $headers['References']." ";
-            $this->_references .= $this->getEmailMessageId();
-        }
-        return $this->_references;
+    function getEmailReferences($include_mid=true) {
+        $references = '';
+        $headers = self::getEmailHeaderArray();
+        if (isset($headers['References']) && $headers['References'])
+            $references = $headers['References']." ";
+        if ($include_mid)
+            $references .= $this->getEmailMessageId();
+        return $references;
     }
 
     function getTaggedEmailReferences($prefix, $refId) {
@@ -374,7 +374,7 @@ Class ThreadEntry {
         $mid = substr_replace($this->getEmailMessageId(),
                 $ref, strpos($this->getEmailMessageId(), '@'), 0);
 
-        return sprintf('%s %s', $this->getEmailReferences(), $mid);
+        return sprintf('%s %s', $this->getEmailReferences(false), $mid);
     }
 
     function getEmailReferencesForUser($user) {
@@ -853,7 +853,7 @@ Class ThreadEntry {
             return ThreadEntry::lookup($id);
         }
 
-        foreach (array('mid', 'in-reply-to', 'references') as $header) {
+        foreach (array('in-reply-to', 'references') as $header) {
             $matches = array();
             if (!isset($mailinfo[$header]) || !$mailinfo[$header])
                 continue;
@@ -867,6 +867,7 @@ Class ThreadEntry {
             // (parent) on the far right.
             // @see rfc 1036, section 2.2.5
             // @see http://www.jwz.org/doc/threading.html
+            $thread = null;
             foreach (array_reverse($matches[0]) as $mid) {
                 //Try to determine if it's a reply to a tagged email.
                 $ref = null;
@@ -877,20 +878,29 @@ Class ThreadEntry {
                 }
                 $res = db_query(sprintf($search, db_input($mid)));
                 while (list($id) = db_fetch_row($res)) {
-                    if (!($t = ThreadEntry::lookup($id))) continue;
-
-                    //We found a match  - see if we can ID the user.
+                    if (!($t = ThreadEntry::lookup($id)))
+                        continue;
+                    // Capture the first match thread item
+                    if (!$thread)
+                        $thread = $t;
+                    // We found a match  - see if we can ID the user.
                     // XXX: Check access of ref is enough?
                     if ($ref && ($uid = $t->getUIDFromEmailReference($ref))) {
                         if ($ref[0] =='s') //staff
                             $mailinfo['staffId'] = $uid;
-                        else //user or collaborator.
+                        else // user or collaborator.
                             $mailinfo['userId'] = $uid;
-                    }
 
-                    return $t;
+                        // Best possible case — found the thread and the
+                        // user
+                        return $t;
+                    }
                 }
             }
+            // Second best case — found a thread but couldn't identify the
+            // user from the header. Return the first thread entry matched
+            if ($thread)
+                return $thread;
         }
 
         // Search for ticket by the [#123456] in the subject line
@@ -1417,9 +1427,9 @@ class TextThreadBody extends ThreadBody {
 }
 class HtmlThreadBody extends ThreadBody {
     function __construct($body, $options=array()) {
+        if ($options['strip-embedded'])
+            $body = $this->extractEmbeddedHtmlImages($body);
         parent::__construct($body, 'html', $options);
-        if ($this->options['strip-embedded'])
-            $this->body = $this->extractEmbeddedHtmlImages($this->body);
     }
 
     function extractEmbeddedHtmlImages($body) {
diff --git a/include/ost-sampleconfig.php b/include/ost-sampleconfig.php
index a5f896769fb81a931571e9afa5f98c0a8ef81967..3fc0e71780edaca45f56fdefb698a59e5a5b2b1a 100644
--- a/include/ost-sampleconfig.php
+++ b/include/ost-sampleconfig.php
@@ -16,19 +16,6 @@
     $Id: $
 **********************************************************************/
 
-/**
- * If you have a strange HTTP server configuration and osTicket cannot
- * discover the URL path of where your osTicket is installed, define
- * ROOT_PATH here.
- *
- * The ROOT_PATH is the part of the URL used to access your osTicket
- * helpdesk before the '/scp' part and after the hostname. For instance, for
- * http://mycompany.com/support', the ROOT_PATH should be '/support/'
- *
- * ROOT_PATH *must* end with a forward-slash!
- */
-# define('ROOT_PATH', '/support/');
-
 #Disable direct access.
 if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']),basename(__FILE__)) || !defined('INCLUDE_DIR'))
     die('kwaheri rafiki!');
@@ -48,13 +35,19 @@ define('SECRET_SALT','%CONFIG-SIRI');
 #Default admin email. Used only on db connection issues and related alerts.
 define('ADMIN_EMAIL','%ADMIN-EMAIL');
 
-#Mysql Login info
+# Database Options
+# ---------------------------------------------------
+# Mysql Login info
 define('DBTYPE','mysql');
 define('DBHOST','%CONFIG-DBHOST');
 define('DBNAME','%CONFIG-DBNAME');
 define('DBUSER','%CONFIG-DBUSER');
 define('DBPASS','%CONFIG-DBPASS');
 
+# Table prefix
+define('TABLE_PREFIX','%CONFIG-PREFIX');
+
+#
 # SSL Options
 # ---------------------------------------------------
 # SSL options for MySQL can be enabled by adding a certificate allowed by
@@ -75,7 +68,42 @@ define('DBPASS','%CONFIG-DBPASS');
 # define('DBSSLCERT','/path/to/client.crt');
 # define('DBSSLKEY','/path/to/client.key');
 
-#Table prefix
-define('TABLE_PREFIX','%CONFIG-PREFIX');
+#
+# Mail Options
+# ---------------------------------------------------
+# Option: MAIL_EOL (default: \r\n)
+#
+# Some mail setups do not handle emails with \r\n (CRLF) line endings for
+# headers and base64 and quoted-response encoded bodies. This is an error
+# and a violation of the internet mail RFCs. However, because this is also
+# outside the control of both osTicket development and many server
+# administrators, this option can be adjusted for your setup. Many folks who
+# experience blank or garbled email from osTicket can adjust this setting to
+# use "\n" (LF) instead of the CRLF default.
+#
+# References:
+# http://www.faqs.org/rfcs/rfc2822.html
+# https://github.com/osTicket/osTicket-1.8/issues/202
+# https://github.com/osTicket/osTicket-1.8/issues/700
+# https://github.com/osTicket/osTicket-1.8/issues/759
+# https://github.com/osTicket/osTicket-1.8/issues/1217
+
+# define(MAIL_EOL, "\n");
 
+#
+# HTTP Server Options
+# ---------------------------------------------------
+# Option: ROOT_PATH (default: <auto detect>, fallback: /)
+#
+# If you have a strange HTTP server configuration and osTicket cannot
+# discover the URL path of where your osTicket is installed, define
+# ROOT_PATH here.
+#
+# The ROOT_PATH is the part of the URL used to access your osTicket
+# helpdesk before the '/scp' part and after the hostname. For instance, for
+# http://mycompany.com/support', the ROOT_PATH should be '/support/'
+#
+# ROOT_PATH *must* end with a forward-slash!
+
+# define('ROOT_PATH', '/support/');
 ?>
diff --git a/scp/js/dashboard.inc.js b/scp/js/dashboard.inc.js
index ba19235f12ec5198cb2c074bc083f37b1344ed4d..b16aebf103a94e8c0f22e873e28681227e797da1 100644
--- a/scp/js/dashboard.inc.js
+++ b/scp/js/dashboard.inc.js
@@ -250,6 +250,7 @@
                 // ------------------------> Export <-----------------------
                 $('<a>').attr({'href':'ajax.php/report/overview/table/export?group='
                         +group+'&start='+start+'&stop='+stop}).append('Export')
+                    .addClass('no-pjax')
                     .appendTo($('<li>')
                     .appendTo(p));