diff --git a/lib/base.php b/lib/base.php
index 94ae26c4d1ba347628aacde021054fc06b6a9221..db55504117d4b1df4752e07107e5fa647c05ed63 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -95,31 +95,6 @@ class OC{
 		}
 	}
 
-	/**
-	 * autodetects the formfactor of the used device
-	 * default -> the normal desktop browser interface
-	 * mobile -> interface for smartphones
-	 * tablet -> interface for tablets
-	 * standalone -> the default interface but without header, footer and sidebar. just the application. useful to ue just a specific app on the desktop in a standalone window.
-	 */
-	public static function detectFormfactor(){
-		// please add more useragent strings for other devices
-		if(isset($_SERVER['HTTP_USER_AGENT'])){
-			if(stripos($_SERVER['HTTP_USER_AGENT'],'ipad')>0) {
-				$mode='tablet';
-			}elseif(stripos($_SERVER['HTTP_USER_AGENT'],'iphone')>0){
-				$mode='mobile';
-			}elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'],'nokia')>0)){
-				$mode='mobile';
-			}else{
-				$mode='default';
-			}
-		}else{
-			$mode='default';
-		}
-		return($mode);
-	}
-
 	public static function initPaths(){
 		// calculate the root directories
 		OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
@@ -237,15 +212,6 @@ class OC{
 	}
 
 	public static function initTemplateEngine() {
-		// if the formfactor is not yet autodetected do the autodetection now. For possible forfactors check the detectFormfactor documentation
-		if(!isset($_SESSION['formfactor'])){
-			$_SESSION['formfactor']=OC::detectFormfactor();
-		}
-		// allow manual override via GET parameter
-		if(isset($_GET['formfactor'])){
-			$_SESSION['formfactor']=$_GET['formfactor'];
-		}
-
 		// Add the stuff we need always
 		OC_Util::addScript( "jquery-1.7.2.min" );
 		OC_Util::addScript( "jquery-ui-1.8.16.custom.min" );
diff --git a/lib/template.php b/lib/template.php
index a3700e133e79786ecab01400d1ed432488b90350..7e2e1d4d5268457b49fb0eef2d9a9ba56b6a1ed3 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -166,11 +166,48 @@ class OC_Template{
 		$this->findTemplate($name);
 	}
 
+	/**
+	 * autodetects the formfactor of the used device
+	 * default -> the normal desktop browser interface
+	 * mobile -> interface for smartphones
+	 * tablet -> interface for tablets
+	 * standalone -> the default interface but without header, footer and
+	 * 	sidebar, just the application. Useful to use just a specific
+	 * 	app on the desktop in a standalone window.
+	 */
+	public static function detectFormfactor(){
+		// please add more useragent strings for other devices
+		if(isset($_SERVER['HTTP_USER_AGENT'])){
+			if(stripos($_SERVER['HTTP_USER_AGENT'],'ipad')>0) {
+				$mode='tablet';
+			}elseif(stripos($_SERVER['HTTP_USER_AGENT'],'iphone')>0){
+				$mode='mobile';
+			}elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'],'nokia')>0)){
+				$mode='mobile';
+			}else{
+				$mode='default';
+			}
+		}else{
+			$mode='default';
+		}
+		return($mode);
+	}
+
 	/**
 	 * @brief Returns the formfactor extension for current formfactor
 	 */
 	static public function getFormFactorExtension()
 	{
+		// if the formfactor is not yet autodetected do the
+		// autodetection now. For possible formfactors check the
+		// detectFormfactor documentation
+		if(!isset($_SESSION['formfactor'])){
+			$_SESSION['formfactor'] = self::detectFormfactor();
+		}
+		// allow manual override via GET parameter
+		if(isset($_GET['formfactor'])){
+			$_SESSION['formfactor']=$_GET['formfactor'];
+		}
 		$formfactor=$_SESSION['formfactor'];
 		if($formfactor=='default') { 
 			$fext='';