diff --git a/redirect.admin.inc b/redirect.admin.inc
index 19ffaf8..bfe1cb5 100644
--- a/redirect.admin.inc
+++ b/redirect.admin.inc
@@ -637,20 +637,17 @@ function redirect_settings_form($form, &$form_state) {
     '#type' => 'fieldset',
     '#title' => t('Always enabled redirections'),
     '#description' => t('(formerly Global Redirect features)'),
-    '#access' => FALSE,
   );
   $form['globals']['redirect_global_home'] = array(
     '#type' => 'checkbox',
     '#title' => t('Redirect from paths like index.php and /node to the root directory.'),
     '#default_value' => variable_get('redirect_global_home', 1),
-    '#access' => FALSE,
   );
   $form['globals']['redirect_global_clean'] = array(
     '#type' => 'checkbox',
     '#title' => t('Redirect from non-clean URLs to clean URLs.'),
     '#default_value' => variable_get('redirect_global_clean', 1),
     '#disabled' => !variable_get('clean_url', 0),
-    '#access' => FALSE,
   );
   $form['globals']['redirect_global_canonical'] = array(
     '#type' => 'checkbox',
@@ -661,7 +658,6 @@ function redirect_settings_form($form, &$form_state) {
     '#type' => 'checkbox',
     '#title' => t('Remove trailing slashes from paths.'),
     '#default_value' => variable_get('redirect_global_deslash', 0),
-    '#access' => FALSE,
   );
   $form['globals']['redirect_global_admin_paths'] = array(
     '#type' => 'checkbox',
diff --git a/redirect.module b/redirect.module
index dfbe029..749ced1 100644
--- a/redirect.module
+++ b/redirect.module
@@ -206,20 +206,30 @@ function redirect_menu() {
  * Implements hook_url_inbound_alter().
  */
 function redirect_url_inbound_alter(&$path, $original_path, $path_language) {
-  // Redirect to canonical URLs.
-  if ($path && variable_get('redirect_canonical', 1)) {
-    $alias = drupal_get_path_alias($path, $path_language);
-    if ($alias != $path && $alias != $original_path) {
-      //return redirect_redirect(array('redirect' => $alias, 'type' => 'global'));
-    }
+  // Check for empty path or disabled canonical redirects.
+  if (empty($path) || !variable_get('redirect_global_canonical', 1)) {
+    return;
+  }
+  // Do not redirect if $original_path does not match the requested url.
+  if ($original_path != $_GET['q']) {
+    return;
+  }
+  // Do not redirect if disallowed.
+  if (!redirect_can_redirect()) {
+    return;
+  }
 
-    // Redirect from default entity paths to the proper entity path.
-    if ($path_entity = redirect_load_entity_from_path($path)) {
-      if ($uri = entity_uri($path_entity['entity_type'], $path_entity['entity'])) {
-        if ($path != $uri['path']) {
-          //return redirect_redirect(array('redirect' => $uri['path'], 'redirect_options' => $uri['options'], 'type' => 'global'));
-        }
-      }
+  $alias = drupal_get_path_alias($path, $path_language);
+
+  if ($alias != $path && $alias != $original_path) {
+    return redirect_redirect((object)array('redirect' => $alias, 'type' => 'global'));
+  }
+
+  // Redirect from default entity paths to the proper entity path.
+  if ($path_entity = redirect_load_entity_from_path($path)) {
+    $uri = entity_uri($path_entity['entity_type'], $path_entity['entity']);
+    if ($path != $uri['path']) {
+      return redirect_redirect((object)array('redirect' => $uri['path'], 'redirect_options' => $uri['options'], 'type' => 'global'));
     }
   }
 }
@@ -252,29 +262,43 @@ function redirect_init() {
   $current_path = current_path();
   $current_langcode = $GLOBALS['language']->language;
   $current_query = drupal_get_query_parameters();
-  if ($redirect = redirect_load_by_source($current_path, $current_langcode, $current_query)) {
-    redirect_redirect($redirect);
+  if ($redirects = redirect_load_by_source($current_path, $current_langcode, $current_query)) {
+    redirect_redirect(reset($redirects));
   }
 
   $redirect_global = FALSE;
   $request_uri = $original_uri = ltrim(request_uri(), '/');
-
-  // Redirect from non-clean URLs to clean URLs.
-  if (variable_get('redirect_global_clean', 1) && variable_get('clean_url', 0) && strpos($request_uri, '?q=') !== FALSE) {
-    //$redirect_global = TRUE;
-    //$request_uri = str_replace('?q=', '', $request_uri);
-  }
-
-  if (strpos($request_uri, 'index.php') !== FALSE) {
-    //$redirect_global = TRUE;
-    //$request_uri = str_replace('index.php', '', $request_uri);
+  $is_query = (strpos($request_uri, '?q=') !== FALSE) || (strpos($request_uri, '&q=') !== FALSE);
+  
+  // Redirect from non-clean URLs to clean URLs.
+  if (variable_get('redirect_global_clean', 1) && variable_get('clean_url', 0) && $is_query) {
+    $redirect_global = TRUE;
+    $request_uri = $current_path;
+  }
+
+  // redirect to front page
+  if (variable_get('redirect_global_home', 1)) {
+    //echo $_GET['q'].' '; echo drupal_is_front_page()?0:1; die;
+    if ( drupal_is_front_page() && strpos($request_uri, variable_get('site_frontpage', 'node')) === 0) {
+      global $base_url;
+      $redirect_global = TRUE;
+      $request_uri = $base_url;
+    }
   }
 
-  //$request_uri = ltrim($request_uri, '/');
-  //$parsed = parse_url($request_uri);
-
   if ($redirect_global && $request_uri != $original_uri) {
-    redirect_redirect(array(/*'redirect' => $request_uri,*/ 'type' => 'global'));
+    if (strpos($request_uri,'?') === 0) {
+      $request_uri = ''; //should newer happen
+    }
+    $redirect = new stdClass;
+    $redirect->source = $current_path;
+    $redirect->redirect = $request_uri;
+    $redirect->type = 'global';
+    $redirect->source = $current_path;
+    $redirect->redirect_options = array (
+      'query'  => $current_query,
+    );
+    redirect_redirect($redirect);
   }
 }
 
@@ -527,7 +551,7 @@ function redirect_load_by_source($source, $language = LANGUAGE_NONE, array $quer
       $context = array('language' => $language, 'query' => $query);
       drupal_alter('redirect_load_by_source', $redirects, $source, $context);
 
-      return !empty($redirects) ? reset($redirects) : FALSE;
+      return !empty($redirects) ? $redirects : FALSE;
     }
   }
 
@@ -642,7 +666,7 @@ function redirect_validate($redirect, $form, &$form_state) {
   }
 }
 
-function redirect_object_prepare($redirect, $defaults = array()) {
+function redirect_object_prepare(stdClass $redirect, $defaults = array()) {
   $defaults += array(
     'rid' => NULL,
     'type' => 'redirect',
@@ -909,7 +933,7 @@ function redirect_purge_inactive_redirects(array $types = array('redirect'), $in
  *
  * @ingroup redirect_api
  */
-function redirect_redirect($redirect = NULL) {
+function redirect_redirect(stdClass $redirect = NULL) {
   // First check if we're in an infinite loop.
   $session_id = session_id();
   if (flood_is_allowed('redirection', 5, 15, $session_id ? $session_id : NULL)) {
