diff --git a/.htaccess b/.htaccess
index adc6667d5bf64ce0e4f282dc9c53da2a7b187255..fd1f6abb969c671fc75f408f34d7fc05dd046e39 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,9 +1,9 @@
 ErrorDocument 403 /core/templates/403.php
 ErrorDocument 404 /core/templates/404.php
-Redirect 301 /apps/calendar/caldav.php /remote/caldav.php
-Redirect 301 /apps/contacts/carddav.php /remote/carddav.php
-Redirect 301 /apps/files/webdav.php /remote/webdav.php
-Redirect 301 /files/webdav.php /remote/webdav.php
+Redirect 301 /apps/calendar/caldav.php /remote.php/caldav/
+Redirect 301 /apps/contacts/carddav.php /remote.php/carddav/
+Redirect 301 /apps/files/webdav.php /remote.php/webdav/
+Redirect 301 /files/webdav.php /remote.php/webdav/
 <IfModule mod_php5.c>
 php_value upload_max_filesize 512M
 php_value post_max_size 512M
@@ -15,9 +15,10 @@ php_value memory_limit 512M
 <IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
-RewriteRule ^.well-known/carddav /remote/carddav.php [R]
-RewriteRule ^.well-known/caldav /remote/caldav.php [R]
+RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]
+RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]
 
 RewriteRule ^apps/([^/]*)/(.*\.(css|php))$ index.php?app=$1&getfile=$2 [QSA,L]
+RewriteRule ^remote/(.*) remote.php [QSA,L]
 </IfModule>
 Options -Indexes
diff --git a/3rdparty/Sabre/DAV/Server.php b/3rdparty/Sabre/DAV/Server.php
index 4284c127b6e120ac33b110e5df019e0502d6d797..50b190e8fabf834a9c421b9638eadb71156e20b6 100644
--- a/3rdparty/Sabre/DAV/Server.php
+++ b/3rdparty/Sabre/DAV/Server.php
@@ -215,7 +215,7 @@ class Sabre_DAV_Server {
             $DOM->appendChild($error);
 
             $error->appendChild($DOM->createElement('s:exception',get_class($e)));
-            $error->appendChild($DOM->createElement('s:message',$e->getMessage()));
+            $error->appendChild($DOM->createElement('s:message',htmlentities($e->getMessage())));
             if ($this->debugExceptions) {
                 $error->appendChild($DOM->createElement('s:file',$e->getFile()));
                 $error->appendChild($DOM->createElement('s:line',$e->getLine()));
diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php
index 2eb20414292b110f49858ccd062c2f9cf6396c76..4e0803f791b29441fd4689c6891b7a3be520bc84 100755
--- a/apps/admin_dependencies_chk/settings.php
+++ b/apps/admin_dependencies_chk/settings.php
@@ -68,12 +68,24 @@ $modules[] =array(
 	'modules'=> array('core'),
 	'message'=> $l->t('The php-ctype module is needed validate data.'));
 
+$modules[] =array(
+	'status' => class_exists('DOMDocument') ? 'ok' : 'error',
+	'part'=> 'php-xml',
+	'modules'=> array('core'),
+	'message'=> $l->t('The php-xml module is needed to share files with webdav.'));
+
 $modules[] =array(
 	'status' => ini_get('allow_url_fopen') == '1' ? 'ok' : 'error',
 	'part'=> 'allow_url_fopen',
 	'modules'=> array('core'),
 	'message'=> $l->t('The allow_url_fopen directive of your php.ini should be set to 1 to retrieve knowledge base from OCS servers'));
 
+$modules[] =array(
+	'status' => class_exists('PDO') ? 'ok' : 'warning',
+	'part'=> 'php-pdo',
+	'modules'=> array('core'),
+	'message'=> $l->t('The php-pdo module is needed to store owncloud data into a database.'));
+
 foreach($modules as $key => $module) {
 	$enabled = false ;
 	foreach($module['modules'] as $app) {
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 055066de0df03f66b79438c6f236c694de279827..0c91bf8f135b01e004de13d07fe0e8c6d71581a1 100755
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -23,6 +23,5 @@ OCP\App::addNavigationEntry( array(
   'name' => $l->t('Calendar')));
 OCP\App::registerPersonal('calendar', 'settings');
 OC_Search::registerProvider('OC_Search_Provider_Calendar');
-if(!file_exists(OC::$SERVERROOT.'/remote/caldav.php')){
-	file_put_contents(OC::$SERVERROOT.'/remote/caldav.php', file_get_contents(OC::$APPSROOT . '/apps/calendar/appinfo/remote.php'));
-}
\ No newline at end of file
+OCP\CONFIG::setAppValue('core', 'remote_caldav', '/apps/calendar/appinfo/remote.php');
+OCP\CONFIG::setAppValue('core', 'public_calendar', '/apps/calendar/share.php');
\ No newline at end of file
diff --git a/apps/calendar/appinfo/remote.php b/apps/calendar/appinfo/remote.php
index 32b454ee90ca27e2c2a1187338a65b41d248199a..7ff6a2fbbe2b3cbc00111bac59adb9d7f8258dbe 100755
--- a/apps/calendar/appinfo/remote.php
+++ b/apps/calendar/appinfo/remote.php
@@ -5,10 +5,6 @@
  * later.
  * See the COPYING-README file.
  */
-// Do not load FS ...
-$RUNTIME_NOSETUPFS = true;
-require_once('../lib/base.php');
-
 OCP\App::checkAppEnabled('calendar');
 
 // Backends
@@ -24,7 +20,7 @@ $nodes = array(
 
 // Fire up server
 $server = new Sabre_DAV_Server($nodes);
-$server->setBaseUri(OC::$WEBROOT.'/remote/caldav.php');
+$server->setBaseUri($baseuri);
 // Add plugins
 $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
 $server->addPlugin(new Sabre_CalDAV_Plugin());
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index a16856938ce0b43cb893491e907a24d5fe1702dc..b3beb8d44cb9364aa730f4886622547c8c5460f4 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -517,7 +517,10 @@ Calendar={
 			},
 			share:function(id, idtype, sharewith, sharetype){
 				$.getJSON(OC.filePath('calendar', 'ajax/share', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){
-
+					if(sharetype == 'public'){
+						$('#public_token').val(parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=calendar&t='+data.message);
+						$('#public_token').css('display', 'block');
+					}
 				});
 			},
 			unshare:function(id, idtype, sharewith, sharetype){
diff --git a/apps/calendar/share.php b/apps/calendar/share.php
index 1cc8a2ef15edd9708cc73f9ba3edc5fff45e3dd8..68c7d0ffae28013b156ff2af4249bb3cfc7e67a9 100644
--- a/apps/calendar/share.php
+++ b/apps/calendar/share.php
@@ -1,5 +1,4 @@
 <?php
-require_once('../../lib/base.php');
 $token = strip_tags($_GET['t']);
 $shared = OC_Calendar_Share::getElementByToken($token);
 $nl = "\n\r";
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index 7e767e367324ef006152cc0d85e384a6c2f1e117..832194f0fe1ed32c33a3f35f944ee87009a8c3e4 100755
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -19,7 +19,7 @@
 				var missing_field_totime = '<?php echo addslashes($l->t('To Time')) ?>';
 				var missing_field_startsbeforeends = '<?php echo addslashes($l->t('The event ends before it starts')) ?>';
 				var missing_field_dberror = '<?php echo addslashes($l->t('There was a database fail')) ?>';
-				var totalurl = '<?php echo OCP\Util::linkToAbsolute('calendar', 'caldav.php'); ?>/calendars';
+				var totalurl = '<?php echo OCP\Util::linkToRemote('caldav'); ?>calendars';
 				var firstDay = '<?php echo (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'firstday', 'mo') == 'mo' ? '1' : '0'); ?>';
 				$(document).ready(function() {
 				<?php
diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php
index 0a325ccbc24ec1a1c9f0c190ff2dc8b32e5e97d7..12117750ca55392beb3003553d17dc6bd01c10f2 100755
--- a/apps/calendar/templates/settings.php
+++ b/apps/calendar/templates/settings.php
@@ -47,6 +47,6 @@
         </table>
 
         <?php echo $l->t('Calendar CalDAV syncing address:');?>
-        <code><?php echo OCP\Util::linkToAbsolute('remote', 'caldav.php'); ?></code><br />
+        <code><?php echo OCP\Util::linkToRemote('caldav'); ?></code><br />
         </fieldset>
 </form>
diff --git a/apps/calendar/templates/share.dropdown.php b/apps/calendar/templates/share.dropdown.php
index e0dabebf257426cdacc7591711f1f47382aedd8f..356a8d4fab14e26f8c20a423db860f7be90b095f 100755
--- a/apps/calendar/templates/share.dropdown.php
+++ b/apps/calendar/templates/share.dropdown.php
@@ -73,5 +73,5 @@ echo OCP\html_select_options($allgroups, array());
 </ul>
 <div id="public">
 	<input type="checkbox" id="publish" <?php echo ($public['share'])?'checked="checked"':'' ?>><label for="publish"><?php echo $l->t('make public'); ?></label><br>
-	<input type="text" id="public_token" value="<?php echo OCP\Util::linkToAbsolute('apps/calendar', 'share.php?t=' . $public['share'], null, true) ; ?>" onmouseover="$('#public_token').select();" style="<?php echo (!$public['share'])?'display:none':'' ?>">
-</div>
\ No newline at end of file
+	<input type="text" id="public_token" value="<?php echo OCP\Util::linkToAbsolute('', 'public.php').'?service=calendar&t=' . $public['share'] ?>" onmouseover="$('#public_token').select();" style="<?php echo (!$public['share'])?'display:none':'' ?>">
+</div>
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index c8c1d779daef6013ad4d291568e73f08f76ccc0f..7e196733064ddab8337f37498cbb4424125d2bba 100755
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -25,6 +25,4 @@ OCP\App::addNavigationEntry( array(
 OCP\App::registerPersonal('contacts','settings');
 OCP\Util::addscript('contacts', 'loader');
 OC_Search::registerProvider('OC_Search_Provider_Contacts');
-if(!file_exists(OC::$SERVERROOT.'/remote/carddav.php')){
-	file_put_contents(OC::$SERVERROOT.'/remote/carddav.php', file_get_contents(OC::$APPSROOT . '/apps/contacts/appinfo/remote.php'));
-}
\ No newline at end of file
+OCP\CONFIG::setAppValue('core', 'remote_carddav', '/apps/contacts/appinfo/remote.php');
\ No newline at end of file
diff --git a/apps/contacts/appinfo/remote.php b/apps/contacts/appinfo/remote.php
index 804c560e3d0414c15d067cba22ad61754b100505..67006b77f97c1c3c4ddfe85e6e9d21eb434b9409 100755
--- a/apps/contacts/appinfo/remote.php
+++ b/apps/contacts/appinfo/remote.php
@@ -19,9 +19,6 @@
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-// Do not load FS ...
-$RUNTIME_NOSETUPFS = true;
-require_once('../lib/base.php');
 
 OCP\App::checkAppEnabled('contacts');
 
@@ -38,7 +35,7 @@ $nodes = array(
 
 // Fire up server
 $server = new Sabre_DAV_Server($nodes);
-$server->setBaseUri(OC::$WEBROOT.'/remote/carddav.php');
+$server->setBaseUri($baseuri);
 // Add plugins
 $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
 $server->addPlugin(new Sabre_CardDAV_Plugin());
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 68a01174d8326c9a3732235c5d80e4273ab84a19..44b2979220602c4cc92641cc905aa155efec1cb8 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -168,14 +168,14 @@ Contacts={
 			honsuf:'',
 			data:undefined,
 			update:function(id) {
-				// Make sure proper DOM is loaded.
 				var newid;
 				if(id == undefined) {
 					newid = $('#contacts li:first-child').data('id');
 				} else {
 					newid = id;
 				}
-				if(!$('n')) {
+				// Make sure proper DOM is loaded.
+				if(!$('#card')) {
 					$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){
 						if(jsondata.status == 'success'){
 							$('#rightcontent').html(jsondata.data.page);
@@ -185,8 +185,6 @@ Contacts={
 					});
 				}
 				if($('#contacts li').length > 0) {
-					//var newid = $('#contacts li:first-child').data('id');
-					//$('#contacts li:first-child').addClass('active');
 					$('#leftcontent li[data-id="'+newid+'"]').addClass('active');
 					$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
 						if(jsondata.status == 'success'){
@@ -210,8 +208,6 @@ Contacts={
 			},
 			doExport:function() {
 				document.location.href = OC.linkTo('contacts', 'export.php') + '?contactid=' + this.id;
-				//$.get(OC.linkTo('contacts', 'export.php'),{'contactid':this.id},function(jsondata){
-				//});
 			},
 			doImport:function(){
 				Contacts.UI.notImplemented();
@@ -249,7 +245,7 @@ Contacts={
 								if(!added) {
 									$('#leftcontent ul').append(item);
 								}
-								if(isnew) {
+								if(isnew) { // add some default properties
 									Contacts.UI.Card.addProperty('EMAIL');
 									Contacts.UI.Card.addProperty('TEL');
 									Contacts.UI.Card.addProperty('NICKNAME');
@@ -261,7 +257,6 @@ Contacts={
 							}
 							else{
 								OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
-								//alert(jsondata.data.message);
 							}
 						});
 						$('#contact_identity').show();
@@ -291,11 +286,10 @@ Contacts={
 									newid = newlistitem.data('id');
 								}
 								$('#rightcontent').data('id',newid);
-								//$('#rightcontent').empty();
 								this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
 								this.data = undefined;
-								// Load first in list.
-								if($('#contacts li').length > 0) {
+								
+								if($('#contacts li').length > 0) { // Load first in list.
 									Contacts.UI.Card.update(newid);
 								} else {
 									// load intro page
@@ -313,7 +307,6 @@ Contacts={
 							}
 							else{
 								OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
-								//alert(jsondata.data.message);
 							}
 						});
 					}
@@ -321,7 +314,6 @@ Contacts={
 				return false;
 			},
 			loadContact:function(jsondata){
-				//$('#contact_communication').hide();
 				this.data = jsondata;
 				this.id = this.data.id;
 				$('#rightcontent').data('id',this.id);
@@ -508,7 +500,6 @@ Contacts={
 				}
 			},
 			saveProperty:function(obj){
-				// I couldn't get the selector to filter on 'contacts_property' so I filter by hand here :-/
 				if(!$(obj).hasClass('contacts_property')) {
 					return false;
 				}
@@ -569,7 +560,6 @@ Contacts={
 				}
 			},
 			addProperty:function(type){
-				//console.log('addProperty:' + type);
 				switch (type) {
 					case 'PHOTO':
 						this.loadPhoto(true);
@@ -617,7 +607,6 @@ Contacts={
 			deleteProperty:function(obj, type){
 				Contacts.UI.loading(obj, true);
 				var checksum = Contacts.UI.checksumFor(obj);
-				//console.log('deleteProperty, id: ' + this.id + ', checksum: ' + checksum);
 				if(checksum) {
 					$.getJSON(OC.filePath('contacts', 'ajax', 'deleteproperty.php'),{'id': this.id, 'checksum': checksum },function(jsondata){
 						if(jsondata.status == 'success'){
@@ -822,16 +811,13 @@ Contacts={
 										if(isnew) {
 											container.remove();
 										}
-										//Contacts.UI.showHideContactInfo();
 									}
 								},
 								close : function(event, ui) {
-									//alert('close');
 									$(this).dialog('destroy').remove();
 									if(isnew) {
 										container.remove();
 									}
-									//Contacts.UI.showHideContactInfo();
 								},
 								open : function(event, ui) {
 									$( "#adr_city" ).autocomplete({
@@ -848,9 +834,6 @@ Contacts={
 												},
 												success: function( data ) {
 													response( $.map( data.geonames, function( item ) {
-														/*for(var key in item) {
-															console.log(key + ': ' + item[key]);
-														}*/
 														return {
 															label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
 															value: item.name,
@@ -865,9 +848,6 @@ Contacts={
 											if(ui.item && $('#adr_country').val().trim().length == 0) {
 												$('#adr_country').val(ui.item.country);
 											}
-											/*log( ui.item ?
-												"Selected: " + ui.item.label :
-												"Nothing selected, input was " + this.value);*/
 										},
 										open: function() {
 											$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
@@ -892,9 +872,6 @@ Contacts={
 												},
 												success: function( data ) {
 													response( $.map( data.geonames, function( item ) {
-														//for(var key in item) {
-														//	console.log(key + ': ' + item[key]);
-														//}
 														return {
 															label: item.name,
 															value: item.name
@@ -1245,12 +1222,9 @@ Contacts={
 					  function(jsondata) {
 						if (jsondata.status == 'success'){
 							$(obj).closest('tr').remove();
-							//$('#chooseaddressbook_dialog').dialog('destroy').remove();
 							Contacts.UI.Contacts.update();
-							//Contacts.UI.Addressbooks.overview();
 						} else {
 							OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
-							//alert('Error: ' + data.message);
 						}
 					  });
 				}
@@ -1480,7 +1454,6 @@ $(document).ready(function(){
 			}
 			else{
 				OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
-				//alert(jsondata.data.message);
 			}
 		});
 		return false;
@@ -1507,9 +1480,6 @@ $(document).ready(function(){
 		}
 	});
 	
-	// NOTE: For some reason the selector doesn't work when I select by '.contacts_property' too...
-	// I do the filtering in the event handler instead.
-	//$('input[type="text"],input[type="checkbox"],input[type="email"],input[type="tel"],input[type="date"], select').live('change', function(){
 	$('.contacts_property').live('change', function(){
 		Contacts.UI.Card.saveProperty(this);
 	});
@@ -1523,7 +1493,7 @@ $(document).ready(function(){
 	});
 	
 	// Name has changed. Update it and reorder.
-	$('#fn').live('change',function(){
+	$('#fn').change(function(){
 		var name = $('#fn').val();
 		var item = $('#contacts [data-id="'+Contacts.UI.Card.id+'"]').clone();
 		$('#contacts [data-id="'+Contacts.UI.Card.id+'"]').remove();
@@ -1541,9 +1511,7 @@ $(document).ready(function(){
 		}
 	});
 
-	/**
-	 * Profile picture upload handling
-	 */
+	// Profile picture upload handling
 	// New profile picture selected
 	$('#file_upload_start').change(function(){
 		Contacts.UI.Card.uploadPhoto(this.files);
@@ -1594,30 +1562,22 @@ $(document).ready(function(){
 						OC.dialogs.alert(xhr.status + ': ' + xhr.responseText, t('contacts', 'Error'));
 					}
 				} else {
-					//alert(xhr.responseText);
 					OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
 				}
-				// stop loading indicator
-				//$('#contacts_details_photo_progress').hide();
 			}
 		};
 	
 		fileUpload.onprogress = function(e){
 			if (e.lengthComputable){
 				var _progress = Math.round((e.loaded * 100) / e.total);
-				if (_progress != 100){
-					//$('#contacts_details_photo_progress').text(_progress + '%');
-					//$('#contacts_details_photo_progress').val(_progress);
-				}
+				//if (_progress != 100){
+				//}
 			}
 		};
-		// Start loading indicator.
-		//$('#contacts_details_photo_progress').show()();
 		xhr.open('POST', OC.filePath('contacts', 'ajax', 'uploadphoto.php')+'?id='+Contacts.UI.Card.id+'&imagefile='+encodeURIComponent(file.name), true);
 		xhr.setRequestHeader('Cache-Control', 'no-cache');
 		xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
 		xhr.setRequestHeader('X_FILE_NAME', encodeURIComponent(file.name));
-		//xhr.setRequestHeader("X_FILENAME", file.name);
 		xhr.setRequestHeader('X-File-Size', file.size);
 		xhr.setRequestHeader('Content-Type', file.type);
 		xhr.send(file);
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php
index c28b47e7c287e6366ebb09172b5f2b1eb045f31b..7d212e71ba830f096f8d8da68f1cb4168c69410b 100755
--- a/apps/contacts/templates/index.php
+++ b/apps/contacts/templates/index.php
@@ -1,5 +1,5 @@
 <script type='text/javascript'>
-	var totalurl = '<?php echo OCP\Util::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
+	var totalurl = '<?php echo OCP\Util::linkToRemote('carddav'); ?>addressbooks';
 	var categories = <?php echo json_encode($_['categories']); ?>;
 	var lang = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>';
 </script>
diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php
index 9dffdfb0e4fc157b443f3d92b6d380497b7b0ef5..216003b6c698938437807adb6dbb54317f88a5fb 100755
--- a/apps/contacts/templates/settings.php
+++ b/apps/contacts/templates/settings.php
@@ -4,9 +4,9 @@
 		<?php echo $l->t('CardDAV syncing addresses'); ?> (<a href="http://owncloud.org/synchronisation/" target="_blank"><?php echo $l->t('more info'); ?></a>)
 		<dl>
 		<dt><?php echo $l->t('Primary address (Kontact et al)'); ?></dt>
-		<dd><code><?php echo OCP\Util::linkToAbsolute('remote', 'carddav.php'); ?>/</code></dd>
+		<dd><code><?php echo OCP\Util::linkToRemote('carddav'); ?></code></dd>
 		<dt><?php echo $l->t('iOS/OS X'); ?></dt>
-		<dd><code><?php echo OCP\Util::linkToAbsolute('remote', 'carddav.php'); ?>/principals/<?php echo OCP\USER::getUser(); ?></code>/</dd>
+		<dd><code><?php echo OCP\Util::linkToRemote('carddav'); ?>principals/<?php echo OCP\USER::getUser(); ?></code>/</dd>
 		</dl>
 		Powered by <a href="http://geonames.org/" target="_blank">geonames.org webservice</a>
 	</fieldset>
diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php
index 3f4e1705fb0b06eec4f3fc84d01eb6ca96637934..e7358242ddbfaa896e128f3dbd3495337f255672 100755
--- a/apps/files/appinfo/app.php
+++ b/apps/files/appinfo/app.php
@@ -1,6 +1,4 @@
 <?php
-
-
 $l=OC_L10N::get('files');
 
 OCP\App::register( array( "order" => 2, "id" => "files", "name" => "Files" ));
@@ -9,6 +7,4 @@ OCP\App::registerAdmin('files','admin');
 OCP\App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") ));
 
 OC_Search::registerProvider('OC_Search_Provider_File');
-if(!file_exists(OC::$SERVERROOT.'/remote/webdav.php')){
-	file_put_contents(OC::$SERVERROOT.'/remote/webdav.php', file_get_contents(OC::$APPSROOT . '/apps/files/appinfo/remote.php'));
-}
\ No newline at end of file
+OCP\CONFIG::setAppValue('core', 'remote_webdav', '/apps/files/appinfo/remote.php');
\ No newline at end of file
diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php
index defb97ab152ef8ed451661884c94bcb141e2e81b..465e0c0a93556d7ff6035a5d0ba2324951dc533e 100644
--- a/apps/files/appinfo/remote.php
+++ b/apps/files/appinfo/remote.php
@@ -22,12 +22,8 @@
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-
-// Do not load FS ...
-$RUNTIME_NOSETUPFS = true;
 // only need filesystem apps
 $RUNTIME_APPTYPES=array('filesystem','authentication');
-require_once('../lib/base.php');
 
 // Backends
 $authBackend = new OC_Connector_Sabre_Auth();
@@ -38,7 +34,7 @@ $publicDir = new OC_Connector_Sabre_Directory('');
 
 // Fire up server
 $server = new Sabre_DAV_Server($publicDir);
-$server->setBaseUri(OC::$WEBROOT.'/remote/webdav.php');
+$server->setBaseUri($baseuri);
 
 // Load plugins
 $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
diff --git a/apps/files/index.php b/apps/files/index.php
index 0c439e4ae1afb6a437af70f4b17e7f4153553799..7ead3ce8f862812a8f0e1dfa2b275933225e1b5d 100755
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -25,26 +25,26 @@
 OCP\User::checkLoggedIn();
 
 // Load the files we need
-OCP\Util::addStyle( "files", "files" );
-OCP\Util::addscript( "files", "jquery.iframe-transport" );
-OCP\Util::addscript( "files", "jquery.fileupload" );
-OCP\Util::addscript( "files", "files" );
+OCP\Util::addStyle( 'files', 'files' );
+OCP\Util::addscript( 'files', 'jquery.iframe-transport' );
+OCP\Util::addscript( 'files', 'jquery.fileupload' );
+OCP\Util::addscript( 'files', 'files' );
 OCP\Util::addscript( 'files', 'filelist' );
 OCP\Util::addscript( 'files', 'fileactions' );
 if(!isset($_SESSION['timezone'])){
 	OCP\Util::addscript( 'files', 'timezone' );
 }
-OCP\App::setActiveNavigationEntry( "files_index" );
+OCP\App::setActiveNavigationEntry( 'files_index' );
 // Load the files
 $dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : '';
 // Redirect if directory does not exist
 if(!OC_Filesystem::is_dir($dir.'/')) {
-	header("Location: ".$_SERVER['PHP_SELF']."");
+	header('Location: '.$_SERVER['PHP_SELF'].'');
 }
 
 $files = array();
 foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
-	$i["date"] = OCP\Util::formatDate($i["mtime"] );
+	$i['date'] = OCP\Util::formatDate($i['mtime'] );
 	if($i['type']=='file'){
 		$fileinfo=pathinfo($i['name']);
 		$i['basename']=$fileinfo['filename'];
@@ -63,22 +63,22 @@ foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
 
 // Make breadcrumb
 $breadcrumb = array();
-$pathtohere = "";
-foreach( explode( "/", $dir ) as $i ){
-	if( $i != "" ){
-		$pathtohere .= "/".str_replace('+','%20', urlencode($i));
-		$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
+$pathtohere = '';
+foreach( explode( '/', $dir ) as $i ){
+	if( $i != '' ){
+		$pathtohere .= '/'.str_replace('+','%20', urlencode($i));
+		$breadcrumb[] = array( 'dir' => $pathtohere, 'name' => $i );
 	}
 }
 
 // make breadcrumb und filelist markup
-$list = new OCP\Template( "files", "part.list", "" );
-$list->assign( "files", $files );
-$list->assign( "baseURL", OCP\Util::linkTo("files", "index.php")."?dir=");
-$list->assign( "downloadURL", OCP\Util::linkTo("files", "download.php")."?file=");
-$breadcrumbNav = new OCP\Template( "files", "part.breadcrumb", "" );
-$breadcrumbNav->assign( "breadcrumb", $breadcrumb );
-$breadcrumbNav->assign( "baseURL", OCP\Util::linkTo("files", "index.php")."?dir=");
+$list = new OCP\Template( 'files', 'part.list', '' );
+$list->assign( 'files', $files );
+$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir=');
+$list->assign( 'downloadURL', OCP\Util::linkTo('files', 'download.php').'?file=');
+$breadcrumbNav = new OCP\Template( 'files', 'part.breadcrumb', '' );
+$breadcrumbNav->assign( 'breadcrumb', $breadcrumb );
+$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir=');
 
 $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
 $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
@@ -88,12 +88,12 @@ $freeSpace=OC_Filesystem::free_space('/');
 $freeSpace=max($freeSpace,0);
 $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
 
-$tmpl = new OCP\Template( "files", "index", "user" );
-$tmpl->assign( "fileList", $list->fetchPage() );
-$tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );
+$tmpl = new OCP\Template( 'files', 'index', 'user' );
+$tmpl->assign( 'fileList', $list->fetchPage() );
+$tmpl->assign( 'breadcrumb', $breadcrumbNav->fetchPage() );
 $tmpl->assign( 'dir', $dir);
 $tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir));
-$tmpl->assign( "files", $files );
+$tmpl->assign( 'files', $files );
 $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
 $tmpl->assign( 'uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
 $tmpl->assign( 'allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php
index 6eed0408238c2b95b9cda84bed0d0000f291cf4a..36ac372cad44de36f695a702055b292889efe7ec 100755
--- a/apps/files_sharing/ajax/getitem.php
+++ b/apps/files_sharing/ajax/getitem.php
@@ -19,7 +19,7 @@ while ($path != $userDirectory) {
 					$item['privateLink'] = $token;
 				} else {
 					// If in parent folder, include a path parameter to get direct access to file
-					$item['privateLink'] = $token.'&path='.substr($source, strlen($path));
+					$item['privateLink'] = $token.'&path='.str_replace('%2F', '/', str_replace('+', '%20', urlencode(substr($source, strlen($path)))));;
 				}
 			} else {
 				// Check if uid_shared_with is a group
diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php
index 79ebf9187b9c727c723f479b71c8e8b24f1f20bb..4478144e92f3df9b1005302f5324a3a4c578823c 100755
--- a/apps/files_sharing/ajax/share.php
+++ b/apps/files_sharing/ajax/share.php
@@ -22,12 +22,12 @@ foreach ($sources as $source) {
 				OCP\JSON::success();
 			}
 		} catch (Exception $exception) {
-			OCP\Util::writeLog('files_sharing', 'Unexpected Error : '.$exception->getMessage(),OCP\Util::ERROR);
-			OCP\JSON::error();
+			OCP\Util::writeLog('files_sharing', 'Unexpected Error : '.$exception->getMessage(), OCP\Util::ERROR);
+			OCP\JSON::error(array('data' => array('message' => $exception->getMessage())));
 		}
 	} else {
-		OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :'.$source,OCP\Util::ERROR);
-		OCP\JSON::error();
+		OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :'.$source, OCP\Util::ERROR);
+		OCP\JSON::error(array('data' => array('message' => 'File does not exist or is not readable')));
 	}
 }
 
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index bd81a45cc555408be0881f747c047fe0f1fb530a..b3b9776d2970f34d1044742924c6c345d963cc49 100755
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -17,5 +17,5 @@ if ($dir != '/Shared' || OCP\Config::getAppValue('files_sharing', 'resharing', '
 OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min");
 OCP\Util::addStyle( 'files_sharing', 'sharing' );
 OCP\Util::addStyle("3rdparty", "chosen/chosen");
-
+OCP\CONFIG::setAppValue('core', 'public_files', '/apps/files_sharing/get.php');
 ?>
diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php
index 2b2c9dd07fd0bb6a80029bd78b8c56150a926a82..59a4efba6a6c1989bdf706b04793a00d14bb7313 100755
--- a/apps/files_sharing/get.php
+++ b/apps/files_sharing/get.php
@@ -5,9 +5,8 @@ OCP\JSON::checkAppEnabled('files_sharing');
 require_once 'lib_share.php';
 
 //get the path of the shared file
-$token = $_GET['token'];
-$source = OC_Share::getSource($token);
-if ($source !== false) {
+if (isset($_GET['token']) && $source = OC_Share::getSource($_GET['token'])) {
+	$token = $_GET['token'];
 	// TODO Manipulating the string may not be the best choice. Is there an alternative?
 	$user = substr($source, 1, strpos($source, "/", 1) - 1);
 	OC_Util::setupFS($user);
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index e9b46873d3a6f8b240cf6d34970551a7858c3b73..e23146798f29959a861887db3d78e919a5b67d6b 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -35,7 +35,7 @@ OC.Share={
 					callback(result.data);
 				}
 			} else {
-				OC.dialogs.alert('Error', 'Error while sharing');
+				OC.dialogs.alert(result.data.message, 'Error while sharing');
 			}
 		});
 	},
@@ -177,9 +177,9 @@ OC.Share={
 	},
 	showPrivateLink:function(item, token) {
 		$('#privateLinkCheckbox').attr('checked', true);
-		var link = parent.location.protocol+'//'+location.host+OC.linkTo('files_sharing','get.php')+'?token='+token;
+		var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&token='+token;
 		if (token.indexOf('&path=') == -1) {
-			link += '&file=' + item;
+			link += '&file=' + encodeURIComponent(item);
 		} else {
 			// Disable checkbox if inside a shared parent folder
 			$('#privateLinkCheckbox').attr('disabled', 'true');
@@ -210,9 +210,9 @@ OC.Share={
 }
 
 $(document).ready(function() {
-	OC.Share.loadIcons();
 
 	if (typeof FileActions !== 'undefined') {
+		OC.Share.loadIcons();
 		FileActions.register('all', 'Share', function(filename) {
 			// Return the correct sharing icon
 			if (scanFiles.scanning) { return; } // workaround to prevent additional http request block scanning feedback
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index d5cf3d0a1bab5b89d7e59dfc57da1f8c389f8a5c..c2340bdc1814f2780a1cf55d8b44e113a961d2c3 100755
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -98,15 +98,8 @@ class OC_Share {
 					$uid = $uid."@".$gid;
 				}
 				$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
-				// Add file to filesystem cache
-				$userDirectory = "/".OCP\USER::getUser()."/files";
-				$data = OC_Filecache::get(substr($source, strlen($userDirectory)));
-				$parentQuery = OCP\DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?');
-				$parentResult = $parentQuery->execute(array($sharedFolder))->fetchRow();
-				$parent = $parentResult['id'];
-				$is_writeable = $permissions & OC_Share::WRITE;
-				$cacheQuery = OCP\DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
-				$cacheQuery->execute(array($parent, basename($target), $target, $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], dirname($data['mimetype']), $uid, $is_writeable));
+				// Update mtime of shared folder to invoke a file cache rescan
+				OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder);
 			}
 		}
 	}
@@ -383,6 +376,9 @@ class OC_Share {
 		$source = self::cleanPath($source);
 		$query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
 		$query->execute(array(strlen($source), $source, OCP\USER::getUser()));
+		// Update mtime of shared folder to invoke a file cache rescan
+		$sharedFolder = '/'.$uid_shared_with.'/files/Shared';
+		OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder);
 	}
 
 	/**
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
index 2501ae7bbd520131da62945c30fa326af446d3af..333b1581ce102171d3f31a20b0e5cda3aafaf810 100755
--- a/apps/gallery/appinfo/app.php
+++ b/apps/gallery/appinfo/app.php
@@ -56,4 +56,5 @@ class OC_GallerySearchProvider extends OC_Search_Provider{
 OC_Search::registerProvider('OC_GallerySearchProvider');
 
 require_once('apps/gallery/lib/hooks_handlers.php');
+OCP\CONFIG::setAppValue('core', 'public_gallery', '/apps/gallery/sharing.php');
 ?>
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
index d44e7f83d1f7a4ff74e5c0943e0d0742daf2e781..61084c99b29b921697d4e1db38c8af23f881ddcc 100644
--- a/apps/gallery/js/album_cover.js
+++ b/apps/gallery/js/album_cover.js
@@ -31,7 +31,7 @@ function albumClick(title) {
 }
 
 function constructSharingPath() {
-  return document.location.protocol + '//' + document.location.host + OC.linkTo('gallery', 'sharing.php') + '?token=' + Albums.token;
+  return document.location.protocol + '//' + document.location.host + OC.linkTo('', 'public.php') + '?service=gallery&token=' + Albums.token;
 }
 
 function shareGallery() {
diff --git a/apps/gallery/js/sharing.js b/apps/gallery/js/sharing.js
index 340d1b9b2745b6c6ad42aa58f83141367830115a..679e39578aa4cd27357c0f3b9c1b651fa1fb95c4 100644
--- a/apps/gallery/js/sharing.js
+++ b/apps/gallery/js/sharing.js
@@ -1,5 +1,5 @@
 $(document).ready(function() {
-  $.getJSON('ajax/sharing.php', {operation: 'get_gallery', token: TOKEN}, albumClickHandler);
+  $.getJSON(OC.filePath('gallery', 'ajax', 'sharing.php'), {operation: 'get_gallery', token: TOKEN}, albumClickHandler);
 });
 
 var paths = [];
@@ -13,7 +13,7 @@ function returnTo(num) {
   }
   path = '';
   for (var e in paths) path += '/' + paths[e];
-  $.getJSON('ajax/sharing.php', {operation: 'get_gallery', token: TOKEN, path: path}, function(r) {
+  $.getJSON(OC.filePath('gallery', 'ajax', 'sharing.php'), {operation: 'get_gallery', token: TOKEN, path: path}, function(r) {
     albumClickHandler(r);
   });
 }
@@ -21,7 +21,7 @@ function returnTo(num) {
 function albumClickHandler(r) {
   var element = $('div#gallery_list');
   element.html('');
-  var album_template = '<div class="gallery_box"><div><a rel="images"><img src="ajax/sharing.php?token='+TOKEN+'&operation=get_album_thumbnail&albumname=IMGPATH"></a></div><h1></h1></div>';
+  var album_template = '<div class="gallery_box"><div><a rel="images"><img src="' + OC.filePath('gallery', 'ajax', 'sharing.php') + '?token='+TOKEN+'&operation=get_album_thumbnail&albumname=IMGPATH"></a></div><h1></h1></div>';
 
   for (var i in r.albums) {
     var a = r.albums[i];
@@ -36,7 +36,7 @@ function albumClickHandler(r) {
       paths.push($(this).attr('title'));
       path = '';
       for (var e in paths) path += '/' + paths[e];
-      $.getJSON('ajax/sharing.php', {operation: 'get_gallery', token: TOKEN, path: path}, function(r) {
+      $.getJSON(OC.filePath('gallery', 'ajax', 'sharing.php'), {operation: 'get_gallery', token: TOKEN, path: path}, function(r) {
         var name = paths[paths.length-1];
         counter++;
         var d = '<span class="breadcrumbelement" onclick="javascript:returnTo('+counter+');return false;">'+name+'</span>';
@@ -49,9 +49,9 @@ function albumClickHandler(r) {
 
   var pat = '';
   for (var a in paths) pat += '/'+paths[a];
-  var photo_template = '<div class="gallery_box"><div><a rel="images" href="*HREF*" target="_blank"><img src="ajax/sharing.php?token='+TOKEN+'&operation=get_thumbnail&img=IMGPATH"></a></div></div>';
+  var photo_template = '<div class="gallery_box"><div><a rel="images" href="*HREF*" target="_blank"><img src="' + OC.filePath('gallery', 'ajax', 'sharing.php') + '?token='+TOKEN+'&operation=get_thumbnail&img=IMGPATH"></a></div></div>';
   for (var a in r.photos) {
-    var local = photo_template.replace('IMGPATH', encodeURIComponent(r.photos[a])).replace('*HREF*', 'ajax/sharing.php?token='+TOKEN+'&operation=get_photo&photo='+encodeURIComponent(r.photos[a]));
+    var local = photo_template.replace('IMGPATH', encodeURIComponent(r.photos[a])).replace('*HREF*', OC.filePath('gallery', 'ajax', 'sharing.php') + '?token='+TOKEN+'&operation=get_photo&photo='+encodeURIComponent(r.photos[a]));
     element.append(local);
   }
 }
diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php
index 26cb2045549882e6dd630f2d36390d462950dfd2..0ab6543e070c85acae176931dd2fd961b6eeccb0 100755
--- a/apps/media/appinfo/app.php
+++ b/apps/media/appinfo/app.php
@@ -32,3 +32,4 @@ OCP\App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' ));
 OCP\App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music')));
 
 OC_Search::registerProvider('OC_MediaSearchProvider');
+OCP\CONFIG::setAppValue('core', 'remote_ampache', '/apps/media/remote.php');
\ No newline at end of file
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php
index d658605611c41c4447812bdd865d494d9674426f..f5c91661abee3747c1f69ec30b446951b4261793 100755
--- a/apps/media/lib_ampache.php
+++ b/apps/media/lib_ampache.php
@@ -207,7 +207,7 @@ class OC_MEDIA_AMPACHE{
 		echo("\t\t<title>$name</title>\n");
 		echo("\t\t<artist id='$artist'>$artistName</artist>\n");
 		echo("\t\t<album id='$album'>$albumName</album>\n");
-		$url=OCP\Util::linkToAbsolute('media', 'server/xml.server.php')."?action=play&song=$id&auth={$_GET['auth']}";
+		$url=OCP\Util::linkToRemote('ampache')."server/xml.server.php/?action=play&song=$id&auth={$_GET['auth']}";
 		$url=self::fixXmlString($url);
 		echo("\t\t<url>$url</url>\n");
 		echo("\t\t<time>{$song['song_length']}</time>\n");
diff --git a/apps/media/remote.php b/apps/media/remote.php
new file mode 100644
index 0000000000000000000000000000000000000000..8a88c2b51ae93ede1b9f06f05c57817f621a1b9b
--- /dev/null
+++ b/apps/media/remote.php
@@ -0,0 +1,7 @@
+<?php
+if($path_info == '/ampache' || $path_info == '/ampache/'){
+	require_once(OC::$APPSROOT . '/apps/media/index.php');
+}else{
+	require_once(OC::$APPSROOT . '/apps/media/server/xml.server.php');
+}
+?>
\ No newline at end of file
diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php
index 63f2a51dcb51dbc6562261fd460ac975d1f3b79a..6cb6c91ca06bdffdb317f2427f85ec985ca610d2 100755
--- a/apps/media/server/xml.server.php
+++ b/apps/media/server/xml.server.php
@@ -21,8 +21,6 @@
 * 
 */
 
-require_once('../../inc.php');
-
 OCP\App::checkAppEnabled('media');
  require_once(OC::$APPSROOT . '/apps/media/lib_collection.php');
  require_once(OC::$APPSROOT . '/apps/media/lib_ampache.php');
diff --git a/apps/media/templates/settings.php b/apps/media/templates/settings.php
index 2fe0b945a63d248a32fe9c0e990b28694aea1109..a7dc0775c44784e440c46a2a7dc68fe3733b1b83 100755
--- a/apps/media/templates/settings.php
+++ b/apps/media/templates/settings.php
@@ -2,6 +2,6 @@
 	<fieldset class="personalblock">
 		<strong>Media</strong><br />
 		Ampache address: 
-		<code><?php echo OCP\Util::linkToAbsolute('media', ''); ?></code><br />
+		<code><?php echo OCP\Util::linkToRemote('ampache'); ?></code><br />
 	</fieldset>
 </form>
diff --git a/apps/remoteStorage/appinfo/webfinger.php b/apps/remoteStorage/appinfo/webfinger.php
index 7c0ab846057bf5eab72a2fb7a299c1ad271b1918..6403d3a6916e8abd0b20513bf74f4ec02f1cec30 100644
--- a/apps/remoteStorage/appinfo/webfinger.php
+++ b/apps/remoteStorage/appinfo/webfinger.php
@@ -1,6 +1,8 @@
+<?php if(OC_User::userExists(WF_USER)) { ?>
     <Link
         rel="remoteStorage"
         template="<?php echo WF_BASEURL; ?>/apps/remoteStorage/WebDAV.php/<?php echo WF_USER; ?>/remoteStorage/{category}/"
         api="WebDAV"
         auth="<?php echo WF_BASEURL; ?>/apps/remoteStorage/auth.php/<?php echo WF_USER; ?>">
     </Link>
+<?php } ?>
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php
index c71c0cb7e543d88a31f1cd4fc4c3f01baafff638..4c2c22cbbeeba7ffc8f4036d43789eaf31d29f31 100755
--- a/apps/user_ldap/lib_ldap.php
+++ b/apps/user_ldap/lib_ldap.php
@@ -568,6 +568,15 @@ class OC_LDAP {
 			self::$ldapUserFilter       = OCP\Config::getAppValue('user_ldap', 'ldap_userlist_filter','objectClass=person');
 			self::$ldapGroupDisplayName = OCP\Config::getAppValue('user_ldap', 'ldap_group_display_name', LDAP_GROUP_DISPLAY_NAME_ATTR);
 
+			if(empty(self::$ldapBaseUsers)) {
+				OCP\Util::writeLog('ldap', 'Base for Users is empty, using Base DN', OCP\Util::INFO);
+				self::$ldapBaseUsers = self::$ldapBase;
+			}
+			if(empty(self::$ldapBaseGroups)) {
+				OCP\Util::writeLog('ldap', 'Base for Groups is empty, using Base DN', OCP\Util::INFO);
+				self::$ldapBaseGroups = self::$ldapBase;
+			}
+
 			if(
 				   !empty(self::$ldapHost)
 				&& !empty(self::$ldapPort)
@@ -576,8 +585,6 @@ class OC_LDAP {
 					|| ( empty(self::$ldapAgentName) &&  empty(self::$ldapAgentPassword))
 				)
 				&& !empty(self::$ldapBase)
-				&& !empty(self::$ldapBaseUsers)
-				&& !empty(self::$ldapBaseGroups)
 				&& !empty(self::$ldapUserDisplayName)
 			)
 			{
@@ -591,6 +598,7 @@ class OC_LDAP {
 	 */
 	static private function establishConnection() {
 		if(!self::$configured) {
+			OCP\Util::writeLog('ldap', 'Configuration is invalid, cannot connect', OCP\Util::INFO);
 			return false;
 		}
 		if(!self::$ldapConnectionRes) {
diff --git a/apps/user_webfinger/webfinger.php b/apps/user_webfinger/webfinger.php
index da35cf29d0e7fb6b5b1113a978a9ac851842510f..307a1630019a271aaae3b4599fdeb7643bb93438 100755
--- a/apps/user_webfinger/webfinger.php
+++ b/apps/user_webfinger/webfinger.php
@@ -25,15 +25,17 @@ $SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT));
 $WEBROOT=substr($SUBURI,0,-34);
 */
 
+require_once('../../lib/base.php');
 
-$request = urldecode($_GET['q']);
+$userName = '';
+$hostName = '';
+$request = strip_tags(urldecode($_GET['q']));
 if($_GET['q']) {
 	$reqParts = explode('@', $request);
-	$userName = $reqParts[0];
-	$hostName = $reqParts[1];
-} else {
-	$userName = '';
-	$hostName = '';
+	if(count($reqParts)==2) {
+		$userName = $reqParts[0];
+		$hostName = $reqParts[1];
+	}
 }
 if(substr($userName, 0, 5) == 'acct:') {
 	$userName = substr($userName, 5);
@@ -49,12 +51,16 @@ if(isset($_SERVER['HTTPS'])) {
 	$baseAddress = 'http://';
 }
 $baseAddress .= $_SERVER['SERVER_NAME'].OC::$WEBROOT;
+if(empty($id)) {
+	header("HTTP/1.0 400 Bad Request");
+}
 define('WF_USER', $userName);
 define('WF_ID', $id);
 define('WF_BASEURL', $baseAddress);
 echo "<";
 ?>
 ?xml version="1.0" encoding="UTF-8"?>
+<?php if(empty($id)) echo '<!-- Invalid URI: ' . str_replace('>', '/>', $request) . " -->\n"; ?>
 <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/xrd/1.0">
     <hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME']; ?></hm:Host>
     <Subject>acct:<?php echo $id ?></Subject>
diff --git a/core/js/js.js b/core/js/js.js
index 7585d4b09d1064a0fd62858fc497631373e05cc5..4b0978cfb5276f30c0efe95b8765da1448d8d43a 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -33,7 +33,7 @@ OC={
 	webroot:oc_webroot,
 	appswebroot:oc_appswebroot,
 	currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
-	coreApps:['admin','log','search','settings','core','3rdparty'],
+	coreApps:['', 'admin','log','search','settings','core','3rdparty'],
 	/**
 	 * get an absolute url to a file in an appen
 	 * @param app the id of the app the file belongs to
@@ -70,11 +70,13 @@ OC={
 			link+=file;
 		}else{
 			link+='/';
-			app+='/';
 			if(!isCore){
 				link+='apps/';
 			}
-			link+=app;
+			if (app != '') {
+				app+='/';
+				link+=app;
+			}
 			if(type){
 				link+=type+'/';
 			}
@@ -160,7 +162,7 @@ OC.search.lastResults={};
 OC.addStyle.loaded=[];
 OC.addScript.loaded=[];
 
-if(typeof localStorage !='undefined'){
+if(typeof localStorage !='undefined' && localStorage != null){
 	//user and instance awere localstorage
 	OC.localStorage={
 		namespace:'oc_'+OC.currentUser+'_'+OC.webroot+'_',
diff --git a/index.php b/index.php
index 91f0cfb5e4803aee277b6fe667c9c521e3745b08..5d5307065bd7d36f2b6064c6a9973d36d36c7a93 100644
--- a/index.php
+++ b/index.php
@@ -44,7 +44,7 @@ if($not_installed) {
 
 // Handle WebDAV
 if($_SERVER['REQUEST_METHOD']=='PROPFIND'){
-	header('location: '.OC_Helper::linkToAbsolute('remote','webdav.php'));
+	header('location: '.OC_Helper::linkToRemote('webdav'));
 	exit();
 }
 
diff --git a/lib/base.php b/lib/base.php
index 40df2b0c56cb3765249dc2002b90755a6fc44051..14f2439ecbd199ab8f65d05944f9f489fd320adc 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -443,8 +443,8 @@ class OC{
 			$_GET['getfile'] = $file;
 		}
 		if(!is_null(self::$REQUESTEDFILE)){
-			$subdir = OC::$APPSROOT . '/' . self::$REQUESTEDAPP . '/' . self::$REQUESTEDFILE;
-			$parent = OC::$APPSROOT . '/' . self::$REQUESTEDAPP;
+			$subdir = OC::$APPSROOT . '/apps/' . self::$REQUESTEDAPP . '/' . self::$REQUESTEDFILE;
+			$parent = OC::$APPSROOT . '/apps/' . self::$REQUESTEDAPP;
 			if(!OC_Helper::issubdirectory($subdir, $parent)){
 				self::$REQUESTEDFILE = null;
 				header('HTTP/1.0 404 Not Found');
diff --git a/lib/filecache.php b/lib/filecache.php
index 091a7939e1a909df802100c2a1b041819f6dfa3e..8763865c8c3e850150507e494580aeaa1d51cb51 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -655,7 +655,7 @@ class OC_FileCache{
 		}else{
 			$view=new OC_FilesystemView(($root=='/')?'':$root);
 		}
-		$dh=$view->opendir($path);
+		$dh=$view->opendir($path.'/');
 		if($dh){//check for changed/new files
 			while (($filename = readdir($dh)) !== false) {
 				if($filename != '.' and $filename != '..'){
diff --git a/lib/helper.php b/lib/helper.php
index 2ddd5e7b7787dd5cbe78fb12212863a961652802..f5e247ca9ebab9cea9c35dfc85319e1ca1472813 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -41,15 +41,15 @@ class OC_Helper {
 			$app .= '/';
 			// Check if the app is in the app folder
 			if( file_exists( OC::$APPSROOT . '/apps/'. $app.$file )){
-				if(substr($file, -3) == 'php' || substr($file, -3) == 'css'){	
+				//if(substr($file, -3) == 'php' || substr($file, -3) == 'css'){	
 					if(substr($app, -1, 1) == '/'){
 						$app = substr($app, 0, strlen($app) - 1);
 					}
 					$urlLinkTo =  OC::$WEBROOT . '/?app=' . $app;
 					$urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):'';
-				}else{
-					$urlLinkTo =  OC::$APPSWEBROOT . '/apps/' . $app . $file;
-				}
+				//}else{
+				//	$urlLinkTo =  OC::$APPSWEBROOT . '/apps/' . $app . $file;
+				//}
 			}
 			else{
 				$urlLinkTo =  OC::$WEBROOT . '/' . $app . $file;
@@ -105,6 +105,17 @@ class OC_Helper {
 		return $urlLinkTo;
 	}
 
+	/**
+	 * @brief Creates an absolute url for remote use
+	 * @param $service id
+	 * @returns the url
+	 *
+	 * Returns a absolute url to the given service.
+	 */
+	public static function linkToRemote( $service ) {
+		return self::linkToAbsolute( '', 'remote.php') . '/' . $service . '/';
+	}
+
 	/**
 	 * @brief Creates path to an image
 	 * @param $app app
@@ -576,14 +587,12 @@ class OC_Helper {
 				return true;
 			}
 		}
-		/*
-		echo 'SUB: ' . $sub . "\n";
+		/*echo 'SUB: ' . $sub . "\n";
 		echo 'PAR: ' . $parent . "\n";
 		echo 'REALSUB: ' . $realpath_sub . "\n";
 		echo 'REALPAR: ' . $realpath_parent . "\n";
 		echo substr($realpath_sub, 0, strlen($realpath_parent));
-		exit;
-		*/
+		exit;*/
 		return false;
 	}
 }
diff --git a/lib/public/util.php b/lib/public/util.php
index 4068d73370ddb5df4d71b84a7add361482bca2b1..f9f3759fe5bdb79557e8c7c18ce861d05e0b30a0 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -130,6 +130,18 @@ class Util {
 	}
 
 
+	/**
+	 * @brief Creates an absolute url for remote use
+	 * @param $service id
+	 * @returns the url
+	 *
+	 * Returns a absolute url to the given app and file.
+	 */
+	public static function linkToRemote( $service ) {
+		return(\OC_Helper::linkToRemote( $service ));
+	}
+
+
         /**
          * @brief Creates an url
          * @param $app app
@@ -150,7 +162,7 @@ class Util {
 	 * reverse proxies
 	 */
 	public static function getServerHost() {
-		return(\OC_Helper::severHost());
+		return(\OC_Helper::serverHost());
 	}
 
 	/**
diff --git a/lib/user.php b/lib/user.php
index 8b887559df3d5e0ea9786196362740a7133f86f2..816caff8dd8de2f0db2cb1117ee0f7f054758476 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -117,15 +117,15 @@ class OC_User {
 		// Check the name for bad characters
 		// Allowed are: "a-z", "A-Z", "0-9" and "_.@-"
 		if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $uid )){
-			return false;
+			throw new Exception('Only the following characters are allowed in a username: "a-z", "A-Z", "0-9", and "_.@-"');
 		}
 		// No empty username
 		if(trim($uid) == ''){
-			return false;
+			throw new Exception('A valid username must be provided');
 		}
 		// Check if user already exists
 		if( self::userExists($uid) ){
-			return false;
+			throw new Exception('The username is already being used');
 		}
 
 
diff --git a/public.php b/public.php
new file mode 100644
index 0000000000000000000000000000000000000000..27a75adec9319275b84f6642c76e9522f5760acf
--- /dev/null
+++ b/public.php
@@ -0,0 +1,10 @@
+<?php
+$RUNTIME_NOSETUPFS = true;
+//$RUNTIME_NOAPPS = TRUE;
+require_once('lib/base.php');
+$file = OCP\CONFIG::getAppValue('core', 'public_' . strip_tags($_GET['service']));
+if(is_null($file)){
+	header('HTTP/1.0 404 Not Found');
+	exit;
+}
+require_once(OC::$APPSROOT . $file);
\ No newline at end of file
diff --git a/remote.php b/remote.php
new file mode 100644
index 0000000000000000000000000000000000000000..2a7ab167d048c3dbe0b1060fddabf9a3c6207906
--- /dev/null
+++ b/remote.php
@@ -0,0 +1,16 @@
+<?php
+$RUNTIME_NOSETUPFS = true;
+//$RUNTIME_NOAPPS = TRUE;
+require_once('lib/base.php');
+$path_info = $_SERVER['PATH_INFO'];
+if (!$pos = strpos($path_info, '/', 1)) {
+	$pos = strlen($path_info);
+}
+$service=substr($path_info, 1, $pos-1);
+$file = OCP\CONFIG::getAppValue('core', 'remote_' . $service);
+if(is_null($file)){
+	header('HTTP/1.0 404 Not Found');
+	exit;
+}
+$baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
+require_once(OC::$APPSROOT . $file);
\ No newline at end of file
diff --git a/remote/.gitignore b/remote/.gitignore
deleted file mode 100644
index c96a04f008ee21e260b28f7701595ed59e2839e3..0000000000000000000000000000000000000000
--- a/remote/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
\ No newline at end of file
diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php
index 1ed53efcf062f1c5bc6b3a3b420e81a22d8311b6..6714711bc876fbf5161343c6265859941a8b2d32 100644
--- a/settings/ajax/createuser.php
+++ b/settings/ajax/createuser.php
@@ -23,7 +23,8 @@ if( in_array( $username, OC_User::getUsers())){
 }
 
 // Return Success story
-if( OC_User::createUser( $username, $password )){
+try {
+	OC_User::createUser($username, $password);
 	foreach( $groups as $i ){
 		if(!OC_Group::groupExists($i)){
 			OC_Group::createGroup($i);
@@ -31,9 +32,8 @@ if( OC_User::createUser( $username, $password )){
 		OC_Group::addToGroup( $username, $i );
 	}
 	OC_JSON::success(array("data" => array( "username" => $username, "groups" => implode( ", ", OC_Group::getUserGroups( $username )))));
-}
-else{
-	OC_JSON::error(array("data" => array( "message" => "Unable to add user" )));
+} catch (Exception $exception) {
+	OC_JSON::error(array("data" => array( "message" => $exception->getMessage())));
 }
 
 ?>
diff --git a/settings/js/users.js b/settings/js/users.js
index eed93d3b30389fcd600c2b0976e1aef253733196..33872ceaf7b73eab1cf15ccdb1f448f57381e112 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -158,29 +158,16 @@ $(document).ready(function(){
 		event.preventDefault();
 		var username=$('#newusername').val();
 		if($('#content table tbody tr').filterAttr('data-uid',username).length>0){
+			OC.dialogs.alert('The username is already being used', 'Error creating user');
 			return;
 		}
 		if($.trim(username) == '') {
-			alert('Please provide a username!');
+			OC.dialogs.alert('A valid username must be provided', 'Error creating user');
 			return false;
 		}
 		var password=$('#newuserpassword').val();
 		var groups=$('#newusergroups').prev().children('div').data('settings').checked;
-		var tr
-		$.post(
-			OC.filePath('settings','ajax','createuser.php'),
-			{
-				username:username,
-				password:password,
-				groups:groups,
-			},
-			function(result){
-				if(result.status!='success'){
-					tr.remove();
-				}
-			}
-		);
-		tr=$('#content table tbody tr').first().clone();
+		var tr=$('#content table tbody tr').first().clone();
 		tr.attr('data-uid',username);
 		tr.find('td.name').text(username);
 		var select=$('<select multiple="multiple" data-placehoder="Groups" title="Groups">');
@@ -201,10 +188,24 @@ $(document).ready(function(){
 			tr.find('td.remove').append($('<img alt="Delete" title="'+t('settings','Delete')+'" class="svg action" src="'+OC.imagePath('core','actions/delete')+'"/>'));
 		}
 		applyMultiplySelect(select);
-		$('#content table tbody').last().after(tr);
+		$('#content table tbody').last().append(tr);
 		
 		tr.find('select.quota option').attr('selected',null);
 		tr.find('select.quota option').first().attr('selected','selected');
 		tr.find('select.quota').data('previous','default');
+		$.post(
+			OC.filePath('settings','ajax','createuser.php'),
+			{
+				username:username,
+				password:password,
+				groups:groups,
+			},
+			function(result){
+				if(result.status!='success'){
+					tr.remove();
+					OC.dialogs.alert(result.data.message, 'Error creating user');
+				}
+			}
+		);
 	});
 });
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index 3f1d57c73d452b600244b7f2add42105dc44015c..014996a5b2071c5fd278fabe64c7c08a90449479 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -47,7 +47,7 @@
 
 <p class="personalblock">
 	<strong>WebDAV</strong>
-	<code><?php echo OC_Helper::linkToAbsolute('remote', 'webdav.php'); ?></code><br />
+	<code><?php echo OC_Helper::linkToRemote('webdav'); ?></code><br />
 	<em><?php echo $l->t('use this address to connect to your ownCloud in your file manager');?></em>
 </p>