diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 3c496f56e41769f9c14ccaf4f70c99520d4ddd83..92837658a5f4c6453d2688451097a45555a92eed 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -64,25 +64,8 @@ class OC_TemplateLayout extends OC_Template {
 			$root = $info[0];
 			$web = $info[1];
 			$file = $info[2];
-			$paths = explode('/', $file);
 
-			$in_root = false;
-			foreach(OC::$APPSROOTS as $app_root) {
-				if($root == $app_root['path']) {
-					$in_root = true;
-					break;
-				}
-			}
-
-			if($in_root ) {
-				$app = $paths[0];
-				unset($paths[0]);
-				$path = implode('/', $paths);
-				$this->append( 'cssfiles', OC_Helper::linkTo($app, $path) . $versionParameter);
-			}
-			else {
-				$this->append( 'cssfiles', $web.'/'.$file);
-			}
+			$this->append( 'cssfiles', $web.'/'.$file . $versionParameter);
 		}
 	}
 
@@ -123,20 +106,15 @@ class OC_TemplateLayout extends OC_Template {
 			}elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "core/$style.css" )) {
 
 			}else{
-				$append = false;
-				// or in apps?
-				foreach( OC::$APPSROOTS as $apps_dir)
-				{
-					if(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style$fext.css")) {
-						$append = true;
-						break;
-					}
-					elseif(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style.css")) {
-						$append = true;
-						break;
-					}
+				$app = substr($style, 0, strpos($style, '/'));
+				$style = substr($style, strpos($style, '/')+1);
+				$app_path = OC_App::getAppPath($app);
+				$app_url = OC::$WEBROOT . '/index.php/apps/' . $app;
+				if(self::appendIfExist($files, $app_path, $app_url, "$style$fext.css")) {
 				}
-				if(! $append) {
+				elseif(self::appendIfExist($files, $app_path, $app_url, "$style.css")) {
+				}
+				else {
 					echo('css file not found: style:'.$style.' formfactor:'.$fext
 						.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
 					die();