diff --git a/autologout.module b/autologout.module
index 3c22b50..f00eb86 100644
--- a/autologout.module
+++ b/autologout.module
@@ -189,16 +189,16 @@ function autologout_init() {
   // If user is not anonymous and they should be autologged out.
   if ($user->uid && _autologout_logout_role($user)) {
     // Should we be enforcing on admin pages?
-    // Check to see if autologout on admin pages is enforeced.
+    // Check to see if autologout on admin pages is enforced.
     if (arg(0) == 'admin' && !variable_get('autologout_enforce_admin', FALSE)) {
       return;
     }
 
     $now = time();
-    $timeout = _autologout_get_user_timeout(); // Get logout based on role
+    $timeout = _autologout_get_user_timeout(); // Get logout based on role.
     $timeout_padding = variable_get('autologout_padding', 10);
     $redirct_url = variable_get('autologout_redirect_url', 'user/login');
-    drupal_add_library('system', 'ui.dialog'); // Add jquery UI for dialog
+    drupal_add_library('system', 'ui.dialog'); // Add jquery UI for dialog.
 
     // Get all settings JS will need for dialog.
     $msg = t('@msg', array('@msg' => variable_get('autologout_message', 'Your session is about to expire. Do you want to reset it?')));
@@ -272,23 +272,24 @@ function _autologout_get_user_timeout() {
     $userid = $user->uid;
   }
   else {
-    $userid = '';
+    return;
   }
 
   $default_timeout = variable_get('autologout_timeout', 1800);
 
   // If no individual timeout is set.
-  if (!variable_get('autologout_user_' . $userid, $default_timeout)) {
+  if (!variable_get('autologout_user_' . $userid, 0)) {
     // Get role timeouts for user.
     if (variable_get('autologout_role_logout', FALSE)) {
-      $roles = $user -> roles;
+      $roles = $user->roles;
       $output = array();
       $timeouts = _autologout_get_role_timeout();
-        foreach ($roles as $rid => $role) {
-          $output[$rid] =  $timeouts[$rid];
-        }
-      $user_timeout = min($output);
+      foreach ($roles as $rid => $role) {
+        $output[$rid] =  $timeouts[$rid];
+      }
+
       // Assign the lowest timeout value to be session timeout value.
+      $user_timeout = min($output);
     }
     else{
       $user_timeout = $default_timeout;
