diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index da4e930f3e5192906bbae73d97717cf68b36e254..8378507163ed383cb4f6506127473ac1d626ba2c 100644
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -23,6 +23,7 @@
 OCP\JSON::checkLoggedIn();
 //OCP\User::checkLoggedIn();
 OCP\App::checkAppEnabled('contacts');
+session_close_write();
 
 function getStandardImage(){
 	//OCP\Response::setExpiresHeader('P10D');
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
index 4fc9eba992d9eb25f12f98c976f19a34e751fb4e..5bf1d420dc41f5476c7aa16f396b23c3b380efd5 100644
--- a/apps/gallery/ajax/thumbnail.php
+++ b/apps/gallery/ajax/thumbnail.php
@@ -23,6 +23,7 @@
  
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('gallery');
+session_write_close();
 require_once('apps/gallery/lib/managers.php');
 
 
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php
index 037e53059d116bd627dce5fd00fc84c43565fe90..c3b4a17854528144e2569d86ecc4322e768d3eff 100644
--- a/apps/gallery/templates/index.php
+++ b/apps/gallery/templates/index.php
@@ -26,6 +26,7 @@ $(document).ready(function() {
 </div>
 <div id="gallerycontent">
 <?php
+session_write_close();
 
 echo $_['tl']->get();
 
diff --git a/lib/cache/apc.php b/lib/cache/apc.php
index f814afbe494d748a1e97054be558d89efb7d406a..b1ce87f52671aa388e5db52b4911438b05143740 100644
--- a/lib/cache/apc.php
+++ b/lib/cache/apc.php
@@ -44,3 +44,11 @@ class OC_Cache_APC {
 		}
 	}
 }
+if(!function_exists('apc_exists')) {
+	function apc_exists($keys)
+	{
+		$result;
+		apc_fetch($keys, $result);
+		return $result;
+	}
+}
diff --git a/lib/connector/sabre/auth.php b/lib/connector/sabre/auth.php
index 1c7a84f0f2a69c5b9a08c003a3d03b60a90483e6..ee68039162647beab589a2711f0de4767bd40e4e 100644
--- a/lib/connector/sabre/auth.php
+++ b/lib/connector/sabre/auth.php
@@ -33,7 +33,7 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
 	protected function validateUserPass($username, $password){
 		OC_Util::setUpFS();//login hooks may need early access to the filesystem
 		if(OC_User::login($username,$password)){
-			OC_Util::setUpFS();
+			OC_Util::setUpFS($username);
 			return true;
 		}
 		else{
diff --git a/lib/json.php b/lib/json.php
index dfc0a7b894e199187a3d9487c44094b6a431c302..4eab4fce9f6e5700d9c7ba44bc3f11a76d0ca193 100644
--- a/lib/json.php
+++ b/lib/json.php
@@ -81,6 +81,15 @@ class OC_JSON{
 		self::encodedPrint($data);
 	}
 
+	/**
+	 * Convert OC_L10N_String to string, for use in json encodings
+	 */
+	protected static function to_string(&$value){
+		if ($value instanceof OC_L10N_String) {
+			$value = (string)$value;
+		}
+	}
+
 	/**
 	* Encode and print $data in json format
 	*/
@@ -89,6 +98,7 @@ class OC_JSON{
 			if($setContentType){
 				self::setContentTypeHeader();
 			}
+			array_walk_recursive($data, array('OC_JSON', 'to_string'));
 			echo json_encode($data);
 		}
 	}
diff --git a/lib/util.php b/lib/util.php
index 50955ebb87ffadcf808f3a27f8e9663a4aa825fa..0d9f4129442f445236eb79dba1f8209d826a8aa4 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -426,10 +426,11 @@ class OC_Util {
 	/**
 	 * @brief Public function to sanitize HTML
 	 *
-	 * This function is used to sanitize HTML and should be applied on any string or array of strings before displaying it on a web page.
+	 * This function is used to sanitize HTML and should be applied on any
+	 * string or array of strings before displaying it on a web page.
 	 * 
 	 * @param string or array of strings
-	 * @return array with sanitized strings or a single sinitized string, depends on the input parameter.
+	 * @return array with sanitized strings or a single sanitized string, depends on the input parameter.
 	 */
 	public static function sanitizeHTML( &$value ){
 		if (is_array($value) || is_object($value)) array_walk_recursive($value,'OC_Util::sanitizeHTML');
@@ -439,7 +440,7 @@ class OC_Util {
 
 
         /**
-         * Check if the htaccess file is working buy creating a test file in the data directory and trying to access via http
+         * Check if the htaccess file is working by creating a test file in the data directory and trying to access via http
          */
         public static function ishtaccessworking() {
 
diff --git a/settings/js/log.js b/settings/js/log.js
index 6063c7d9a9fe8cb41834e832a1f8416b31c6f3ae..fe2e92f7a867f04fd08361d0f794432f4fd55ea0 100644
--- a/settings/js/log.js
+++ b/settings/js/log.js
@@ -39,7 +39,7 @@ OC.Log={
 			row.append(appTd);
 			
 			var messageTd=$('<td/>');
-			messageTd.text(entry.message);
+			messageTd.html(entry.message);
 			row.append(messageTd);
 			
 			var timeTd=$('<td/>');