diff --git a/include/class.misc.php b/include/class.misc.php
index 4ab741bbd3c62b43627778072fb19dc6ba9d624a..4664e7b6d376024c1f6570aa8225ab2be96e28a9 100644
--- a/include/class.misc.php
+++ b/include/class.misc.php
@@ -127,12 +127,13 @@ class Misc {
         ob_start();
         echo sprintf('<select name="%s" id="%s">',$name,$name);
         echo '<option value="" selected>'.__('Time').'</option>';
+        $format = $cfg->getTimeFormat();
         for($i=23; $i>=0; $i--) {
             for($minute=45; $minute>=0; $minute-=15) {
                 $sel=($hr==$i && $min==$minute)?'selected="selected"':'';
                 $_minute=str_pad($minute, 2, '0',STR_PAD_LEFT);
                 $_hour=str_pad($i, 2, '0',STR_PAD_LEFT);
-                $disp = date($cfg->getTimeFormat(), $i*3600 + $minute*60);
+                $disp = date($format, $i*3600 + $minute*60);
                 echo sprintf('<option value="%s:%s" %s>%s</option>',$_hour,$_minute,$sel,$disp);
             }
         }
diff --git a/include/mysqli.php b/include/mysqli.php
index e8bfeb32ebcfa7f6acd5fe26991a6fc07b32c136..a6da0334d5d4a0167aa4c3139fb32541236ea69c 100644
--- a/include/mysqli.php
+++ b/include/mysqli.php
@@ -250,8 +250,12 @@ function db_free_result($res) {
 }
 
 function db_output($var) {
+    static $no_magic_quotes = null;
 
-    if(!function_exists('get_magic_quotes_runtime') || !get_magic_quotes_runtime()) //Sucker is NOT on - thanks.
+    if (!isset($no_magic_quotes))
+        $no_magic_quotes = !function_exists('get_magic_quotes_runtime') || !get_magic_quotes_runtime();
+
+    if ($no_magic_quotes) //Sucker is NOT on - thanks.
         return $var;
 
     if (is_array($var))
diff --git a/setup/cli/modules/i18n.php b/setup/cli/modules/i18n.php
index dd5332eb8299b0ba324e1634813c4e0656fad8ff..c9152ac6267789812bb2e3db9defcd6f1e7b0c3b 100644
--- a/setup/cli/modules/i18n.php
+++ b/setup/cli/modules/i18n.php
@@ -293,7 +293,7 @@ class i18n_Compiler extends Module {
         while (list(,$T) = each($tokens)) {
             switch ($T[0]) {
                 case T_CONSTANT_ENCAPSED_STRING:
-                    // String leading and trailing ' and " chars
+                    // Strip leading and trailing ' and " chars
                     $string['form'] = preg_replace(array("`^{$T[1][0]}`","`{$T[1][0]}$`"),array("",""), $T[1]);
                     $string['line'] = $T[2];
                     break;
@@ -434,8 +434,8 @@ class i18n_Compiler extends Module {
     function __write_string($string) {
         // Unescape single quote (') and escape unescaped double quotes (")
         $string = preg_replace(array("`\\\(['$])`", '`(?<!\\\)"`'), array("$1", '\"'), $string);
-        // Preserve embedded newlines
-        $string = preg_replace("`\n\s*`", "\\n\n", $string);
+        // Preserve embedded newlines -- preserve up to on
+        $string = preg_replace("`\n\s*`u", "\\n\n", $string);
         // Word-wrap long lines
         $string = rtrim(preg_replace('/(?=[\s\p{Ps}])(.{1,76})(\s|$|(\p{Ps}))/uS',
             "$1$2\n", $string), "\n");