diff --git a/apps/files_archive/lib/storage.php b/apps/files_archive/lib/storage.php
index b8f7d4683850371f735dfac623dd7c0c15747df2..86761663611cf5c4462f12f72df28d673a4df462 100644
--- a/apps/files_archive/lib/storage.php
+++ b/apps/files_archive/lib/storage.php
@@ -18,7 +18,7 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{
 	private static $rootView;
 	
 	private function stripPath($path){//files should never start with /
-		if(substr($path,0,1)=='/'){
+		if(!$path || $path[0]=='/'){
 			$path=substr($path,1);
 		}
 		return $path;
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index 981eeab58bf3b1cad0e2e785bfcb51700f739fb9..c431070e24b37632c1fa7b1e304823d9d62a21a1 100644
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -21,7 +21,7 @@ class OC_FileStorage_FTP extends OC_Filestorage_Common{
 		$this->password=$params['password'];
 		$this->secure=isset($params['secure'])?(bool)$params['secure']:false;
 		$this->root=isset($params['root'])?$params['root']:'/';
-		if(substr($this->root,0,1)!='/'){
+		if(!$this->root || $this->root[0]!='/'){
 			$this->root='/'.$this->root;
 		}
 		
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index e3ba9c240cf7e511ef2b6221f326e9e6ff366a0e..58b95a6ae010cdec9373c76d0c35811546746ec6 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -269,7 +269,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
 		$this->user=$params['user'];
 		$this->root=isset($params['root'])?$params['root']:'/';
 		$this->secure=isset($params['secure'])?(bool)$params['secure']:true;
-		if(substr($this->root,0,1)!='/'){
+		if(!$this->root || $this->root[0]!='/'){
 			$this->root='/'.$this->root;
 		}
 		$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 07c90d4878e94b208b3abd1f4c610ba25195f19a..d136f04f3eb5e7f90ea5bd7c2ffbbc761b0ee256 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -25,7 +25,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
 		$this->password=$params['password'];
 		$this->secure=isset($params['secure'])?(bool)$params['secure']:false;
 		$this->root=isset($params['root'])?$params['root']:'/';
-		if(substr($this->root,0,1)!='/'){
+		if(!$this->root || $this->root[0]!='/'){
 			$this->root='/'.$this->root;
 		}
 		if(substr($this->root,-1,1)!='/'){
@@ -273,7 +273,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
 	}
 
 	private function cleanPath($path){
-		if(substr($path,0,1)=='/'){
+		if(!$path || $path[0]=='/'){
 			return substr($path,1);
 		}else{
 			return $path;
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php
index 4adb70cfa0ae0ed3a16ae628b1e0a4d0dabd51dd..d7d6e09c9b088df1b2aa9687cc60fe27075dd5d6 100644
--- a/apps/user_ldap/lib_ldap.php
+++ b/apps/user_ldap/lib_ldap.php
@@ -606,7 +606,7 @@ class OC_LDAP {
 	static private function combineFilter($filters, $operator) {
 		$combinedFilter = '('.$operator;
 		foreach($filters as $filter) {
-		    if(substr($filter,0,1) != '(') {
+		    if($filter[0] != '(') {
 				$filter = '('.$filter.')';
 		    }
 		    $combinedFilter.=$filter;
@@ -722,4 +722,4 @@ class OC_LDAP {
 		return false;
 	}
 
- }
\ No newline at end of file
+ }
diff --git a/lib/app.php b/lib/app.php
index e4ec0fe588da5f54d478686cc291797c1358254f..1d046b3bb5b9697a44182286667c9b8d2d786488 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -494,7 +494,7 @@ class OC_App{
 		$apps=array();
 		$dh=opendir(OC::$APPSROOT.'/apps');
 		while($file=readdir($dh)){
-			if(substr($file,0,1)!='.' and is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){
+			if($file[0]!='.' and is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){
 				$apps[]=$file;
 			}
 		}
diff --git a/lib/archive/tar.php b/lib/archive/tar.php
index 4ff787798340ac0a2e547c38ca3a62e8c1bf987d..944a0ac4ba4e13d5ba738e9daff66027763e1551 100644
--- a/lib/archive/tar.php
+++ b/lib/archive/tar.php
@@ -150,7 +150,7 @@ class OC_Archive_TAR extends OC_Archive{
 		$folderContent=array();
 		$pathLength=strlen($path);
 		foreach($files as $file){
-			if(substr($file,0,1)=='/'){
+			if($file[0]=='/'){
 				$file=substr($file,1);
 			}
 			if(substr($file,0,$pathLength)==$path and $file!=$path){
@@ -241,7 +241,7 @@ class OC_Archive_TAR extends OC_Archive{
 				}
 			}
 		}
-		if(substr($path,0,1)!='/'){//not all programs agree on the use of a leading /
+		if($path[0]!='/'){//not all programs agree on the use of a leading /
 			return $this->fileExists('/'.$path);
 		}else{
 			return false;
diff --git a/lib/archive/zip.php b/lib/archive/zip.php
index 22ab48937ebadaa9fb87e13e1a516d0c019aa4bb..6631a649b169380bebfea156f94a539135d7924d 100644
--- a/lib/archive/zip.php
+++ b/lib/archive/zip.php
@@ -191,7 +191,7 @@ class OC_Archive_ZIP extends OC_Archive{
 	}
 
 	private function stripPath($path){
-		if(substr($path,0,1)=='/'){
+		if(!$path || $path[0]=='/'){
 			return substr($path,1);
 		}else{
 			return $path;
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 198f00873c5e67ec2cd2408fc328a8f54c1b11ef..813590b00bb3e41ce3b586c55b1f7df893e1d1c0 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -150,7 +150,7 @@ class OC_Filesystem{
 		if(!$path){
 			$path='/';
 		}
-		if(substr($path,0,1)!=='/'){
+		if($path[0]!=='/'){
 			$path='/'.$path;
 		}
 		$foundMountPoint='';
@@ -311,12 +311,12 @@ class OC_Filesystem{
 	* @param string mountpoint
 	*/
 	static public function mount($class,$arguments,$mountpoint){
+		if($mountpoint[0]!='/'){
+			$mountpoint='/'.$mountpoint;
+		}
 		if(substr($mountpoint,-1)!=='/'){
 			$mountpoint=$mountpoint.'/';
 		}
-		if(substr($mountpoint,0,1)!=='/'){
-			$mountpoint='/'.$mountpoint;
-		}
 		self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments);
 	}
 
@@ -361,7 +361,7 @@ class OC_Filesystem{
 	 * @return bool
 	 */
 	static public function isValidPath($path){
-		if(substr($path,0,1)!=='/'){
+		if(!$path || $path[0]!=='/'){
 			$path='/'.$path;
 		}
 		if(strstr($path,'/../') || strrchr($path, '/') === '/..' ){
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index 93fce38af41d66269fcd5d8df1c7c5946cdf1fa3..d15f91be1ec16e7600326fdd736007e3ac68b326 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -34,7 +34,7 @@ class OC_FilesystemView {
 		if(!$path){
 			$path='/';
 		}
-		if(substr($path,0,1)!=='/'){
+		if($path[0]!=='/'){
 			$path='/'.$path;
 		}
 		return $this->fakeRoot.$path;
diff --git a/lib/installer.php b/lib/installer.php
index 6417ed1c7a8cd46325a3e0862da8a97620f98923..4069f2ab7c641ec3c21df2b48189cc8866e9d86a 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -110,7 +110,7 @@ class OC_Installer{
 			//try to find it in a subdir
 			$dh=opendir($extractDir);
 			while($folder=readdir($dh)){
-				if(substr($folder,0,1)!='.' and is_dir($extractDir.'/'.$folder)){
+				if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)){
 					if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')){
 						$extractDir.='/'.$folder;
 					}
diff --git a/lib/user/database.php b/lib/user/database.php
index a9b01957d428274d6c75ecef8f3cded57932940e..a69fe49a0b9d914cfc891611d3f580562163c211 100644
--- a/lib/user/database.php
+++ b/lib/user/database.php
@@ -129,7 +129,7 @@ class OC_User_Database extends OC_User_Backend {
 		$row=$result->fetchRow();
 		if($row){
 			$storedHash=$row['password'];
-			if (substr($storedHash,0,1)=='$'){//the new phpass based hashing
+			if ($storedHash[0]=='$'){//the new phpass based hashing
 				$hasher=$this->getHasher();
 				if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)){
 					return $row['uid'];
diff --git a/tests/index.php b/tests/index.php
index 6dec1b050fb35518dc2577bb685f9819ef54c6c1..ad98048a6836226a7a7ed04bc34f3dc6356cb9f0 100644
--- a/tests/index.php
+++ b/tests/index.php
@@ -41,7 +41,7 @@ function loadTests($dir=''){
 	$test=isset($_GET['test'])?$_GET['test']:false;
 	if($dh=opendir($dir)){
 		while($name=readdir($dh)){
-			if(substr($name,0,1)!='.'){//no hidden files, '.' or '..'
+			if($name[0]!='.'){//no hidden files, '.' or '..'
 				$file=$dir.'/'.$name;
 				if(is_dir($file)){
 					loadTests($file);