diff --git a/mobile_tools.module b/mobile_tools.module
index 3711684..2851fd5 100755
--- a/mobile_tools.module
+++ b/mobile_tools.module
@@ -242,9 +242,15 @@ function mobile_tools_get_device(){
         break;
       default:
         $device_groups = mobile_tools_device_groups();
-        if(isset($device_groups[$_GET['device']])){
+        $device_types = mobile_tools_device_types();
+        $type = 'mobile';
+        $group = $_GET['device'];
+        if (strpos($group, '/') !== FALSE) {
+          list($type, $group) = explode('/', $group, 2);
+        }
+        if(isset($device_groups[$group]) && isset($device_types[$type])) {
           setCookie('mt_device', $_GET['device'], variable_get('mobile_tools_cookie_lifetime', $session_time) , '/');
-          return array('type' => 'mobile', 'group' => $_GET['device']);
+          return array('type' => $type, 'group' => $group);
         }
      }
   } elseif(isset($_COOKIE['mt_device'])){
@@ -258,9 +264,15 @@ function mobile_tools_get_device(){
         break;
       default:
         $device_groups = mobile_tools_device_groups();
-        if(isset($device_groups[$_COOKIE['mt_device']])){
+        $device_types = mobile_tools_device_types();
+        $type = 'mobile';
+        $group = $_COOKIE['mt_device'];
+        if (strpos($group, '/') !== FALSE) {
+          list($type, $group) = explode('/', $group, 2);
+        }
+        if(isset($device_groups[$group]) && isset($device_types[$type])) {
           setCookie('mt_device', $_COOKIE['mt_device'], variable_get('mobile_tools_cookie_lifetime', $session_time) , '/');
-          return array('type' => 'mobile', 'group' => $_COOKIE['mt_device']);
+          return array('type' => $type, 'group' => $group);
         }
     }
   }
@@ -464,6 +476,31 @@ return array('iphone'=>'iPhone', 'ipod'=>'iPod', 'ipad'=>'iPad', 'android'=>'And
 } 
 
 /**
+ *  Mobile Tools implementation of the hook_device_types()
+ *  This function returns the different device types where this module can make a distinction for. This can be used
+ *  to select different themes for different device types.   
+ */
+function _mobile_tools_device_types() {
+return array('desktop' => 'Desktop', 'mobile' => 'Mobile');
+} 
+
+/**
+ * Calling the device types, check first if third party module registered
+ * for doing the device detection 
+ * @return $types
+ *  Array containing the device type detected by this module
+ */
+function mobile_tools_device_types() {
+  $device_detection = variable_get('mobile-tools-device-detection', 'mobile_tools');
+  if ($device_detection != 'mobile_tools') {
+    return module_invoke($device_detection, 'device_types');
+  } 
+  else {
+    return _mobile_tools_device_types();
+  }
+}  
+
+/**
  * Implementation of hook_devicecapability()
  * This default implementation invokes the responsible module
  */
@@ -476,6 +513,9 @@ function mobile_tools_devicecapability($capability) {
  *  e.g. domain.com becomes www.domain.com . this is because sometimes both www.domain.com and domain.com are the same 
  */ 
 function mobile_tools_prepare_url($url) {
+  if (!is_string($url) || $url == '') {
+    return '';
+  }
   $_url = parse_url($url);
   $_url = $url['host'];
   $_url = explode(".", $_url);
