diff --git a/lib/files/mapper.php b/lib/files/mapper.php
index 71b665e49bb8f715d0fe3d03b8ab9d24777b240d..2d29a8532b6833995539119793dff1198b392c79 100644
--- a/lib/files/mapper.php
+++ b/lib/files/mapper.php
@@ -117,6 +117,9 @@ class Mapper
 		$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*file_map` WHERE `logic_path_hash` = ?');
 		$result = $query->execute(array(md5($logicPath)));
 		$result = $result->fetchRow();
+		if ($result === false) {
+			return null;
+		}
 
 		return $result['physic_path'];
 	}
@@ -160,11 +163,16 @@ class Mapper
 		$sluggedElements = array();
 
 		// skip slugging the drive letter on windows - TODO: test if local path
-		if (strpos(strtolower(php_uname('s')), 'win') !== false) {
+		if (\OC_Util::runningOnWindows()) {
 			$sluggedElements[]= $pathElements[0];
 			array_shift($pathElements);
 		}
 		foreach ($pathElements as $pathElement) {
+			// remove empty elements
+			if (empty($pathElement)) {
+				continue;
+			}
+
 			// TODO: remove file ext before slugify on last element
 			$sluggedElements[] = self::slugify($pathElement);
 		}
@@ -177,6 +185,12 @@ class Mapper
 			array_pop($sluggedElements);
 			array_push($sluggedElements, $last.'-'.$index);
 		}
+
+		// on non-windows systems add the leading / if necessary
+		if (!\OC_Util::runningOnWindows() and $path[0] === '/') {
+			return DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $sluggedElements);
+		}
+
 		return implode(DIRECTORY_SEPARATOR, $sluggedElements);
 	}
 
diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php
index 411b053737a499abc50e45183a9e68fbf06268e3..218465d8eef4e44a78506bc9179c29a10b302b19 100644
--- a/lib/files/storage/mappedlocal.php
+++ b/lib/files/storage/mappedlocal.php
@@ -329,6 +329,9 @@ class MappedLocal extends \OC\Files\Storage\Common{
 		if(strpos($path, '/') === 0) {
 			$path = substr($path, 1);
 		}
+		if ($path === false) {
+			return '';
+		}
 
 		return $path;
 	}