diff --git a/Irpg/Main.pm b/Irpg/Main.pm
index f345f07310e4e596741421fc5179bcf02f4680bc..2aa9be5c40a8104a6270079fc44856cf2a36db0e 100644
--- a/Irpg/Main.pm
+++ b/Irpg/Main.pm
@@ -29,6 +29,7 @@ my $lastreg = 0; # holds the time of the last reg. cleared every second.
 my $lasttime_ref;
 my %split; # holds nick!user@hosts for clients that have been netsplit
 my %onchan; # users on game channel
+my %auto_login;
 
 my $pausemode = 0; # pausemode on/off flag
 my $silentmode = 0; # silent mode 0/1/2/3, see head of file
@@ -37,7 +38,6 @@ my $primnick;
 my $opts;
 my $rps;
 my $prev_online;
-my $auto_login;
 =head1 FUNCTION init_pkg
 	This function sets the references to
 	options and players hashes.
@@ -45,10 +45,9 @@ my $auto_login;
 =item SCALAR (ref)	- reference to the options hash
 =item SCALAR (ref)	- reference to the players hash
 =item SCALAR (ref)	- reference to the prev_online hash
-=item SCALAR (ref)	- reference to the auto_login hash
 =cut
 sub init_pkg {
-	($opts, $rps, $lasttime_ref, $prev_online, $auto_login) = @_;
+	($opts, $rps, $lasttime_ref, $prev_online) = @_;
 	$primnick = $opts->{botnick}; # for regain or register checks
 	Irpg::Irc::init_pkg(\$silentmode);
 	Irpg::Quest::init_pkg($opts, $rps);
@@ -138,7 +137,6 @@ sub penalize {
 	my $pen_key;
     if ($type eq "quit") {
         $pen = int(20 * ($opts->{rppenstep}**$rps->{$username}{level}));
-        $rps->{$username}{online}=0;
 		$reason = undef;
 		$pen_key = 'pen_quit';
     }
@@ -270,9 +268,6 @@ sub rpcheck { # check levels, update database
 	foreach (qw(Quest Action Event)) {
 		eval 'Irpg::'.$_.'::rpcheck($rpreport, $online';
 	}
-#	Irpg::Quest::rpcheck($rpreport, $online); ### QUEST BUSINESS ###
-#	Irpg::Action::rpcheck($rpreport, $online); ### FIGHT BUSINESS ###
-#	Irpg::Event::rpcheck($rpreport, $online); ### EVENT BUSINESS ###
 
 	### TOP PLAYERS REPORT ###
     if ($rpreport && $rpreport%36000==0) { # 10 hours
@@ -373,10 +368,10 @@ sub parse {
     if (lc($arg[0]) eq 'ping') { Irpg::Irc::sts("PONG $arg[1]",1); }
     elsif (lc($arg[0]) eq 'error') {
         # uh oh, we've been disconnected from the server, possibly before we've
-        # logged in the users in %$auto_login. so, we'll set those users' online
+        # logged in the users in %auto_login. so, we'll set those users' online
         # flags to 1, rewrite db, and attempt to reconnect (if that's wanted of
         # us)
-        $rps->{$_}{online}=1 for keys(%$auto_login);
+        $rps->{$_}{online}=1 for keys(%auto_login);
         writedb($rps);
         return;
     }
@@ -386,7 +381,7 @@ sub parse {
         Irpg::Irc::sts("NICK $opts->{botnick}");
     }
     elsif ($arg[1] eq 'join') {
-        # %onchan holds time user joined channel. used for the advertisement ban
+        # %onchan holds time user joined channel. used just to now who is there
 		$onchan{$usernick}=time() if ($opts->{botchan} eq substr($arg[2], 1));
         if ($opts->{'detectsplits'} && exists($split{substr($arg[0],1)})) {
             delete($split{substr($arg[0],1)});
@@ -408,7 +403,8 @@ sub parse {
                 $split{substr($arg[0],1)}{account}=$username;
             }
         }
-        else {
+        elsif (defined($username)) {
+			$rps->{$username}{online}=0;
             penalize($username,"quit");
         }
 		delete($onchan{$usernick});
@@ -421,25 +417,27 @@ sub parse {
         # if we see our nick come open, grab it (skipping queue), unless it was
         # us who just lost it
         elsif ($usernick eq $primnick) { Irpg::Irc::sts("NICK $primnick",1); }
-        else {
-			$rps->{$username}{nick} = substr($arg[2],1);
-			substr($rps->{$username}{userhost},0,length($rps->{$username}{nick})) =
-				substr($arg[2],1);
-            penalize($username,"nick");
+		else {
+			if (defined($username)) {
+				$rps->{$username}{nick} = substr($arg[2],1);
+				substr($rps->{$username}{userhost},0,length($rps->{$username}{nick})) =
+					substr($arg[2],1);
+				penalize($username,"nick");
+			}
 			if (exists($onchan{$usernick})) {
 				$onchan{substr($arg[2],1)} = delete($onchan{$usernick});
 			}
-        }
+		}
     }
     elsif ($arg[1] eq 'part') {
-        $rps->{$username}{online}=0;
+        $rps->{$username}{online}=0 if (defined($username));
         penalize($username,"part");
         delete($onchan{$usernick}) if ($opts->{botchan} eq substr($arg[2], 1));
     }
     elsif ($arg[1] eq 'kick') {
         $usernick = $arg[3];
 		$username = finduser($usernick);
-        $rps->{$usernick}{online}=0;
+        $rps->{$username}{online}=0;
         penalize($username,"kick");
         delete($onchan{$usernick}) if ($opts->{botchan} eq $arg[2]);
     }
@@ -460,20 +458,20 @@ sub parse {
     elsif ($arg[1] eq '315') {
         # 315 is /WHO end. report who we automagically signed online iff it will
         # print < 1k of text
-        if (keys(%$auto_login)) {
+        if (keys(%auto_login)) {
             # not a true measure of size, but easy
-            if (length("%$auto_login") < 1024 && $opts->{senduserlist}) {
-                Irpg::Irc::chanmsg(scalar(keys(%$auto_login))." users matching ".
+            if (length("%auto_login") < 1024 && $opts->{senduserlist}) {
+                Irpg::Irc::chanmsg(scalar(keys(%auto_login))." users matching ".
                         scalar(keys(%$prev_online))." hosts automatically ".
-                        "logged in; accounts: ".join(", ",keys(%$auto_login)));
+                        "logged in; accounts: ".join(", ",keys(%auto_login)));
             }
             else {
-                Irpg::Irc::chanmsg(scalar(keys(%$auto_login))." users matching ".
+                Irpg::Irc::chanmsg(scalar(keys(%auto_login))." users matching ".
                         scalar(keys(%$prev_online))." hosts automatically ".
                         "logged in.");
             }
             if ($opts->{voiceonlogin}) {
-                my @vnicks = map { $rps->{$_}{nick} } keys(%$auto_login);
+                my @vnicks = map { $rps->{$_}{nick} } keys(%auto_login);
                 while (@vnicks) {
                     Irpg::Irc::sts("MODE $opts->{botchan} +".
                         ('v' x $opts->{modesperline})." ".
@@ -484,7 +482,7 @@ sub parse {
         }
         else { Irpg::Irc::chanmsg("0 users qualified for auto login."); }
         undef($prev_online);
-        undef($auto_login);
+        undef(%auto_login);
     }
     elsif ($arg[1] eq '005') {
         if ("@arg" =~ /MODES=(\d+)/) { $opts->{modesperline}=$1; }
@@ -496,7 +494,7 @@ sub parse {
         $onchan{$arg[7]}=time() if ($opts->{botchan} eq $arg[3]);
         if (exists($prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]})) {
             $rps->{$prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]}}{online} = 1;
-            $auto_login->{$prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]}}=1;
+            $auto_login{$prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]}}=1;
         }
     }
     elsif ($arg[1] eq 'privmsg') {
diff --git a/irpg_bot.pl b/irpg_bot.pl
index a8fb665d46be9a97a561e7fd90fe7a465907a749..4dd112204f1d25e5f60a92335649ec8054e01486 100644
--- a/irpg_bot.pl
+++ b/irpg_bot.pl
@@ -151,7 +151,7 @@ $prev_online = loaddb($rps, 1);
 
 irc_connect($opts);
 
-Irpg::Main::init_pkg($opts, $rps, \$lasttime, $prev_online, $auto_login);
+Irpg::Main::init_pkg($opts, $rps, \$lasttime, $prev_online);
 
 #-----------------#
 #    MAIN LOOP    #