diff --git a/mobile_tools.module b/mobile_tools.module
index 348fe82..51ad43c 100755
--- a/mobile_tools.module
+++ b/mobile_tools.module
@@ -1,30 +1,21 @@
 <?php
+
 /**
  * @file
- * Mobile Tools provides a range of functionality assisting in creating a mobile Drupal site . this functionality contains:
- * - User Agent detection ('mobile' or 'desktop')
- * - automatic redirection towards mobile site or user notification by means of a block message or drupal_set_message
- * - Adding a mobile context to the permission system
- * - Adding a mobile context to theming (= theme switching or separate configuration for desktop and )
- * - ...
- *
- * For more documentation and examples please go to http://drupal.org/node/459686
+ * Primarily Drupal hooks.
  */
 
-/* The default messages being displayed to the users . these can be overwritten in
-* the configuration panel
-*/
+// Define default notifications to send to the user
 define('MOBILE_NOTIFICATION', '<a href="!desktop_url">View full site</a>');
 define('DESKTOP_NOTIFICATION', '<a href="!mobile_url">View mobile site</a>');
 
-
 /**
-* Implementation of hook_help($section).
-*/
+ * Implementation of hook_help().
+ */
 function mobile_tools_help($path, $arg) {
   switch ($path) {
     case 'admin/help#mobile_tools':
-      return '<p>'. t('Visit the !documentation for more info', array('!documentation' => l('documentation page', 'http://drupal.org/node/459686'))) .'<p>';
+      return '<p>'. t('Visit the <a href="@documentation">documentation page</a> for more information.', array('@documentation' => 'http://drupal.org/node/459686')) .'<p>';
   }
 }
 
@@ -41,7 +32,7 @@ function mobile_tools_perm() {
 function mobile_tools_menu() {
   $items['admin/settings/mobile-tools'] = array(
     'title' => 'Mobile Tools',
-    'description' => t('Configure the detection of the mobile client and the appropriate actions.'),
+    'description' => 'Configure the detection of the mobile client and the appropriate actions.',
     'access arguments' => array('configure Mobile Tools'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('mobile_tools_configuration_form'),
@@ -74,32 +65,33 @@ function mobile_tools_menu() {
     'weight' => 10,
     'file' => 'mobile_tools.admin.inc',
   );
-
   $items['mt/desktop/%mobile_tools_menu_link'] = array(
    'title' => 'Full site',
    'page callback' => 'mobile_tools_menu_switch_site',
    'access callback' => 'mobile_tools_menu_link_access',
    'access arguments' => array('desktop'),
   );
-
   $items['mt/mobile/%mobile_tools_menu_link'] = array(
-   'title' => "Mobile Site",
+   'title' => 'Mobile Site',
    'page callback' => 'mobile_tools_menu_switch_site',
    'access callback' => 'mobile_tools_menu_link_access',
    'access arguments' => array('mobile'),
   );
   return $items;
 }
+
 /**
- *  Access function for the mobile tools menu links. It decides on which link to shown.
+ * Access function for the mobile tools menu links. It decides on which link to shown.
  */
-function mobile_tools_menu_link_access($target_site){
-  if(preg_match('/admin\/build\/menu/', $_GET['q'])){
+function mobile_tools_menu_link_access($target_site) {
+  if (preg_match('/admin\/build\/menu/', $_GET['q'])) {
     return TRUE;
   }
+
   $current_site = mobile_tools_site_type();
+
   // Only show the link if it's target is different then the current site
-  if($target_site == $current_site){
+  if ($target_site == $current_site) {
     return FALSE;
   }
   else {
@@ -108,24 +100,24 @@ function mobile_tools_menu_link_access($target_site){
 }
 
 /**
- * Implements the menu link argument
+ * Implements the menu link argument.
  */
-function mobile_tools_menu_link_to_arg($arg){
+function mobile_tools_menu_link_to_arg($arg) {
   return $_GET['q'];
 }
 
 /**
- * Redirect the user to the right path
+ * Redirect the user to the right path.
  */
-function mobile_tools_menu_switch_site(){
-
+function mobile_tools_menu_switch_site() {
   $args = arg();
   array_shift($args);
   $site = array_shift($args);
-  $path  = implode('/', $args);
+  $path = implode('/', $args);
+
   // In case of redirect, we already redirect to the target url
-  if(variable_get('mobile_tools_redirect', FALSE)){
-    if($site == "desktop"){
+  if (variable_get('mobile_tools_redirect', FALSE)) {
+    if ($site == 'desktop') {
       $url = variable_get('mobile_tools_desktop_url', '') . '/' . $path;
     }
     else {
@@ -134,8 +126,10 @@ function mobile_tools_menu_switch_site(){
   }
   else {
     $url = $path;
-  } 
+  }
+
   $querystring = drupal_query_string_encode(array_merge($_GET, array('device' => $site)), array('q'));
+
   drupal_goto($url, $querystring);
 }
 
@@ -146,59 +140,57 @@ function mobile_tools_menu_switch_site(){
  * @param $path
  *   Current path
  */
-function mobile_tools_switch_menu_link($site, $path){
-  return 'mt/' . $site . '/' . $path; 
+function mobile_tools_switch_menu_link($site, $path) {
+  return 'mt/' . $site . '/' . $path;
 }
 
 /**
- * Implementation of hook_theme()
+ * Implementation of hook_theme().
  */
-function mobile_tools_theme(){
+function mobile_tools_theme($existing, $type, $theme, $path) {
   $templates['mobile_tools_header'] = array(
     'template' => 'mobile-tools-header',
     'arguments' => array(),
-    'path' => drupal_get_path('module', 'mobile_tools') . '/theme',
+    'path' => $path . '/theme',
   );
   return $templates;
 }
 
 /**
- * Implementation of hook_block()
- * Provides the blocks that can be used to show a message to the user to go to the
- * mobile or desktop version.
+ * Implementation of hook_block().
  */
-function mobile_tools_block($op = 'list',  $delta = 0, $edit = array()) {
-   switch ($op) {
+function mobile_tools_block($op = 'list', $delta = 0, $edit = array()) {
+  switch ($op) {
     case 'list':
-        $blocks[0]['info'] = t('Mobile Tools message block');
-        $blocks[0]['cache'] = BLOCK_NO_CACHE;
-        return $blocks;
+      $blocks[0] = array(
+        'info' => t('Mobile Tools message block'),
+        'cache' => BLOCK_NO_CACHE,
+      );
+      return $blocks;
       break;
     case 'view':
-        $block['content'] = mobile_tools_block_message();
+      $block['content'] = mobile_tools_block_message();
         return $block;
       break;
-   }
+  }
 }
 
 /**
- *  Helper function returning the configurable message for the notification
+ * Helper function returning the configurable message for the notification
  */
 function mobile_tools_block_message() {
   $site = mobile_tools_site_type();
   $querystring = drupal_query_string_encode($_GET, array('q', 'device'));
-  if(!empty($querystring)){
+  if (!empty($querystring)) {
     $querystring = '?' . $querystring;
   }
-  if ($site  == 'mobile' ) {
-    // Fix for security issue https://security.drupal.org/node/70779
+  if ($site == 'mobile') {
     $output = filter_xss(variable_get('mobile_notification', MOBILE_NOTIFICATION));
     $desktop_url = filter_xss(mobile_tools_switch_menu_link('desktop', $_GET['q']));
     $output = t($output, array('!desktop_url' => '/' . $desktop_url . $querystring));
     return $output;
   }
-  elseif($site == 'desktop') {
-    // Fix for security issue https://security.drupal.org/node/70779
+  elseif ($site == 'desktop') {
     $output = filter_xss(variable_get('desktop_notification', DESKTOP_NOTIFICATION));
     $mobile_url = filter_xss(mobile_tools_switch_menu_link('mobile', $_GET['q']));
     $output = t($output, array('!mobile_url' => '/' . $mobile_url . $querystring));
@@ -207,8 +199,7 @@ function mobile_tools_block_message() {
 }
 
 /**
- *  Implementation of hook_boot().
- *  Redirecting if needed
+ * Implementation of hook_boot().
  */
 function mobile_tools_boot() {
   global $mobile_tools_device, $conf;
@@ -219,7 +210,7 @@ function mobile_tools_boot() {
   // Get the device object
   $mobile_tools_device =  mobile_tools_get_device();
   // First call the redirect function. This will redirect the userif needed.
-  if(variable_get('mobile_tools_redirect', FALSE)){
+  if (variable_get('mobile_tools_redirect', FALSE)) {
     $redirected = mobile_tools_device_redirect($mobile_tools_device);
   }
   if (mobile_tools_site_type() == 'mobile') {
@@ -230,11 +221,11 @@ function mobile_tools_boot() {
 }
 
 /**
- * Theme switching:
- * - Only for non cached pages!
+ * Implementation of hook_init().
  */
-function mobile_tools_init(){
+function mobile_tools_init() {
   global $mobile_tools_device, $conf;
+
   // Skip everything in case Drush is used
   if (php_sapi_name() == 'cli') {
     return;
@@ -245,17 +236,15 @@ function mobile_tools_init(){
     $conf['default_nodes_main'] = variable_get('default_nodes_main_mobile', variable_get('default_nodes_main', 10));
   }
 
-  /**
-   * We set the context
-   */
-   if (module_exists('context')) {
-      $plugin = context_get_plugin('condition', 'mobile');
-      if (!empty($plugin) && is_object($plugin)) {
-        $device = mobile_tools_get_device();
-        $plugin->execute($device['type']);
-        $plugin->execute($device['group']);
-      }
-   }
+  // Set the content
+  if (module_exists('context')) {
+    $plugin = context_get_plugin('condition', 'mobile');
+    if (!empty($plugin) && is_object($plugin)) {
+      $device = mobile_tools_get_device();
+      $plugin->execute($device['type']);
+      $plugin->execute($device['group']);
+    }
+  }
 }
 
 /**
@@ -269,22 +258,27 @@ function mobile_tools_device_redirect($device) {
   //only consider redirection if the mobile url and the destkop url are different
   $mobile_url = variable_get('mobile_tools_mobile_url', '');
   $desktop_url = variable_get('mobile_tools_desktop_url', '');
-  if($mobile_url == $desktop_url){
+
+  if ($mobile_url == $desktop_url) {
     return;
   }
+
   // see if the user is currently requestin the mobile or desktop url
   $current_url_type = mobile_tools_site_type();
 
   // code takes into account path exceptions in the configuration.
   $pages = variable_get('mobile_tools_redirect_exceptions', '');
+
   $page_match = FALSE;
-  if(isset($_GET['q']) && $pages != '') {
+
+  if (isset($_GET['q']) && $pages != '') {
     //check if there is no exception in the redirect path (code comes from block.module)
     include_once './includes/bootstrap.inc';
     drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
     $path = drupal_get_path_alias($_GET['q']);
     // Compare with the internal and path alias (if any).
     $page_match = drupal_match_path($path, $pages);
+
     if ($path != $_GET['q']) {
       $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
     }
@@ -293,6 +287,7 @@ function mobile_tools_device_redirect($device) {
   if (variable_get('mobile_tools_redirect_exceptions_type', 0) == 'only-redirect') {
     $page_match = !$page_match;
   }
+
   // Redirections
   if (!$page_match) {
     // The case where a mobile user is accessing the desktop site
@@ -302,8 +297,8 @@ function mobile_tools_device_redirect($device) {
     // The case where a desktop user is accessing the mobile site
     }
     elseif ($device['type'] == 'desktop' && $current_url_type == 'mobile') {
-       $destination_url = mobile_tools_get_redirect_url('desktop');
-       mobile_tools_goto($destination_url);
+      $destination_url = mobile_tools_get_redirect_url('desktop');
+      mobile_tools_goto($destination_url);
     }
   }
 }
@@ -316,7 +311,7 @@ function mobile_tools_switch_theme($device) {
   global $custom_theme, $conf;
   // check if theme switching is forced
   $current_url_type = mobile_tools_site_type();
-  if (($current_url_type == 'mobile' &&  variable_get('mobile-tools-theme-switch', ''  ) == 'mobile-tools-mobile-url') || (variable_get('mobile-tools-theme-switch', ''  ) == 'mobile-tools-mobile-device' && $device['type']  == 'mobile') ) {
+  if (($current_url_type == 'mobile' &&  variable_get('mobile-tools-theme-switch', '') == 'mobile-tools-mobile-url') || (variable_get('mobile-tools-theme-switch', '') == 'mobile-tools-mobile-device' && $device['type']  == 'mobile')) {
     $group = $device['group'];
     $mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
     if (variable_get($mobile_detection_module . '_' . $group . '_enable', '') == 1) {
@@ -328,7 +323,7 @@ function mobile_tools_switch_theme($device) {
       return TRUE;
     }
   }
-  elseif (!empty($device['group'])){ //device groups are independent of device types
+  elseif (!empty($device['group'])) { //device groups are independent of device types
     // Allow custom themes for 'desktop' device types
     $group = $device['group'];
     $mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
@@ -350,46 +345,62 @@ function mobile_tools_switch_theme($device) {
  * @return $device
  *  The $device object
  */
-function mobile_tools_get_device(){
+function mobile_tools_get_device() {
   global $cookie_domain, $mobile_tools_device;
-  // currently the boot method saves the result in a global variable.
-  if(isset($mobile_tools_device)){
+
+  // Currently the boot method saves the result in a global variable.
+  if (isset($mobile_tools_device)) {
     return $mobile_tools_device;
   }
+
   // Checking the possible arguments
   $session_time = time() + variable_get('mobile_tools_cookie_session', 3600 * 24 * 30);
+
   //first check if the device type is forced in the device argument
-  if (isset($_GET['device'])){
+  if (isset($_GET['device'])) {
     switch ($_GET['device']) {
       case 'desktop':
       case 'mobile':
         setCookie('mt_device', $_GET['device'], variable_get('mobile_tools_cookie_lifetime', $session_time) , '/', $cookie_domain);
-        return array('type' => $_GET['device'], 'group' => '');
+        return array(
+          'type' => $_GET['device'],
+          'group' => '',
+        );
         break;
       case 'auto':
         setCookie('mt_device', '', time() - 3600, '/', $cookie_domain);
         break;
       default:
         $device_groups = mobile_tools_device_groups();
-        if(isset($device_groups[$_GET['device']])){
+        if (isset($device_groups[$_GET['device']])) {
           setCookie('mt_device', $_GET['device'], variable_get('mobile_tools_cookie_lifetime', $session_time) , '/', $cookie_domain);
-          return array('type' => 'mobile', 'group' => $_GET['device']);
+          return array(
+            'type' => 'mobile',
+            'group' => $_GET['device'],
+          );
         }
-     }
-  } elseif(isset($_COOKIE['mt_device'])){
+    }
+  }
+  elseif (isset($_COOKIE['mt_device'])) {
     switch ($_COOKIE['mt_device']) {
       case 'desktop':
       case 'mobile':
-        return array('type' => $_COOKIE['mt_device'], 'group' => '');
+        return array(
+          'type' => $_COOKIE['mt_device'],
+          'group' => '',
+        );
         break;
       case 'auto':
         setCookie('mt_device', '', time() - 3600, '/');
         break;
       default:
         $device_groups = mobile_tools_device_groups();
-        if(isset($device_groups[$_COOKIE['mt_device']])){
+        if (isset($device_groups[$_COOKIE['mt_device']])) {
           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' => 'mobile',
+            'group' => $_COOKIE['mt_device'],
+          );
         }
     }
   }
@@ -415,7 +426,7 @@ function mobile_tools_is_mobile_device() {
 }
 
 /**
- *  Default implementation of hook_is_mobile_device()
+ * Implementation of hook_is_mobile_device().
  * @return $device
  *  The $device object
  */
@@ -427,7 +438,7 @@ function _mobile_tools_is_mobile_device() {
   );
 
   if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
-	  $user_agent = $_SERVER['HTTP_USER_AGENT'];
+    $user_agent = $_SERVER['HTTP_USER_AGENT'];
   }
   else {
     return FALSE;
@@ -435,10 +446,10 @@ function _mobile_tools_is_mobile_device() {
   // get the content accept value
   // FIXME: this should be cleaned to ensure no nefarious input gets executed
   if (array_key_exists('HTTP_ACCEPT', $_SERVER)) {
-  	$accept = $_SERVER['HTTP_ACCEPT'];
+    $accept = $_SERVER['HTTP_ACCEPT'];
   }
   else {
-  	$accept = '';
+    $accept = '';
   }
 
   switch (TRUE) {
@@ -491,7 +502,7 @@ function _mobile_tools_is_mobile_device() {
       );
     break;
     // The device shows signs of support for text/vnd.wap.wml or application/vnd.wap.xhtml+xml
-    case ((strpos($accept,'text/vnd.wap.wml') > 0) || (strpos($accept,'application/vnd.wap.xhtml+xml') > 0));
+    case ((strpos($accept, 'text/vnd.wap.wml') > 0) || (strpos($accept, 'application/vnd.wap.xhtml+xml') > 0));
       $mobile_browser = array(
         'type' => 'mobile',
         'group' => '',
@@ -519,29 +530,29 @@ function _mobile_tools_is_mobile_device() {
 }
 
 /**
- *  Detection of the site type . the values comes out the configuration form.
+ *  Detection of the site type. The values comes out the configuration form.
  */
 function mobile_tools_site_type() {
   $site_detection = variable_get('mobile-tools-site-type-detection', 'mobile_tools');
   drupal_load('module', $site_detection);
   if ($site_detection == 'mobile_tools') {
-   return _mobile_tools_site_detection();;
+    return _mobile_tools_site_detection();;
   }
   else {
-   return module_invoke($site_detection, 'is_mobile_site');
+    return module_invoke($site_detection, 'is_mobile_site');
   }
 }
 
 /**
- * Mobile Tools implementation to detect what site is being served now
+ * Helper function to detect what site is being served.
  * @return
  *  desktop / mobile
  */
 function _mobile_tools_site_detection() {
   global $base_url, $mobile_tools_device;
   // Easy detection in case redireciton is disabled and device specific theme switching is enabled
-  if(!variable_get('mobile_tools_redirect', 0) && variable_get('mobile-tools-theme-switch', '' ) == 'mobile-tools-mobile-device'){
-    if($mobile_tools_device['type']  == 'mobile'){
+  if (!variable_get('mobile_tools_redirect', 0) && variable_get('mobile-tools-theme-switch', '' ) == 'mobile-tools-mobile-device') {
+    if ($mobile_tools_device['type']  == 'mobile') {
       return 'mobile';
     }
     else {
@@ -549,7 +560,7 @@ function _mobile_tools_site_detection() {
     }
   }
   // Check if $_SERVER variables are set if not, just return desktop... Still unclear what best solution is:
-  if(!isset($_SERVER['HTTP_HOST']) && !isset($_SERVER['SERVER_NAME'])){
+  if (!isset($_SERVER['HTTP_HOST']) && !isset($_SERVER['SERVER_NAME'])) {
     return 'desktop';
   }
   $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
@@ -558,11 +569,12 @@ function _mobile_tools_site_detection() {
   if (count($server_domain_elements) > 0 ) {
     if ($server_domain_elements[0] == 'm') { // check for m.* domain
       return 'mobile';
-   }
+    }
     if ($server_domain_elements[count($server_domain_elements) - 1] == 'mobi') { // check for *.mobi
-     return 'mobile';
+      return 'mobile';
     }
   }
+
   // If this doesn't return an answer, we will have to do a comparison of the mobile and desktop url!
   $mobile = variable_get('mobile_tools_mobile_url', mobile_tools_create_mobile_url($base_url));
   $mobile_url  = parse_url($mobile);
@@ -577,8 +589,9 @@ function _mobile_tools_site_detection() {
   if (!array_key_exists('path', $mobile_url)) {
     $mobile_url['path'] = '';
   }
+
   // If $_SERVER['HTTP_HOST'] is not set just return desktop
-  if(!isset($_SERVER['HTTP_HOST'])){
+  if (!isset($_SERVER['HTTP_HOST'])) {
     return 'desktop';
   }
   $server_name = mobile_tools_prepare_url($_SERVER['HTTP_HOST']);
@@ -638,11 +651,11 @@ function _mobile_tools_device_groups() {
 }
 
 /**
- * Implementation of hook_devicecapability()
+ * Implementation of hook_devicecapability().
  * This default implementation invokes the responsible module
  */
 function mobile_tools_devicecapability($capability) {
-   return module_invoke(variable_get('mobile-tools-device-capability', 'wurfl'), 'devicecapability', $capability);
+  return module_invoke(variable_get('mobile-tools-device-capability', 'wurfl'), 'devicecapability', $capability);
 }
 
 /**
@@ -683,7 +696,7 @@ function mobile_tools_get_redirect_url($destination_site) {
   //create the path and reassemble
   $base = preg_replace('{/$}', '', $destination_url);
   $currentUrl = url($_GET['q'], array('query' => $query));
-  $currentPath = str_replace(base_path(), "/" ,$currentUrl); 
+  $currentPath = str_replace(base_path(), "/" , $currentUrl);
   $url =  $base . $currentPath ;
   return $url;
 }
@@ -723,41 +736,41 @@ function mobile_tools_create_mobile_url($url) {
  */
 function mobile_tools_form_alter(&$form, $form_state, $form_id) {
   switch ($form_id) {
-      case 'node_configure':
+    case 'node_configure':
       $form['default_nodes_main_mobile'] = array(
-            '#type' => 'select',
-            '#title' => t('Number of posts on main page for the mobile version'),
-            '#default_value' => variable_get('default_nodes_main_mobile', variable_get('default_nodes_main', 10)),
-            '#options' => Array(
-                    1 => 1,
-                    2 => 2,
-                    3 => 3,
-                    4 => 4,
-                    5 => 5,
-                    6 => 6,
-                    7 => 7,
-                    8 => 8,
-                    9 => 9,
-                    10 => 10,
-                    15 => 15,
-                    20 => 20,
-                    25 => 25,
-                    30 => 30,
-                ),
-            '#description' => t('The default maximum number of posts to display per page on overview pages such as the main page (on Mobile).'),
-        );
+        '#type' => 'select',
+        '#title' => t('Number of posts on main page for the mobile version'),
+        '#default_value' => variable_get('default_nodes_main_mobile', variable_get('default_nodes_main', 10)),
+        '#options' => Array(
+          1 => 1,
+          2 => 2,
+          3 => 3,
+          4 => 4,
+          5 => 5,
+          6 => 6,
+          7 => 7,
+          8 => 8,
+          9 => 9,
+          10 => 10,
+          15 => 15,
+          20 => 20,
+          25 => 25,
+          30 => 30,
+        ),
+        '#description' => t('The default maximum number of posts to display per page on overview pages such as the main page (on Mobile).'),
+      );
       break;
   }
 }
 
 /**
- * Implementation of hook_footer()
+ * Implementation of hook_footer().
  *  - inserting some javascript to hide navigation bar
  */
-function mobile_tools_footer(){
+function mobile_tools_footer() {
   $output = '';
-  $site =  mobile_tools_site_type();
-  if(variable_get('mobile_tools_hide_address_bar', 1) && $site == 'mobile'){
+  $site = mobile_tools_site_type();
+  if (variable_get('mobile_tools_hide_address_bar', 1) && $site == 'mobile') {
     $output .= '<script type="text/javascript" charset="utf-8">';
     $output .= <<<EOF
     addEventListener('load', function() {
@@ -773,11 +786,12 @@ EOF;
 }
 
 /**
- * Implements hook_preprocess_page().
+ * Implementation of hook_preprocess_page().
  */
-function mobile_tools_preprocess_page(&$vars){
+function mobile_tools_preprocess_page(&$vars) {
   $site = mobile_tools_site_type();
-  if(variable_get('mobile_tools_add_header', 1) && $site == 'mobile'){
+
+  if (variable_get('mobile_tools_add_header', 1) && $site == 'mobile') {
     // Add the custom output to the HTML HEAD collection.
     drupal_set_html_head(theme('mobile_tools_header'));
     $vars['head'] = drupal_get_html_head();
@@ -785,7 +799,7 @@ function mobile_tools_preprocess_page(&$vars){
 }
 
 /**
- * copy of drupal_goto, since this is called in hook_boot, while the function is not yet available
+ * Copy of drupal_goto, since this is called in hook_boot, while the function is not yet available
  */
 function mobile_tools_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302) {
   $url = $path;
@@ -834,8 +848,8 @@ function mobile_tools_ctools_plugin_directory($module, $plugin) {
  */
 
 /**
-* Implementation of hook_nodeapi
-*/
+ * Implementation of hook_nodeapi().
+ */
 function mobile_tools_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   if ($op == 'load' && mobile_tools_site_type() == 'mobile' && variable_get('mobile_tools_enable_build_mode', 0)) {
     $node->build_mode = 'mobile';
@@ -843,24 +857,19 @@ function mobile_tools_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
 }
 
 /**
- * Implementation of hook_content_build_modes
+ * Implementation of hook_content_build_modes().
  */
 function mobile_tools_content_build_modes() {
   $groups = mobile_tools_device_groups();
   $modes = array();
-  foreach($groups as $group => $title){
+  foreach ($groups as $group => $title) {
     $modes[$group] = array(
       'title' => $title,
       'views style' => TRUE,
     );
   }
   $build_modes = array();
-  // Needs some more thought in combining groups and types. We need to detect which build mode takes the lead
-/*  $build_modes['mobile_tools_groups'] = array(
-    'title' => 'Mobile Groups',
-    'build modes' => $modes,
-  );
-*/
+
   $build_modes['mobile_tools_types'] = array(
     'title' => 'Mobile Device',
     'build modes' => array(
@@ -875,8 +884,7 @@ function mobile_tools_content_build_modes() {
 }
 
 /**
- * Implementation of hook_context_plugins
- * We create mobile contexts
+ * Implementation of hook_context_plugins().
  */
 function mobile_tools_context_plugins() {
   $plugins = array();
@@ -904,7 +912,7 @@ function mobile_tools_context_registry() {
 }
 
 /**
- * Implementation of hook_views_api
+ * Implementation of hook_views_api().
  */
 function mobile_tools_views_api() {
   return array(
@@ -914,14 +922,14 @@ function mobile_tools_views_api() {
 }
 
 /**
- *  Views access check as used by the mobile access check for views
+ * Views access check as used by the mobile access check for views
  */
-function mobile_tools_views_check_access($device, $perms, $rids){
+function mobile_tools_views_check_access($device, $perms, $rids) {
   global $user;
   // first check device permission
   $current_device = mobile_tools_site_type();
   // general case of mobile site
-  if(!empty($device[$current_device])){
+  if (!empty($device[$current_device])) {
     $access = TRUE;
   }
   else {
@@ -933,12 +941,12 @@ function mobile_tools_views_check_access($device, $perms, $rids){
       $access = $access && user_access($perm);
     }
   }
-  
+
   $account = isset($account) ? $account : $user;
   $roles = array_keys($account->roles);
   $roles[] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
-  if($rids){
-	  $access = $access && (user_access('access all views', $account) || array_intersect(array_filter($rids), $roles));
-	}
+  if ($rids) {
+    $access = $access && (user_access('access all views', $account) || array_intersect(array_filter($rids), $roles));
+  }
   return $access;
-}
\ No newline at end of file
+}
