diff --git a/apps/files/admin.php b/apps/files/admin.php
index f747f8645f6ca62bc63bace5d3d90a2846a46026..02c3147dba58cbe5bc17b13a63bd1da339e0b510 100644
--- a/apps/files/admin.php
+++ b/apps/files/admin.php
@@ -21,10 +21,6 @@
 *
 */
 
-
-// Init owncloud
-
-
 OCP\User::checkAdminUser();
 
 $htaccessWorking=(getenv('htaccessWorking')=='true');
diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php
index 307a4d0320d1b9527dcf7c48a62f1e9d36752cdf..043782a9c04c5cdb5cb9958b0b848ba6f8994f93 100644
--- a/apps/files/appinfo/routes.php
+++ b/apps/files/appinfo/routes.php
@@ -8,7 +8,4 @@
 
 $this->create('download', 'download{file}')
 	->requirements(array('file' => '.*'))
-	->actionInclude('files/download.php');
-// oC JS config
-$this->create('publicListView', 'js/publiclistview.js')
-	->actionInclude('files/js/publiclistview.php');
\ No newline at end of file
+	->actionInclude('files/download.php');
\ No newline at end of file
diff --git a/apps/files/download.php b/apps/files/download.php
index ddd23df4125c4457791089e9f61362c8d9761ee6..e3fe24e45d733398f8fb9ae67585b911db544c58 100644
--- a/apps/files/download.php
+++ b/apps/files/download.php
@@ -21,9 +21,6 @@
 *
 */
 
-// Init owncloud
-
-
 // Check if we are a user
 OCP\User::checkLoggedIn();
 
diff --git a/apps/files/index.php b/apps/files/index.php
index 13eebfc6990fc2e653a9f76f3264ffcdc3d41472..894758d38f6558ed3352fb86e0b31a094f78f1e2 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -93,6 +93,7 @@ $list = new OCP\Template('files', 'part.list', '');
 $list->assign('files', $files, false);
 $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
 $list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false);
+$list->assign('disableSharing', false);
 $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
 $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
 $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
@@ -100,6 +101,9 @@ $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir
 $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
 
 $permissions = OCP\PERMISSION_READ;
+if (\OC\Files\Filesystem::isCreatable($dir . '/')) {
+	$permissions |= OCP\PERMISSION_CREATE;
+}
 if (\OC\Files\Filesystem::isUpdatable($dir . '/')) {
 	$permissions |= OCP\PERMISSION_UPDATE;
 }
diff --git a/apps/files/js/publiclistview.php b/apps/files/js/publiclistview.php
deleted file mode 100644
index f1c67aabb485e11a84dc835d0a3f344385f1d5ba..0000000000000000000000000000000000000000
--- a/apps/files/js/publiclistview.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-/**
- * Copyright (c) 2013 Lukas Reschke <lukas@statuscode.ch>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-// Set the content type to Javascript
-header("Content-type: text/javascript");
-
-// Disallow caching
-header("Cache-Control: no-cache, must-revalidate"); 
-header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); 
-
-if ( array_key_exists('disableSharing', $_) && $_['disableSharing'] == true )  {
-	echo "var disableSharing = true;";
-} else {
-	echo "var disableSharing = false;";
-}
diff --git a/apps/files/settings.php b/apps/files/settings.php
index 30463210f719e2797d2ed843b435c88fc86e2e91..8687f0131378c649a2fc42b5362b386d634e4d80 100644
--- a/apps/files/settings.php
+++ b/apps/files/settings.php
@@ -21,10 +21,6 @@
 *
 */
 
-
-// Init owncloud
-
-
 // Check if we are a user
 OCP\User::checkLoggedIn();
 
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
index 1c683c1123080f9054f27c4098ec417b2c19d177..5c39dda85ffd8bc1810eb4911853db92df76e0a4 100644
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -1,4 +1,4 @@
-<script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('publicListView');?>"></script>
+<input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>">
 
 <?php foreach($_['files'] as $file):
 	$simple_file_size = OCP\simple_file_size($file['size']);
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 780b9c1bf6d9eb925680ee1552a8066066dcf7c0..eb5a6e8cb7fe27e001353a3e348757e60b4638a9 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -1,5 +1,7 @@
 $(document).ready(function() {
 
+	var disableSharing = $('#disableSharing').data('status');
+
 	if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined'  && !disableSharing) {
 
 		FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index 275360ac2a869e86d705696a379ef62a845b6dfa..35cca7c42dc9c2832c5b3923fdc681d3ddfed6f8 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -1,5 +1,3 @@
-<script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('publicListView');?>"></script>
-
 <input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir">
 <input type="hidden" name="downloadURL" value="<?php echo $_['downloadURL'] ?>" id="downloadURL">
 <input type="hidden" name="filename" value="<?php echo $_['filename'] ?>" id="filename">
diff --git a/config/config.sample.php b/config/config.sample.php
index 51373327f449cce52da754b894c4d592d99cd069..78d513c7f23d044f53de2245fafaab3f2cb7992a 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -92,6 +92,10 @@ $CONFIG = array(
  */
 "mail_smtpauth" => false,
 
+/* authentication type needed to send mail, depends on mail_smtpmode if this is used
+ * Can be LOGIN (default), PLAIN or NTLM */
+"mail_smtpauthtype" => "LOGIN",
+
 /* Username to use for sendmail mail, depends on mail_smtpauth if this is used */
 "mail_smtpname" => "",
 
diff --git a/core/js/config.php b/core/js/config.php
index e838fb1cd04fd6e9c6129b125c603a586712b308..9069175ed6fa58d542ee165fbb4fe3dbad42ef9e 100644
--- a/core/js/config.php
+++ b/core/js/config.php
@@ -17,11 +17,15 @@ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
 $l = OC_L10N::get('core');
 
 // Get the config
-$debug = (defined('DEBUG') && DEBUG) ? 'true' : 'false';
+$apps_paths = array();
+foreach(OC_App::getEnabledApps() as $app) {
+	$apps_paths[$app] = OC_App::getAppWebPath($app);
+}
+
 $array = array(
-	"oc_debug" => $debug,
+	"oc_debug" => (defined('DEBUG') && DEBUG) ? 'true' : 'false',
 	"oc_webroot" => "\"".OC::$WEBROOT."\"",
-	"oc_appswebroots" =>  "\"".$_['apps_paths']. "\"", 
+	"oc_appswebroots" =>  str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
 	"oc_current_user" =>  "\"".OC_User::getUser(). "\"",
 	"oc_requesttoken" =>  "\"".OC_Util::callRegister(). "\"",
 	"datepickerFormatDate" => json_encode($l->l('jsdate', 'jsdate')),
diff --git a/core/js/update.js b/core/js/update.js
new file mode 100644
index 0000000000000000000000000000000000000000..8ab02bbf9350c3bdeb594a49561c6ae6499b34c2
--- /dev/null
+++ b/core/js/update.js
@@ -0,0 +1,23 @@
+$(document).ready(function () {
+	var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php');
+	updateEventSource.listen('success', function(message) {
+		$('<span>').append(message).append('<br />').appendTo($('.update'));
+	});
+	updateEventSource.listen('error', function(message) {
+		$('<span>').addClass('error').append(message).append('<br />').appendTo($('.update'));
+	});
+	updateEventSource.listen('failure', function(message) {
+		$('<span>').addClass('error').append(message).append('<br />').appendTo($('.update'));
+		$('<span>')
+		.addClass('error bold')
+		.append('<br />')
+		.append(t('core', 'The update was unsuccessful. Please report this issue to the <a href="https://github.com/owncloud/core/issues" target="_blank">ownCloud community</a>.'))
+		.appendTo($('.update'));
+	});
+	updateEventSource.listen('done', function(message) {
+		$('<span>').addClass('bold').append('<br />').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($('.update'));
+		setTimeout(function () {
+			window.location.href = OC.webroot;
+		}, 3000);
+	});
+});
\ No newline at end of file
diff --git a/core/templates/update.php b/core/templates/update.php
index c65230db0d68d6094fbd4c12b3f7add130994a83..ae714dcfb92211849acd7dbde483e4e2f246bdd6 100644
--- a/core/templates/update.php
+++ b/core/templates/update.php
@@ -3,28 +3,3 @@
 		<?php echo $l->t('Updating ownCloud to version %s, this may take a while.', array($_['version'])); ?><br /><br />
 	</li>
 </ul>
-<script>
-	$(document).ready(function () {
-		var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php');
-		updateEventSource.listen('success', function(message) {
-			$('<span>').append(message).append('<br />').appendTo($('.update'));
-		});
-		updateEventSource.listen('error', function(message) {
-			$('<span>').addClass('error').append(message).append('<br />').appendTo($('.update'));
-		});
-		updateEventSource.listen('failure', function(message) {
-			$('<span>').addClass('error').append(message).append('<br />').appendTo($('.update'));
-			$('<span>')
-				.addClass('error bold')
-				.append('<br />')
-				.append(t('core', 'The update was unsuccessful. Please report this issue to the <a href="https://github.com/owncloud/core/issues" target="_blank">ownCloud community</a>.'))
-				.appendTo($('.update'));
-		});
-		updateEventSource.listen('done', function(message) {
-			$('<span>').addClass('bold').append('<br />').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($('.update'));
-			setTimeout(function () {
-				window.location.href = OC.webroot;
-			}, 3000);
-		});
-	});
-</script>
\ No newline at end of file
diff --git a/lib/base.php b/lib/base.php
index e6f00839aa28dbd7b5adb8d1a29a1a364e49e568..c1fece0c3d96cafc7d1f975b072dad417d840ed4 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -261,6 +261,7 @@ class OC
 				if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
 					OC_Config::setValue('maintenance', true);
 					OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
+					OC_Util::addscript('update');
 					$tmpl = new OC_Template('', 'update', 'guest');
 					$tmpl->assign('version', OC_Util::getVersionString());
 					$tmpl->printPage();
@@ -431,8 +432,6 @@ class OC
 		self::checkSSL();
 		self::initSession();
 		self::initTemplateEngine();
-		self::checkMaintenanceMode();
-		self::checkUpgrade();
 
 		$errors = OC_Util::checkServer();
 		if (count($errors) > 0) {
@@ -572,10 +571,13 @@ class OC
 			return;
 		}
 
+		// Check if ownCloud is installed or in maintenance (update) mode
 		if (!OC_Config::getValue('installed', false)) {
 			require_once 'core/setup.php';
 			exit();
 		}
+		self::checkMaintenanceMode();
+		self::checkUpgrade();
 		
 		// Handle redirect URL for logged in users
 		if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
diff --git a/lib/mail.php b/lib/mail.php
index ffc4d01b79f5dbde035be04f369f62d58d5f4f96..1bb202ac977e193acecdf01cf1cb4847f6786dcf 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -38,6 +38,7 @@ class OC_Mail {
 		$SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' );
 		$SMTPPORT = OC_Config::getValue( 'mail_smtpport', 25 );
 		$SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', false );
+		$SMTPAUTHTYPE = OC_Config::getValue( 'mail_smtpauthtype', 'LOGIN' );
 		$SMTPUSERNAME = OC_Config::getValue( 'mail_smtpname', '' );
 		$SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' );
 		$SMTPDEBUG    = OC_Config::getValue( 'mail_smtpdebug', false );
@@ -62,6 +63,7 @@ class OC_Mail {
 		$mailo->SMTPAuth = $SMTPAUTH;
 		$mailo->SMTPDebug = $SMTPDEBUG;
 		$mailo->SMTPSecure = $SMTPSECURE;
+		$mailo->AuthType = $SMTPAUTHTYPE;
 		$mailo->Username = $SMTPUSERNAME;
 		$mailo->Password = $SMTPPASSWORD;
 		$mailo->Timeout  = $SMTPTIMEOUT;
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 83d361999867410d618da5414c37b71ce5112eec..37ece91047f4b4c012a2116b1eb724307fe90ff3 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -28,11 +28,6 @@ class OC_TemplateLayout extends OC_Template {
 					break;
 				}
 			}
-			$apps_paths = array();
-			foreach(OC_App::getEnabledApps() as $app) {
-				$apps_paths[$app] = OC_App::getAppWebPath($app);
-			}
-			$this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes waiting for better solution
 		} else if ($renderas == 'guest') {
 			parent::__construct('core', 'layout.guest');
 		} else {
diff --git a/lib/user.php b/lib/user.php
index fd0ed6ecd3ac5091685ec739ca7b164dc4774718..85240ce6b68e8f0ccd799813d95b53a668fb74f0 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -383,8 +383,8 @@ class OC_User {
 
 	/**
 	 * @brief Check if the password is correct
-	 * @param $uid The username
-	 * @param $password The password
+	 * @param string $uid The username
+	 * @param string $password The password
 	 * @returns string
 	 *
 	 * returns the path to the users home directory