Index: irc.c
===================================================================
--- irc.c	(revision 63a520b8ce1776442f2f79528ddd23fb0de51f94)
+++ irc.c	(revision b95932eb5a897fd264f3762493285dd7037dccba)
@@ -594,8 +594,7 @@
 			irc->user = irc_user_new( irc, iu->nick );
 			irc->user->user = iu->user;
+			irc->user->host = iu->host;
 			irc->user->fullname = iu->fullname;
-			g_free( iu->fullname );
 			g_free( iu->nick );
-			g_free( iu->host );
 			g_free( iu );
 			
Index: irc.h
===================================================================
--- irc.h	(revision 63a520b8ce1776442f2f79528ddd23fb0de51f94)
+++ irc.h	(revision b95932eb5a897fd264f3762493285dd7037dccba)
@@ -87,4 +87,6 @@
 typedef struct irc_user
 {
+	irc_t *irc;
+	
 	char *nick;
 	char *user;
@@ -159,4 +161,5 @@
 void irc_send_names( irc_channel_t *ic );
 void irc_send_topic( irc_channel_t *ic );
+void irc_send_whois( irc_user_t *iu );
 
 /* irc_user.c */
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision 63a520b8ce1776442f2f79528ddd23fb0de51f94)
+++ irc_commands.c	(revision b95932eb5a897fd264f3762493285dd7037dccba)
@@ -155,4 +155,26 @@
 		irc_send_num( irc, 442, "%s :You're not on that channel", cmd[1] );
 	}
+}
+
+static void irc_cmd_whois( irc_t *irc, char **cmd )
+{
+	char *nick = cmd[1];
+	irc_user_t *iu = irc_user_find( irc, nick );
+	
+	if( iu )
+		irc_send_whois( iu );
+	else
+		irc_send_num( irc, 401, "%s :Nick does not exist", nick );
+}
+
+static void irc_cmd_whowas( irc_t *irc, char **cmd )
+{
+	/* For some reason irssi tries a whowas when whois fails. We can
+	   ignore this, but then the user never gets a "user not found"
+	   message from irssi which is a bit annoying. So just respond
+	   with not-found and irssi users will get better error messages */
+	
+	irc_send_num( irc, 406, "%s :Nick does not exist", cmd[1] );
+	irc_send_num( irc, 369, "%s :End of WHOWAS", cmd[1] );
 }
 
@@ -475,46 +497,4 @@
 }
 
-static void irc_cmd_whois( irc_t *irc, char **cmd )
-{
-	char *nick = cmd[1];
-	user_t *u = user_find( irc, nick );
-	
-	if( u )
-	{
-		irc_send_num( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname );
-		
-		if( u->ic )
-			irc_send_num( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user,
-			           u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "",
-			           u->ic->acc->prpl->name );
-		else
-			irc_send_num( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO );
-		
-		if( !u->online )
-			irc_send_num( irc, 301, "%s :%s", u->nick, "User is offline" );
-		else if( u->away )
-			irc_send_num( irc, 301, "%s :%s", u->nick, u->away );
-		if( u->status_msg )
-			irc_send_num( irc, 333, "%s :Status: %s", u->nick, u->status_msg );
-		
-		irc_send_num( irc, 318, "%s :End of /WHOIS list", nick );
-	}
-	else
-	{
-		irc_send_num( irc, 401, "%s :Nick does not exist", nick );
-	}
-}
-
-static void irc_cmd_whowas( irc_t *irc, char **cmd )
-{
-	/* For some reason irssi tries a whowas when whois fails. We can
-	   ignore this, but then the user never gets a "user not found"
-	   message from irssi which is a bit annoying. So just respond
-	   with not-found and irssi users will get better error messages */
-	
-	irc_send_num( irc, 406, "%s :Nick does not exist", cmd[1] );
-	irc_send_num( irc, 369, "%s :End of WHOWAS", cmd[1] );
-}
-
 static void irc_cmd_nickserv( irc_t *irc, char **cmd )
 {
@@ -583,4 +563,6 @@
 	{ "names",       1, irc_cmd_names,       IRC_CMD_LOGGED_IN },
 	{ "part",        1, irc_cmd_part,        IRC_CMD_LOGGED_IN },
+	{ "whois",       1, irc_cmd_whois,       IRC_CMD_LOGGED_IN },
+	{ "whowas",      1, irc_cmd_whowas,      IRC_CMD_LOGGED_IN },
 #if 0
 	{ "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
@@ -595,6 +577,4 @@
 	{ "topic",       1, irc_cmd_topic,       IRC_CMD_LOGGED_IN },
 	{ "away",        0, irc_cmd_away,        IRC_CMD_LOGGED_IN },
-	{ "whois",       1, irc_cmd_whois,       IRC_CMD_LOGGED_IN },
-	{ "whowas",      1, irc_cmd_whowas,      IRC_CMD_LOGGED_IN },
 	{ "nickserv",    1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
 	{ "ns",          1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
Index: irc_send.c
===================================================================
--- irc_send.c	(revision 63a520b8ce1776442f2f79528ddd23fb0de51f94)
+++ irc_send.c	(revision b95932eb5a897fd264f3762493285dd7037dccba)
@@ -189,2 +189,28 @@
 		irc_send_num( ic->irc, 331, "%s :No topic for this channel", ic->name );
 }
+
+void irc_send_whois( irc_user_t *iu )
+{
+	irc_t *irc = iu->irc;
+	
+	irc_send_num( irc, 311, "%s %s %s * :%s",
+	              iu->nick, iu->user, iu->host, iu->fullname );
+	
+	/*
+	if( u->ic )
+		irc_send_num( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user,
+		           u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "",
+		           u->ic->acc->prpl->name );
+	else
+		irc_send_num( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO );
+	*/
+	
+	/*
+	if( u->away )
+		irc_send_num( irc, 301, "%s :%s", u->nick, u->away );
+	if( u->status_msg )
+		irc_send_num( irc, 333, "%s :Status: %s", u->nick, u->status_msg );
+	*/
+	
+	irc_send_num( irc, 318, "%s :End of /WHOIS list", iu->nick );
+}
Index: irc_user.c
===================================================================
--- irc_user.c	(revision 63a520b8ce1776442f2f79528ddd23fb0de51f94)
+++ irc_user.c	(revision b95932eb5a897fd264f3762493285dd7037dccba)
@@ -30,4 +30,5 @@
 	irc_user_t *iu = g_new0( irc_user_t, 1 );
 	
+	iu->irc = irc;
 	iu->nick = g_strdup( nick );
 	iu->user = iu->host = iu->fullname = iu->nick;
