diff --git a/sites/all/modules/admin_language/admin_language.module b/sites/all/modules/admin_language/admin_language.module
index f2e5224..7f3f4e3 100644
--- a/sites/all/modules/admin_language/admin_language.module
+++ b/sites/all/modules/admin_language/admin_language.module
@@ -91,9 +91,27 @@ function admin_language_translated_menu_link_alter(&$item, $map) {
 }
 
 /**
- * Implements hook_init().
+ * Implements hook_language_negotiation_info()
  */
-function admin_language_init() {
+function admin_language_language_negotiation_info() {
+  return array(
+    'admin_language_provider' => array(
+      'callbacks' => array(
+        'language' => 'admin_language_provider_callback',
+      ),
+      'file' => drupal_get_path('module', 'admin_language') . '/admin_language.module',
+      'weight' => -99,
+      'name' => t('Admin language'),
+      'description' => t('Set admin language custom sites.'),
+      'cache' => 0,
+    ),
+  );
+}
+
+/**
+ * Custom callback for language switching
+ */
+function admin_language_provider_callback($languages) {
   if (user_access('display admin pages in another language') && drupal_multilingual()) {
     global $_admin_language;
 
@@ -106,10 +124,13 @@ function admin_language_init() {
     if (_admin_language_switch_language()) {
       global $user;
 
-      $account = user_load($user->uid);
+      $query = db_select('admin_language', 'al');
+      $query->addField('al', 'language');
+      $query->condition('uid', $user->uid);
+      $usr_lang = $query->execute()->fetchField();
 
-      if (isset($account->admin_language)) {
-        switch ($account->admin_language) {
+      if (isset($usr_lang)) {
+        switch ($usr_lang) {
           case 'admin':
             // nothing to do, use default value of $admin_language
             break;
@@ -118,14 +139,12 @@ function admin_language_init() {
             $admin_language = $default->language;
             break;
           default:
-            if (isset($languages[$account->admin_language])) {
-              $admin_language = $account->admin_language;
+            if (isset($languages[$usr_lang])) {
+              $admin_language = $usr_lang;
             }
         }
       }
-
-      global $language;
-      $language = $languages[$admin_language];
+      return $admin_language;
     }
   }
 }
@@ -568,8 +587,8 @@ function _admin_language_switch_language() {
   $pages = variable_get('admin_language_pages', ADMIN_LANGUAGE_DEFAULT_PAGES);
 
   if ($pages) {
-    $path = drupal_get_path_alias($_GET['q']);
-    $switch = drupal_match_path($path, $pages);
+    $path = request_path(); // we do not need aliases for administration purposes
+    $switch = _admin_language_match_path($path, $pages);
     if ($path != $_GET['q']) {
       $switch = $switch || drupal_match_path($_GET['q'], $pages);
     }
@@ -665,3 +684,28 @@ function _admin_language_user_form_remove_admin_language($form) {
 
   return $form;
 }
+
+/**
+ * Copy of drupal_match_patch which is not awailable at bootstrap.
+ */
+function _admin_language_match_path($path, $patterns) {
+  $regexps = &drupal_static(__FUNCTION__);
+
+  if (!isset($regexps[$patterns])) {
+    // Convert path settings to a regular expression.
+    // Therefore replace newlines with a logical or, /* with asterisks and the <front> with the frontpage.
+    $to_replace = array(
+      '/(\r\n?|\n)/', // newlines
+      '/\\\\\*/', // asterisks
+      '/(^|\|)\\\\<front\\\\>($|\|)/', // <front>
+    );
+    $replacements = array(
+      '|',
+      '.*',
+      '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2',
+    );
+    $patterns_quoted = preg_quote($patterns, '/');
+    $regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
+  }
+  return (bool) preg_match($regexps[$patterns], $path);
+}
