diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 8b989db3b079e38267f7f1927ace71270fc8487a..d35a5148de23bae31690d8656d38ab3b52293bc2 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -136,6 +136,19 @@ class Shared_Cache extends Cache {
 		return -1;
 	}
 
+	/**
+	 * check if a file is available in the cache
+	 *
+	 * @param string $file
+	 * @return bool
+	 */
+	public function inCache($file) {
+		if ($file == '') {
+			return true;
+		}
+		return parent::inCache($file);
+	}
+
 	/**
 	 * remove a file or folder from the cache
 	 *
diff --git a/apps/files_sharing/lib/permissions.php b/apps/files_sharing/lib/permissions.php
index 508c3a384f0c5a5b0fa2b1cd2adc80ab1729af22..2b068ff93502f45ed68151b472ce9f7ca4826257 100644
--- a/apps/files_sharing/lib/permissions.php
+++ b/apps/files_sharing/lib/permissions.php
@@ -33,7 +33,7 @@ class Shared_Permissions extends Permissions {
 		if ($fileId == -1) {
 			return \OCP\PERMISSION_READ;
 		}
-		$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
+		$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE, null, true);
 		if ($source) {
 			return $source['permissions'];
 		} else {
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 5e98c455d35d5be22ae798915c92d68ed1ae4333..6d3c55a008f0bdaf85fc14674f6a3f55f7d01f51 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -117,6 +117,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
 	}
 
 	public static function getSource($target) {
+		if ($target == '') {
+			return false;
+		}
 		$target = '/'.$target;
 		$target = rtrim($target, '/');
 		$pos = strpos($target, '/', 1);
diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/share/folder.php
index bbe4c130bddd79a3c484b0a204bbef119eb9a6d5..11c8c6b1e8066bd7d84dfbee563a5982607d3486 100644
--- a/apps/files_sharing/lib/share/folder.php
+++ b/apps/files_sharing/lib/share/folder.php
@@ -24,6 +24,13 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share
 	public function getChildren($itemSource) {
 		$children = array();
 		$parents = array($itemSource);
+		$query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
+		$result = $query->execute(array('httpd/unix-directory'));
+		if ($row = $result->fetchRow()) {
+			$mimetype = $row['id'];
+		} else {
+			$mimetype = -1;
+		}
 		while (!empty($parents)) {
 			$parents = "'".implode("','", $parents)."'";
 			$query = OC_DB::prepare('SELECT `fileid`, `name`, `mimetype` FROM `*PREFIX*filecache` WHERE `parent` IN ('.$parents.')');
@@ -32,8 +39,8 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share
 			while ($file = $result->fetchRow()) {
 				$children[] = array('source' => $file['fileid'], 'file_path' => $file['name']);
 				// If a child folder is found look inside it
-				if ($file['mimetype'] == 'httpd/unix-directory') {
-					$parents[] = $file['id'];
+				if ($file['mimetype'] == $mimetype) {
+					$parents[] = $file['fileid'];
 				}
 			}
 		}
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 24096e0c10c97c357089e0510b7734305f34b1aa..c8756af8ed72a9032e31b3b4f535f500069525e1 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -408,12 +408,6 @@ class Shared extends \OC\Files\Storage\Common {
 	}
 
 	public function getScanner($path = '') {
-		if ($path != '' && ($source = $this->getSourcePath($path))) {
-			list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
-			if ($storage) {
-				return $storage->getScanner($internalPath);
-			}
-		}
 		return new \OC\Files\Cache\Scanner($this);
 	}
 
diff --git a/lib/public/share.php b/lib/public/share.php
index c74960b94c536e21abaaa5e23fd6bd0488f0c26b..7722e0b86cc0d1703b6cf62da0a0f688fa9b1b19 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -756,7 +756,7 @@ class Share {
 			$collectionItems = array();
 			foreach ($items as &$row) {
 				// Return only the item instead of a 2-dimensional array
-				if ($limit == 1 && $row['item_type'] == $itemType && $row[$column] == $item) {
+				if ($limit == 1 && $row[$column] == $item && ($row['item_type'] == $itemType || $itemType == 'file')) {
 					if ($format == self::FORMAT_NONE) {
 						return $row;
 					} else {
@@ -823,6 +823,9 @@ class Share {
 			if (!empty($collectionItems)) {
 				$items = array_merge($items, $collectionItems);
 			}
+			if (empty($items) && $limit == 1) {
+				return false;
+			}
 			if ($format == self::FORMAT_NONE) {
 				return $items;
 			} else if ($format == self::FORMAT_STATUSES) {