diff --git a/Irpg/Admin.pm b/Irpg/Admin.pm
index 06fb3bad2af3cd60cac3528756e66f6abf654b7f..aac310bf42cf5814846d382b7dbf06d9734cc491 100644
--- a/Irpg/Admin.pm
+++ b/Irpg/Admin.pm
@@ -31,7 +31,7 @@ sub leave_chans {
 }
 
 sub peval {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if ($opts->{ownerpevalonly} && $opts->{owner} ne $username) {
 		Irpg::Irc::privmsg("You don't have access to PEVAL.", $usernick);
 	}
@@ -50,7 +50,7 @@ sub peval {
 }
 
 sub delold {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if ($arg[0] !~ /^[\d\.]+$/) {
 		Irpg::Irc::privmsg("Try: DELOLD <# of days>", $usernick, 1);
 	}
@@ -65,7 +65,7 @@ sub delold {
 }
 
 sub delacct {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($arg[0])) {
 	   Irpg::Irc::privmsg("Try: DEL <char name>", $usernick, 1);
 	}
@@ -79,7 +79,7 @@ sub delacct {
 }
 
 sub mkadmin {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if ($opts->{owneraddonly} && $opts->{owner} ne $username) {
 		Irpg::Irc::privmsg("You don't have access to MKADMIN.", $usernick);
 	}
@@ -96,7 +96,7 @@ sub mkadmin {
 }
 
 sub rmadmin {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if ($opts->{ownerdelonly} && $opts->{owner} ne $username) {
 		Irpg::Irc::privmsg("You don't have access to RMADMIN.", $usernick);
 	}
@@ -117,20 +117,20 @@ sub rmadmin {
 }
 
 sub do_hog {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	Irpg::Irc::chanmsg("$usernick has summoned the Hand of God.");
 	hog();
 }
 
 sub rehash {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	readconfig();
 	Irpg::Irc::privmsg("Reread config file.",$usernick,1);
 	$opts->{botchan} =~ s/ .*//; # strip channel key if present
 }
 
 sub chpass {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($arg[1])) {
 		Irpg::Irc::privmsg("Try: CHPASS <char name> <new pass>", $usernick, 1);
 	}
@@ -144,7 +144,7 @@ sub chpass {
 }
 
 sub chuser {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($arg[1])) {
 		Irpg::Irc::privmsg("Try: CHUSER <char name> <new char name>",
 				$usernick, 1);
@@ -163,7 +163,7 @@ sub chuser {
 }
 
 sub push {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	# insure it's a positive or negative, integral number of seconds
 	if ($arg[1] !~ /^\-?\d+$/) {
 		Irpg::Irc::privmsg("Try: PUSH <char name> <seconds>", $usernick, 1);
@@ -189,29 +189,30 @@ sub push {
 }
 
 sub bot_die {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	$opts->{reconnect} = 0;
 	writedb($opts, $rps);
 	Irpg::Irc::sts("QUIT :DIE from $usernick",1);
 }
 
 sub restart {
-	my ($usernick, $username, $source, @arg) = @_;
-	writedb();
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
+	writedb($opts, $rps);
 	Irpg::Irc::sts("QUIT :RESTART from $usernick",1);
-	close($Irpg::Irc::sock);
+	#close($Irpg::Irc::sock);
+	#Irpg::Irc::irc_clean($opts);
 	exec("perl $0");
 }
 
 sub do_backup {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	backup();
 	Irpg::Irc::privmsg("$opts->{dbfile} copied to ".
 			".dbbackup/$opts->{dbfile}".time(),$usernick,1);
 }
 
 sub clearq {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	undef(@Irpg::Irc::queue);
 	Irpg::Irc::chanmsg("Outgoing message queue cleared by $usernick.");
 	Irpg::Irc::privmsg("Outgoing message queue cleared.",$usernick,1);
diff --git a/Irpg/Irc.pm b/Irpg/Irc.pm
index e8e66f8643ace1dbfe20e275c22105b216c14be2..2eaba5cea43db53be238ee9f9c795546c408ffa9 100644
--- a/Irpg/Irc.pm
+++ b/Irpg/Irc.pm
@@ -20,8 +20,8 @@ use warnings;
 use IO::Socket;
 use IO::Select;
 use Irpg::Utils;
-use Irpg::Main qw($silentmode);
 use Exporter qw(import);
+our @EXPORT = qw($sock);
 our @EXPORT_OK = qw($sock @queue
 					&irc_connect &irc_clean
 					&checkmsg &fq &sts
@@ -40,10 +40,22 @@ my $buffer; # buffer for socket stuff
 my $conn_tries = 0; # number of connection tries. gives up after trying each
                     # server twice
 my $sock; # IO::Socket::INET object
+my $sock_ref = \$sock;
 my $freemessages = 4; # number of "free" privmsgs we can send. 0..$freemessages
 
 my $opts;
 
+my $silentmode_ref; 
+=head1 FUNCTION init_pkg
+    This function sets the references to
+	    options and players hashes.
+=over
+=item SCALAR (ref)  - reference to the options hash
+=item SCALAR (ref)  - reference to the players hash
+=cut
+sub init_pkg { $silentmode_ref = shift;}
+
+
 =head1 FUNCTION irc_connect
 	This function manage the connection to the irc server.
 =over
@@ -210,7 +222,7 @@ sub privmsg { # send a message to an arbitrary entity
     my $msg = shift or return undef;
     my $target = shift or return undef;
     my $force = shift;
-    if (($Irpg::Main::silentmode == 3 || ($target !~ /^[\+\&\#]/ && $Irpg::Main::silentmode == 2))
+    if (($$silentmode_ref == 3 || ($target !~ /^[\+\&\#]/ && $$silentmode_ref == 2))
         && !$force) {
         return undef;
     }
@@ -228,7 +240,7 @@ sub privmsg { # send a message to an arbitrary entity
 =cut
 sub chanmsg { # send a message to the channel
     my $msg = shift or return undef;
-    if ($Irpg::Main::silentmode & 1) { return undef; }
+    if ($$silentmode_ref & 1) { return undef; }
     privmsg($msg, $opts->{botchan}, shift);
 }
 
@@ -244,7 +256,7 @@ sub notice { # send a notice to an arbitrary entity
     my $msg = shift or return undef;
     my $target = shift or return undef;
     my $force = shift;
-    if (($Irpg::Main::silentmode == 3 || ($target !~ /^[\+\&\#]/ && $Irpg::Main::silentmode == 2))
+    if (($$silentmode_ref == 3 || ($target !~ /^[\+\&\#]/ && $$silentmode_ref == 2))
         && !$force) {
         return undef;
     }
diff --git a/Irpg/Main.pm b/Irpg/Main.pm
index 1c75a2f14c88494c94a86cb0ab348597272d3f92..10442e770f1b3c4518d32bd284b0ac5f32b264ee 100644
--- a/Irpg/Main.pm
+++ b/Irpg/Main.pm
@@ -52,6 +52,7 @@ my $auto_login;
 sub init_pkg {
 	($opts, $rps, $lasttime_ref, $prev_online, $auto_login) = @_;
 	$primnick = $opts->{botnick}; # for regain or register checks
+	Irpg::Irc::init_pkg(\$silentmode);
 	Irpg::Quest::init_pkg($opts, $rps);
 	Irpg::Fight::init_pkg($opts, $rps, \$primnick);
 	Irpg::Event::init_pkg($opts, $rps);
@@ -61,13 +62,13 @@ sub init_pkg {
 }
 
 sub pause_mode {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	$pausemode = $pausemode ? 0 : 1;
 	Irpg::Irc::privmsg("PAUSE_MODE set to $pausemode.",$usernick,1);
 }
 
 sub silent_mode {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($arg[0]) || $arg[0] < 0 || $arg[0] > 3) {
 		Irpg::Irc::privmsg("Try: SILENT <mode>", $usernick,1);
 	}
@@ -78,7 +79,7 @@ sub silent_mode {
 }
 
 sub reloaddb {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!$pausemode) {
 		Irpg::Irc::privmsg("ERROR: Can only use LOADDB while in PAUSE mode.",
 				$usernick, 1);
@@ -196,13 +197,14 @@ sub moveplayers {
     return unless $$lasttime_ref > 1;
     my $onlinecount = grep { $rps->{$_}{online} } keys %$rps;
     return unless $onlinecount;
-    for (my $i=0;$i<$rps->{self_clock};++$i) { # this is to simulate 1 move/s
+    for (my $i=0;$i<$opts->{self_clock};++$i) { # this is to simulate 1 move/s
         # temporary hash to hold player positions, detect collisions
 		my @questers = movequesters();
 		my %positions = ();
 		for my $player (keys(%$rps)) {
-			next unless $rps->{$player}{online};
-			next if (grep { $player eq $_ } @questers);
+			next unless ($rps->{$player}{online});
+			next if (!$questers[0] || grep { $player eq $_ } @questers);
+			#if (@questers) {next if (grep { $player eq $_ } @questers)};
 			$rps->{$player}{x} += int(rand(3))-1;
 			$rps->{$player}{y} += int(rand(3))-1;
 			# if player goes over edge, wrap them back around
@@ -444,7 +446,7 @@ sub parse {
                 while (@vnicks) {
                     Irpg::Irc::sts("MODE $opts->{botchan} +".
                         ('v' x $opts->{modesperline})." ".
-                        join(" ",@vnicks[0..$opts->{modesperline}-1]));
+                        join(" ",@vnicks[0..(@vnicks % $opts->{modesperline})-1]));
                     splice(@vnicks,0,$opts->{modesperline});
                 }
             }
@@ -503,8 +505,9 @@ sub parse {
 				if (exists $onchan{$usernick}) {
 					# the user is on the game chan
 					# we execute the command
+					# $arg[0] is userhost
 					# from $arg[4], it is the message content
-					$commands{$arg[3]}->{ref}($usernick, $username,
+					$commands{$arg[3]}->{ref}($arg[0], $usernick, $username,
 											  $source, @arg[4..$#arg]);
 				} else {
 					Irpg::Irc::notice("Sorry, you're not in $opts->{botchan}.",
diff --git a/Irpg/Quest.pm b/Irpg/Quest.pm
index 37a80ce838fbff49c34d54c9bf84312050f03e09..2ccd7c704d5d54a6e7b77935e451766b1efd0ebe 100644
--- a/Irpg/Quest.pm
+++ b/Irpg/Quest.pm
@@ -244,7 +244,7 @@ sub rpcheck {
 
 
 sub quest_info {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!@{$quest{questers}}) {
 		privmsg("There is no active quest.",$source);
 	}
diff --git a/Irpg/User.pm b/Irpg/User.pm
deleted file mode 100644
index 73cffec846899d1673e2269c1c3ef3606611a42c..0000000000000000000000000000000000000000
--- a/Irpg/User.pm
+++ /dev/null
@@ -1,3 +0,0 @@
-package Irpg::User;
-use strict;
-use warnings;
diff --git a/Irpg/Users.pm b/Irpg/Users.pm
index 31d070e24e6f82c67500a98f8eed77e320edb4ca..16e45e8984f7826bc30559265b59bc43ef1bc2f4 100644
--- a/Irpg/Users.pm
+++ b/Irpg/Users.pm
@@ -10,7 +10,7 @@ my $opts;
 my $rps;
 my $onchan;
 my ($primnick_ref, $lastreg_ref, $silentmode_ref, $pausemode_ref);
-=head1 FUNCTION init_hashes
+=head1 FUNCTION init_pkg
 	This function sets the references to
 	options and players hashes.
 =over
@@ -23,14 +23,14 @@ sub init_pkg {
 }
 
 sub register {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 
 	if (defined $username) {
 		Irpg::Irc::privmsg("Sorry, you are already online as $username.",
 				$usernick);
 	}
 	else {
-		if ($#arg < 3 || $arg[2] eq "") {
+		if ($#arg < 2 || $arg[2] eq "") {
 			Irpg::Irc::privmsg("Try: REGISTER <char name> <password> <class>",
 					$usernick);
 			Irpg::Irc::privmsg("IE : REGISTER Poseidon MyPassword M God of the ".
@@ -94,7 +94,7 @@ sub register {
 			$rps->{$arg[0]}{level} = 0;
 			$rps->{$arg[0]}{online} = 1;
 			$rps->{$arg[0]}{nick} = $usernick;
-			$rps->{$arg[0]}{userhost} = $arg[0];
+			$rps->{$arg[0]}{userhost} = $userhost;
 			$rps->{$arg[0]}{created} = time();
 			$rps->{$arg[0]}{lastlogin} = time();
 			$rps->{$arg[0]}{pass} = crypt($arg[1],mksalt());
@@ -129,8 +129,8 @@ sub register {
 
 
 sub chclass {
-	my ($usernick, $username, $source, @arg) = @_;
-	if ($#arg < 3) {
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
+	if ($#arg < 2) {
 		Irpg::Irc::privmsg("Try: CHCLASS <char name> <passwd> <new char class>",
 				$usernick, 1);
 	}
@@ -152,20 +152,20 @@ sub chclass {
 
 
 sub login {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (defined($username)) {
 		Irpg::Irc::notice("Sorry, you are already online as $username.",
 				$usernick);
 	}
 	else {
-		if ($#arg < 2 || $arg[1] eq "") {
+		if ($#arg < 1 || $arg[1] eq "") {
 			Irpg::Irc::notice("Try: LOGIN <username> <password>", $usernick);
 		}
 		elsif (!exists $rps->{$arg[0]}) {
 			Irpg::Irc::notice("Sorry, no such account name. Note that ".
 					"account names are case sensitive.",$usernick);
 		}
-		elsif (!exists $onchan->{$opts->{botchan}}{$usernick}) {
+		elsif (!exists $onchan->{$usernick}) {
 			Irpg::Irc::notice("Sorry, you're not in $opts->{botchan}.",
 					$usernick);
 		}
@@ -179,7 +179,7 @@ sub login {
 			}
 			$rps->{$arg[0]}{online} = 1;
 			$rps->{$arg[0]}{nick} = $usernick;
-			$rps->{$arg[0]}{userhost} = $arg[0];
+			$rps->{$arg[0]}{userhost} = $userhost;
 			$rps->{$arg[0]}{lastlogin} = time();
 			Irpg::Irc::chanmsg("$arg[0], the level $rps->{$arg[0]}{level} ".
 					"$rps->{$arg[0]}{class}, is now online from ".
@@ -192,7 +192,7 @@ sub login {
 }
 
 sub logout {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (defined($username)) {
         $rps->{$username}{online}=0;
 		penalize($username,"logout");
@@ -204,7 +204,7 @@ sub logout {
 
 sub status {
 	return unless ($opts->{statuscmd});
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($username)) {
 		Irpg::Irc::privmsg("You are not logged in.", $usernick);
 	}
@@ -235,7 +235,7 @@ sub status {
 }
 
 sub whoami {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($username)) {
 		Irpg::Irc::privmsg("You are not logged in.", $usernick);
 	}
@@ -248,7 +248,7 @@ sub whoami {
 }
 
 sub newpass {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($username)) {
 		Irpg::Irc::privmsg("You are not logged in.", $usernick)
 	}
@@ -262,7 +262,7 @@ sub newpass {
 }
 
 sub align {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($username)) {
 		Irpg::Irc::privmsg("You are not logged in.", $usernick)
 	}
@@ -280,7 +280,7 @@ sub align {
 }
 
 sub gender {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($username)) {
 		Irpg::Irc::privmsg("You are not logged in.", $usernick)
 	}
@@ -297,7 +297,7 @@ sub gender {
 }
 
 sub rmplayer {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if (!defined($username)) {
 		Irpg::Irc::privmsg("You are not logged in.", $usernick)
 	}
@@ -310,8 +310,7 @@ sub rmplayer {
 }
 
 sub help {
-	my ($usernick, $username, $source, @arg) = @_;
-	print "$source\n";
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	if ($source !~ /^#/ || !Irpg::Main::ha($usernick)) {
 		Irpg::Irc::privmsg("For information on IRPG bot commands, see ".
 				$opts->{helpurl}, $source);
@@ -324,12 +323,12 @@ sub help {
 }
 
 sub info {
-	my ($usernick, $username, $source, @arg) = @_;
+	my ($userhost, $usernick, $username, $source, @arg) = @_;
 	my $info;
 	if (!Irpg::Main::ha($usernick)) {
 		$info = "IRPG bot by ElTata, ".
 				"based on jotun's initial work.".
-				"https://gennuso.iiens.net/irpg. On via server: ".
+				"https://gennuso.iiens.net/irpg. On via: ".
 				$opts->{servers}->[0].". Admins online: ".
 				join(", ", map { $rps->{$_}{nick} }
 						  grep { $rps->{$_}{isadmin} &&
@@ -361,9 +360,6 @@ sub info {
 	}
 }
 
-
-	my ($usernick, $username, $source, @arg) = @_;
-
 our $commands = {
 	register => {ref => \&register,	adm => 0, prv => 1, pub => 0},
 	chclass	 => {ref => \&chclass,	adm => 0, prv => 1, pub => 0},
diff --git a/Irpg/Utils.pm b/Irpg/Utils.pm
index caf96a64611169707f1d333c63448745b16e46dd..458bb261433d2f0d8e502238220105a56a5ef8d2 100644
--- a/Irpg/Utils.pm
+++ b/Irpg/Utils.pm
@@ -179,12 +179,12 @@ sub daemonize {
 =cut
 sub readconfig {
 	my %opts;
-    if (! -e ".irpg.conf.dev") {
+    if (! -e ".irpg.conf") {
         debug("Error: Cannot find .irpg.conf. Copy it to this directory, ".
               "please.",\%opts,1);
     }
     else {
-        open(CONF,"<.irpg.conf.dev") or do {
+        open(CONF,"<.irpg.conf") or do {
             debug("Failed to open config file .irpg.conf: $!",\%opts,1);
         };
         my($line,$key,$val);
diff --git a/irpg_bot.pl b/irpg_bot.pl
index 6509c887f3deb822d596c41a114090146e97b1a0..50d40d29aef09dd37e1b2e22f8dcb9b97cf04482 100644
--- a/irpg_bot.pl
+++ b/irpg_bot.pl
@@ -142,8 +142,8 @@ my $lasttime = 1; # last time that rpcheck() was run
 
 $rps = createdb(\%opts) unless -e $opts{dbfile};
 
-#print "\n".debug("Becoming a daemon...")."\n";
-#daemonize(\%opts);
+print "\n".debug("Becoming a daemon...")."\n";
+daemonize(\%opts);
 
 $SIG{HUP} = "readconfig"; # sighup = reread config file