diff --git a/ip2locale.module b/ip2locale.module
index c353a4b..5b57a3b 100644
--- a/ip2locale.module
+++ b/ip2locale.module
@@ -209,7 +209,7 @@ function ip2locale_boot() {
   );
   if (function_exists('language_url_rewrite')) {
     // Note that language_url_rewrite() takes path (by reference) as the first argument but does not use it at all.
-    $path = $_REQUEST['q'];
+    $path = isset($_REQUEST['q']) ? $_REQUEST['q'] : '';
     language_url_rewrite($path, $options);
   }
   if ($prefix = rtrim($options['prefix'], '/')) {
@@ -239,6 +239,7 @@ function ip2locale_boot() {
   $languages = language_list('enabled');
 
   foreach ($languages[1] as $lang) {
+    $redirect = FALSE;
     switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
       case LANGUAGE_NEGOTIATION_DOMAIN:
         if (($lc == $lang->language) && ($language->language != $lc)) {
@@ -502,7 +503,7 @@ function ip2locale_get_locale($ip) {
   }
 
   $custom_mappings = _ip2locale_custom_map_options(variable_get('ip2locale_custom_mapping', ''));
-  $lc = $custom_mappings[$cc]? $custom_mappings[$cc] : $cc;
+  $lc = isset($custom_mappings[$cc]) ? $custom_mappings[$cc] : $cc;
 
   if (variable_get('ip2locale_debug', FALSE)) {
     $mapped = $lc? $lc : 'NONE';
@@ -516,7 +517,7 @@ function ip2locale_get_locale($ip) {
  * Helper function to get the current ip address
  */
 function ip2locale_ip_address() {
-  if (variable_get('ip2locale_debug', FALSE) && $_GET['ip2locale_debug']) {
+  if (variable_get('ip2locale_debug', FALSE) && isset($_GET['ip2locale_debug'])) {
     $ip = $_GET['ip2locale_debug'];
     drupal_set_message('IP to Locale debug: Using IP '. $ip);
   }
