diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index ea3a9da6f7a9693b7595cb2a55eac81cba0c3f96..bbb753d5e69de07c2140870af192d6ef06c16951 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -1,15 +1,20 @@
 <?php
 
-require_once('apps/files_sharing/sharedstorage.php');
-
 OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php";
+OC::$CLASSPATH['OC_Filestorage_Shared'] = "apps/files_sharing/sharedstorage.php";
+
 OCP\App::registerAdmin('files_sharing', 'settings');
+
+OCP\Util::connectHook('OC_Filesystem', 'setup', 'OC_Filestorage_Shared', 'setup');
+
 OCP\Util::connectHook("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
 OCP\Util::connectHook("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
 OCP\Util::connectHook("OC_Filesystem", "post_write", "OC_Share", "updateItem");
+
 OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Share', 'removeUser');
 OCP\Util::connectHook('OC_User', 'post_addToGroup', 'OC_Share', 'addToGroupShare');
 OCP\Util::connectHook('OC_User', 'post_removeFromGroup', 'OC_Share', 'removeFromGroupShare');
+
 $dir = isset($_GET['dir']) ? $_GET['dir'] : '/';
 if ($dir != '/Shared' || OCP\Config::getAppValue('files_sharing', 'resharing', 'yes') == 'yes') {
 	OCP\Util::addscript("files_sharing", "share");
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 9174334383c6ee2f59aa4ca3e070ed5eea02d0c7..9c6df31d29707649b392658b96aa8f4c0878dc04 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -510,8 +510,9 @@ class OC_Filestorage_Shared extends OC_Filestorage {
 		}
 	}
 
-	public static function setup() {
-		OC_Filesystem::mount('OC_Filestorage_Shared', array('datadir' => '/'.OCP\USER::getUser().'/files/Shared'), '/'.OCP\USER::getUser().'/files/Shared/');
+	public static function setup($options) {
+		$user_dir = $options['user_dir'];
+		OC_Filesystem::mount('OC_Filestorage_Shared', array('datadir' => $user_dir.'/Shared'), $user_dir.'/Shared/');
 	}
 
 	/**
@@ -524,11 +525,3 @@ class OC_Filestorage_Shared extends OC_Filestorage {
 		return $this->filemtime($path)>$time;
 	}
 }
-
-if (OCP\USER::isLoggedIn()) {
-	OC_Filestorage_Shared::setup();
-} else {
-	OCP\Util::connectHook('OC_User', 'post_login', 'OC_Filestorage_Shared', 'setup');
-}
-
-?>
diff --git a/lib/base.php b/lib/base.php
index 6e209afebda8571fc9e8b8cdb114f4382e6fed6f..b6ca19568feeb61bc3b946418e4662464c719002 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -353,12 +353,6 @@ class OC{
 		OC_User::useBackend( OC_Config::getValue( "userbackend", "database" ));
 		OC_Group::useBackend(new OC_Group_Database());
 
-		// Set up file system unless forbidden
-		global $RUNTIME_NOSETUPFS;
-		if(!$RUNTIME_NOSETUPFS ){
-			OC_Util::setupFS();
-		}
-
 		// Load Apps
 		// This includes plugins for users and filesystems as well
 		global $RUNTIME_NOAPPS;
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 0d0943d3639a3d7bc77ee380c33df7539bd4f3d8..aeeb012f373c726f52d03217809be526575dd9a5 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -488,4 +488,5 @@ class OC_Filesystem{
 	}
 }
 
+OC_Util::setupFS();
 require_once('filecache.php');
diff --git a/lib/util.php b/lib/util.php
index f0999b6d201bc2c49c99b3e26275da13ebdf5cbb..46c9e0ef92736f3b27074f7a67f2500b7d355a93 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -14,7 +14,7 @@ class OC_Util {
 	public static $core_scripts=array();
 
 	// Can be set up
-	public static function setupFS( $user = "", $root = "files" ){// configure the initial filesystem based on the configuration
+	public static function setupFS( $user = '' ){// configure the initial filesystem based on the configuration
 		if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble
 			return false;
 		}
@@ -32,13 +32,14 @@ class OC_Util {
 		}
 
 		if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem
-			$userdirectory = $CONFIG_DATADIRECTORY."/$user/$root";
+			$user_dir = '/'.$user.'/files';
+			$userdirectory = $CONFIG_DATADIRECTORY.$user_dir;
 			if( !is_dir( $userdirectory )){
 				mkdir( $userdirectory, 0755, true );
 			}
 
 			//jail the user into his "home" directory
-			OC_Filesystem::init('/'.$user.'/'.$root);
+			OC_Filesystem::init($user_dir);
 			$quotaProxy=new OC_FileProxy_Quota();
 			OC_FileProxy::register($quotaProxy);
 			self::$fsSetup=true;
@@ -51,6 +52,7 @@ class OC_Util {
 					}
 				}
 			}
+			OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
 		}
 	}