diff --git a/bootstrap.php b/bootstrap.php
index 7d7bf3ca85c7df3ea306543b0ada59708207816c..05d6d23027cbaad8fc0383251c5e647d636ec154 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -236,6 +236,13 @@ class Bootstrap {
                     return preg_replace_callback('/\b\p{Ll}/u', 'mb_strtoupper', $str);
                 }
             }
+            function mb_internal_encoding($encoding) { return 'UTF-8'; }
+            function mb_regex_encoding($encoding) { return 'UTF-8'; }
+            function mb_substr_count($haystack, $needle) {
+                $matches = array();
+                return preg_match_all('`'.preg_quote($needle).'`u', $haystack,
+                    $matches);
+            }
         }
         else {
             // Use UTF-8 for all multi-byte string encoding
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 51cbbf9908cd44b3e63de358aa91596de3b34914..07e0650e8e21e5bfdd6ea4844c840471f6ecb52d 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -23,7 +23,6 @@ include_once(INCLUDE_DIR.'class.topic.php');
 include_once(INCLUDE_DIR.'class.lock.php');
 include_once(INCLUDE_DIR.'class.file.php');
 include_once(INCLUDE_DIR.'class.attachment.php');
-include_once(INCLUDE_DIR.'class.pdf.php');
 include_once(INCLUDE_DIR.'class.banlist.php');
 include_once(INCLUDE_DIR.'class.template.php');
 include_once(INCLUDE_DIR.'class.variable.php');
@@ -1669,6 +1668,7 @@ class Ticket {
 
     //Print ticket... export the ticket thread as PDF.
     function pdfExport($psize='Letter', $notes=false) {
+        require_once(INCLUDE_DIR.'class.pdf.php');
         $pdf = new Ticket2PDF($this, $psize, $notes);
         $name='Ticket-'.$this->getExtId().'.pdf';
         $pdf->Output($name, 'I');
diff --git a/main.inc.php b/main.inc.php
index 924f728886779c0cd668d07376cee0f745596a6b..7feb271e7743274b02b2227ac29e68f4e67f3f7e 100644
--- a/main.inc.php
+++ b/main.inc.php
@@ -23,8 +23,8 @@ if(isset($_SERVER['SCRIPT_NAME'])
 require('bootstrap.php');
 Bootstrap::loadConfig();
 Bootstrap::defineTables(TABLE_PREFIX);
-Bootstrap::loadCode();
 Bootstrap::i18n_prep();
+Bootstrap::loadCode();
 Bootstrap::connect();
 
 if(!($ost=osTicket::start()) || !($cfg = $ost->getConfig()))