Index: irc.c
===================================================================
--- irc.c	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ irc.c	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -94,4 +94,6 @@
 	
 	b = irc->b = bee_new();
+	b->ui_data = irc;
+	b->ui = &irc_ui_funcs;
 	
 	s = set_add( &b->set, "away_devoice", "true", NULL/*set_eval_away_devoice*/, irc );
Index: irc.h
===================================================================
--- irc.h	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ irc.h	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -75,5 +75,4 @@
 	
 	struct query *queries;
-	struct account *accounts;
 	GSList *file_transfers;
 	
@@ -113,5 +112,5 @@
 	//int sendbuf_flags;
 	
-	//struct user *b;
+	struct bee_user *bu;
 	
 	const struct irc_user_funcs *f;
@@ -152,4 +151,6 @@
 	gboolean (*privmsg)( irc_channel_t *iu, const char *msg );
 };
+
+extern const struct bee_ui_funcs irc_ui_funcs;
 
 /* irc.c */
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ irc_commands.c	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -309,4 +309,11 @@
 }
 
+static void irc_cmd_nickserv( irc_t *irc, char **cmd )
+{
+	/* [SH] This aliases the NickServ command to PRIVMSG root */
+	/* [TV] This aliases the NS command to PRIVMSG root as well */
+	root_command( irc, cmd + 1 );
+}
+
 
 
@@ -516,11 +523,4 @@
 	
 	set_setstr( &irc->set, "away", u->away );
-}
-
-static void irc_cmd_nickserv( irc_t *irc, char **cmd )
-{
-	/* [SH] This aliases the NickServ command to PRIVMSG root */
-	/* [TV] This aliases the NS command to PRIVMSG root as well */
-	root_command( irc, cmd + 1 );
 }
 
@@ -578,4 +578,6 @@
 	{ "who",         0, irc_cmd_who,         IRC_CMD_LOGGED_IN },
 	{ "privmsg",     1, irc_cmd_privmsg,     IRC_CMD_LOGGED_IN },
+	{ "nickserv",    1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
+	{ "ns",          1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
 #if 0
 	{ "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
@@ -587,6 +589,4 @@
 	{ "topic",       1, irc_cmd_topic,       IRC_CMD_LOGGED_IN },
 	{ "away",        0, irc_cmd_away,        IRC_CMD_LOGGED_IN },
-	{ "nickserv",    1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
-	{ "ns",          1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
 	{ "version",     0, irc_cmd_version,     IRC_CMD_LOGGED_IN },
 	{ "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
Index: irc_im.c
===================================================================
--- irc_im.c	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ irc_im.c	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -26,6 +26,8 @@
 #include "bitlbee.h"
 
+
+/* IM->IRC callbacks */
+
 static const struct irc_user_funcs irc_user_im_funcs;
-static const struct bee_ui_funcs irc_ui_funcs;
 
 static gboolean bee_irc_user_new( bee_t *bee, bee_user_t *bu )
@@ -37,5 +39,6 @@
 	strcpy( nick, nick_get( bu->ic->acc, bu->handle ) );
 	
-	iu = irc_user_new( (irc_t*) bee->ui_data, nick );
+	bu->ui_data = iu = irc_user_new( (irc_t*) bee->ui_data, nick );
+	iu->bu = bu;
 	
 	if( ( s = strchr( bu->handle, '@' ) ) )
@@ -66,10 +69,32 @@
 }
 
+static gboolean bee_irc_user_free( bee_t *bee, bee_user_t *bu )
+{
+	return irc_user_free( bee->ui_data, bu->ui_data );
+}
+
+static gboolean bee_irc_user_status( bee_t *bee, bee_user_t *bu, bee_user_t *old )
+{
+	return TRUE;
+}
+
+const struct bee_ui_funcs irc_ui_funcs = {
+	bee_irc_user_new,
+	bee_irc_user_free,
+	bee_irc_user_status,
+};
 
 
-static const struct bee_ui_funcs irc_ui_funcs = {
-	bee_irc_user_new,
-};
+/* IRC->IM calls */
+
+static gboolean bee_irc_user_privmsg( irc_user_t *iu, const char *msg )
+{
+	if( iu->bu )
+		return bee_user_msg( iu->irc->b, iu->bu, msg, 0 );
+	else
+		return FALSE;
+}
 
 static const struct irc_user_funcs irc_user_im_funcs = {
+	bee_irc_user_privmsg,
 };
Index: protocols/bee.h
===================================================================
--- protocols/bee.h	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ protocols/bee.h	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -80,4 +80,16 @@
 int bee_user_free( bee_t *bee, struct im_connection *ic, const char *handle );
 bee_user_t *bee_user_by_handle( bee_t *bee, struct im_connection *ic, const char *handle );
+int bee_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, int flags );
+
+/* Callbacks from IM modules to core: */
+/* Buddy activity */
+/* To manipulate the status of a handle.
+ * - flags can be |='d with OPT_* constants. You will need at least:
+ *   OPT_LOGGED_IN and OPT_AWAY.
+ * - 'state' and 'message' can be NULL */
+G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
+/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
+/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
+G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at );
 
 #endif /* __BEE_H__ */
Index: protocols/bee_user.c
===================================================================
--- protocols/bee_user.c	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ protocols/bee_user.c	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -81,2 +81,186 @@
 	return NULL;
 }
+
+int bee_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, int flags )
+{
+	char *buf = NULL;
+	int st;
+	
+	if( ( bu->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+	{
+		buf = escape_html( msg );
+		msg = buf;
+	}
+	
+	st = bu->ic->acc->prpl->buddy_msg( bu->ic, bu->handle, msg, flags );
+	g_free( buf );
+	
+	return st;
+}
+
+
+/* IM->UI callbacks */
+void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message )
+{
+	bee_t *bee = ic->bee;
+	bee_user_t *bu, *old;
+	
+	if( !( bu = bee_user_by_handle( bee, ic, handle ) ) )
+	{
+		if( g_strcasecmp( set_getstr( &ic->bee->set, "handle_unknown" ), "add" ) == 0 )
+		{
+			bu = bee_user_new( bee, ic, handle );
+		}
+		else
+		{
+			if( set_getbool( &ic->bee->set, "debug" ) || g_strcasecmp( set_getstr( &ic->bee->set, "handle_unknown" ), "ignore" ) != 0 )
+			{
+				imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle );
+				imcb_log( ic, "flags = %d, state = %s, message = %s", flags,
+				          state ? state : "NULL", message ? message : "NULL" );
+			}
+			
+			return;
+		}
+	}
+	
+	/* May be nice to give the UI something to compare against. */
+	old = g_memdup( bu, sizeof( bee_user_t ) );
+	
+	/* TODO(wilmer): OPT_AWAY, or just state == NULL ? */
+	bu->flags = ( flags & OPT_LOGGED_IN ? BEE_USER_ONLINE : 0 ) |
+	            ( flags & OPT_AWAY ? BEE_USER_AWAY : 0 );
+	bu->status = g_strdup( ( flags & OPT_AWAY ) && state == NULL ? "Away" : state );
+	bu->status_msg = g_strdup( message );
+	
+	if( bee->ui->user_status )
+		bee->ui->user_status( bee, bu, old );
+	
+	g_free( old->status_msg );
+	g_free( old->status );
+	g_free( old );
+#if 0	
+	oa = u->away != NULL;
+	oo = u->online;
+	
+	g_free( u->away );
+	g_free( u->status_msg );
+	u->away = u->status_msg = NULL;
+	
+	if( ( flags & OPT_LOGGED_IN ) && !u->online )
+	{
+		irc_spawn( ic->irc, u );
+		u->online = 1;
+	}
+	else if( !( flags & OPT_LOGGED_IN ) && u->online )
+	{
+		struct groupchat *c;
+		
+		irc_kill( ic->irc, u );
+		u->online = 0;
+		
+		/* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
+		for( c = ic->groupchats; c; c = c->next )
+			remove_chat_buddy_silent( c, handle );
+	}
+	
+	if( flags & OPT_AWAY )
+	{
+		if( state && message )
+		{
+			u->away = g_strdup_printf( "%s (%s)", state, message );
+		}
+		else if( state )
+		{
+			u->away = g_strdup( state );
+		}
+		else if( message )
+		{
+			u->away = g_strdup( message );
+		}
+		else
+		{
+			u->away = g_strdup( "Away" );
+		}
+	}
+	else
+	{
+		u->status_msg = g_strdup( message );
+	}
+	
+	/* LISPy... */
+	if( ( set_getbool( &ic->bee->set, "away_devoice" ) ) &&		/* Don't do a thing when user doesn't want it */
+	    ( u->online ) &&						/* Don't touch offline people */
+	    ( ( ( u->online != oo ) && !u->away ) ||			/* Voice joining people */
+	      ( ( u->online == oo ) && ( oa == !u->away ) ) ) )		/* (De)voice people changing state */
+	{
+		char *from;
+		
+		if( set_getbool( &ic->bee->set, "simulate_netsplit" ) )
+		{
+			from = g_strdup( ic->irc->myhost );
+		}
+		else
+		{
+			from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick,
+			                                    ic->irc->myhost );
+		}
+		irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
+		                                          u->away?'-':'+', u->nick );
+		g_free( from );
+	}
+#endif
+}
+
+void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at )
+{
+#if 0
+	bee_t *bee = ic->bee;
+	char *wrapped;
+	user_t *u;
+	
+	u = user_findhandle( ic, handle );
+	
+	if( !u )
+	{
+		char *h = set_getstr( &bee->set, "handle_unknown" );
+		
+		if( g_strcasecmp( h, "ignore" ) == 0 )
+		{
+			if( set_getbool( &bee->set, "debug" ) )
+				imcb_log( ic, "Ignoring message from unknown handle %s", handle );
+			
+			return;
+		}
+		else if( g_strncasecmp( h, "add", 3 ) == 0 )
+		{
+			int private = set_getbool( &bee->set, "private" );
+			
+			if( h[3] )
+			{
+				if( g_strcasecmp( h + 3, "_private" ) == 0 )
+					private = 1;
+				else if( g_strcasecmp( h + 3, "_channel" ) == 0 )
+					private = 0;
+			}
+			
+			imcb_add_buddy( ic, handle, NULL );
+			u = user_findhandle( ic, handle );
+			u->is_private = private;
+		}
+		else
+		{
+			imcb_log( ic, "Message from unknown handle %s:", handle );
+			u = user_find( irc, irc->mynick );
+		}
+	}
+	
+	if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
+	    ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
+		strip_html( msg );
+
+	wrapped = word_wrap( msg, 425 );
+	irc_msgfrom( irc, u->nick, wrapped );
+	g_free( wrapped );
+#endif
+}
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ protocols/nogaim.c	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -546,169 +546,4 @@
 	data->handle = g_strdup( handle );
 	query_add( ic->irc, ic, s, imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data );
-#endif
-}
-
-void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message )
-{
-	bee_t *bee = ic->bee;
-	bee_user_t *bu, *old;
-	
-	if( !( bu = bee_user_by_handle( bee, ic, handle ) ) )
-	{
-		if( g_strcasecmp( set_getstr( &ic->bee->set, "handle_unknown" ), "add" ) == 0 )
-		{
-			bu = bee_user_new( bee, ic, handle );
-		}
-		else
-		{
-			if( set_getbool( &ic->bee->set, "debug" ) || g_strcasecmp( set_getstr( &ic->bee->set, "handle_unknown" ), "ignore" ) != 0 )
-			{
-				imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle );
-				imcb_log( ic, "flags = %d, state = %s, message = %s", flags,
-				          state ? state : "NULL", message ? message : "NULL" );
-			}
-			
-			return;
-		}
-	}
-	
-	/* May be nice to give the UI something to compare against. */
-	old = g_memdup( bu, sizeof( bee_user_t ) );
-	
-	/* TODO(wilmer): OPT_AWAY, or just state == NULL ? */
-	bu->flags = ( flags & OPT_LOGGED_IN ? BEE_USER_ONLINE : 0 ) |
-	            ( flags & OPT_AWAY ? BEE_USER_AWAY : 0 );
-	bu->status = g_strdup( ( flags & OPT_AWAY ) && state == NULL ? "Away" : state );
-	bu->status_msg = g_strdup( message );
-	
-	if( bee->ui->user_status )
-		bee->ui->user_status( bee, bu, old );
-	
-	g_free( old->status_msg );
-	g_free( old->status );
-	g_free( old );
-#if 0	
-	oa = u->away != NULL;
-	oo = u->online;
-	
-	g_free( u->away );
-	g_free( u->status_msg );
-	u->away = u->status_msg = NULL;
-	
-	if( ( flags & OPT_LOGGED_IN ) && !u->online )
-	{
-		irc_spawn( ic->irc, u );
-		u->online = 1;
-	}
-	else if( !( flags & OPT_LOGGED_IN ) && u->online )
-	{
-		struct groupchat *c;
-		
-		irc_kill( ic->irc, u );
-		u->online = 0;
-		
-		/* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
-		for( c = ic->groupchats; c; c = c->next )
-			remove_chat_buddy_silent( c, handle );
-	}
-	
-	if( flags & OPT_AWAY )
-	{
-		if( state && message )
-		{
-			u->away = g_strdup_printf( "%s (%s)", state, message );
-		}
-		else if( state )
-		{
-			u->away = g_strdup( state );
-		}
-		else if( message )
-		{
-			u->away = g_strdup( message );
-		}
-		else
-		{
-			u->away = g_strdup( "Away" );
-		}
-	}
-	else
-	{
-		u->status_msg = g_strdup( message );
-	}
-	
-	/* LISPy... */
-	if( ( set_getbool( &ic->bee->set, "away_devoice" ) ) &&		/* Don't do a thing when user doesn't want it */
-	    ( u->online ) &&						/* Don't touch offline people */
-	    ( ( ( u->online != oo ) && !u->away ) ||			/* Voice joining people */
-	      ( ( u->online == oo ) && ( oa == !u->away ) ) ) )		/* (De)voice people changing state */
-	{
-		char *from;
-		
-		if( set_getbool( &ic->bee->set, "simulate_netsplit" ) )
-		{
-			from = g_strdup( ic->irc->myhost );
-		}
-		else
-		{
-			from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick,
-			                                    ic->irc->myhost );
-		}
-		irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
-		                                          u->away?'-':'+', u->nick );
-		g_free( from );
-	}
-#endif
-}
-
-void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at )
-{
-#if 0
-	bee_t *bee = ic->bee;
-	char *wrapped;
-	user_t *u;
-	
-	u = user_findhandle( ic, handle );
-	
-	if( !u )
-	{
-		char *h = set_getstr( &bee->set, "handle_unknown" );
-		
-		if( g_strcasecmp( h, "ignore" ) == 0 )
-		{
-			if( set_getbool( &bee->set, "debug" ) )
-				imcb_log( ic, "Ignoring message from unknown handle %s", handle );
-			
-			return;
-		}
-		else if( g_strncasecmp( h, "add", 3 ) == 0 )
-		{
-			int private = set_getbool( &bee->set, "private" );
-			
-			if( h[3] )
-			{
-				if( g_strcasecmp( h + 3, "_private" ) == 0 )
-					private = 1;
-				else if( g_strcasecmp( h + 3, "_channel" ) == 0 )
-					private = 0;
-			}
-			
-			imcb_add_buddy( ic, handle, NULL );
-			u = user_findhandle( ic, handle );
-			u->is_private = private;
-		}
-		else
-		{
-			imcb_log( ic, "Message from unknown handle %s:", handle );
-			u = user_find( irc, irc->mynick );
-		}
-	}
-	
-	if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
-	    ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
-		strip_html( msg );
-
-	wrapped = word_wrap( msg, 425 );
-	irc_msgfrom( irc, u->nick, wrapped );
-	g_free( wrapped );
 #endif
 }
@@ -1035,21 +870,4 @@
    them all from some wrappers. We'll start to define some down here: */
 
-int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags )
-{
-	char *buf = NULL;
-	int st;
-	
-	if( ( ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
-	{
-		buf = escape_html( msg );
-		msg = buf;
-	}
-	
-	st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags );
-	g_free( buf );
-	
-	return st;
-}
-
 int imc_chat_msg( struct groupchat *c, char *msg, int flags )
 {
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ protocols/nogaim.h	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -2,5 +2,5 @@
   * BitlBee -- An IRC to other IM-networks gateway                     *
   *                                                                    *
-  * Copyright 2002-2004 Wilmer van der Gaast and others                *
+  * Copyright 2002-2010 Wilmer van der Gaast and others                *
   \********************************************************************/
 
@@ -286,14 +286,6 @@
 G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick );
 
-/* Buddy activity */
-/* To manipulate the status of a handle.
- * - flags can be |='d with OPT_* constants. You will need at least:
- *   OPT_LOGGED_IN and OPT_AWAY.
- * - 'state' and 'message' can be NULL */
-G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
-/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
-/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
-G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at );
 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags );
+G_MODULE_EXPORT struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *handle );
 G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle );
 
@@ -320,5 +312,4 @@
 /* Actions, or whatever. */
 int imc_away_send_update( struct im_connection *ic );
-int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
 int imc_chat_msg( struct groupchat *c, char *msg, int flags );
 
Index: root_commands.c
===================================================================
--- root_commands.c	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ root_commands.c	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -221,4 +221,5 @@
 	}
 }
+#endif
 
 struct cmd_account_del_data
@@ -233,5 +234,5 @@
 	account_t *a;
 	
-	for( a = cad->irc->accounts; a && a != cad->a; a = a->next );
+	for( a = cad->irc->b->accounts; a && a != cad->a; a = a->next );
 	
 	if( a == NULL )
@@ -245,5 +246,5 @@
 	else
 	{
-		account_del( cad->irc, a );
+		account_del( cad->irc->b, a );
 		irc_usermsg( cad->irc, "Account deleted" );
 	}
@@ -286,5 +287,5 @@
 		set_name = set_full;
 		
-		head = &irc->set;
+		head = &irc->b->set;
 	}
 	else 
@@ -357,5 +358,5 @@
 	account_t *a;
 	
-	if( ( a = account_get( irc, id ) ) )
+	if( ( a = account_get( irc->b, id ) ) )
 		return &a->set;
 	else
@@ -405,5 +406,5 @@
 		}
 
-		a = account_add( irc, prpl, cmd[3], cmd[4] );
+		a = account_add( irc->b, prpl, cmd[3], cmd[4] );
 		if( cmd[5] )
 		{
@@ -419,5 +420,5 @@
 		MIN_ARGS( 2 );
 
-		if( !( a = account_get( irc, cmd[2] ) ) )
+		if( !( a = account_get( irc->b, cmd[2] ) ) )
 		{
 			irc_usermsg( irc, "Invalid account" );
@@ -441,5 +442,5 @@
 			                       "set' command. Are you sure you want to delete this "
 			                       "account?", a->prpl->name, a->user );
-			query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad );
+			//query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad );
 			g_free( msg );
 		}
@@ -452,5 +453,5 @@
 			irc_usermsg( irc, "Account list:" );
 		
-		for( a = irc->accounts; a; a = a->next )
+		for( a = irc->b->accounts; a; a = a->next )
 		{
 			char *con;
@@ -475,5 +476,5 @@
 		if( cmd[2] )
 		{
-			if( ( a = account_get( irc, cmd[2] ) ) )
+			if( ( a = account_get( irc->b, cmd[2] ) ) )
 			{
 				if( a->ic )
@@ -484,5 +485,5 @@
 				else
 				{
-					account_on( irc, a );
+					account_on( irc->b, a );
 				}
 			}
@@ -495,10 +496,11 @@
 		else
 		{
-			if ( irc->accounts ) {
+			if ( irc->b->accounts )
+			{
 				irc_usermsg( irc, "Trying to get all accounts connected..." );
 			
-				for( a = irc->accounts; a; a = a->next )
+				for( a = irc->b->accounts; a; a = a->next )
 					if( !a->ic && a->auto_connect )
-						account_on( irc, a );
+						account_on( irc->b, a );
 			} 
 			else
@@ -514,17 +516,17 @@
 			irc_usermsg( irc, "Deactivating all active (re)connections..." );
 			
-			for( a = irc->accounts; a; a = a->next )
+			for( a = irc->b->accounts; a; a = a->next )
 			{
 				if( a->ic )
-					account_off( irc, a );
+					account_off( irc->b, a );
 				else if( a->reconnect )
 					cancel_auto_reconnect( a );
 			}
 		}
-		else if( ( a = account_get( irc, cmd[2] ) ) )
+		else if( ( a = account_get( irc->b, cmd[2] ) ) )
 		{
 			if( a->ic )
 			{
-				account_off( irc, a );
+				account_off( irc->b, a );
 			}
 			else if( a->reconnect )
@@ -557,4 +559,5 @@
 }
 
+#if 0
 static void cmd_add( irc_t *irc, char **cmd )
 {
@@ -1222,9 +1225,9 @@
 const command_t commands[] = {
 	{ "help",           0, cmd_help,           0 }, 
+	{ "account",        1, cmd_account,        0 },
 #if 0
 	{ "identify",       1, cmd_identify,       0 },
 	{ "register",       1, cmd_register,       0 },
 	{ "drop",           1, cmd_drop,           0 },
-	{ "account",        1, cmd_account,        0 },
 	{ "add",            2, cmd_add,            0 },
 	{ "info",           1, cmd_info,           0 },
Index: unix.c
===================================================================
--- unix.c	(revision 81e04e162bdc4517b2f357fd16dfd76f68245464)
+++ unix.c	(revision d860a8ddf5039f7208bff4c179bc9fe1549da6da)
@@ -62,5 +62,5 @@
 	
 	b_main_init();
-	//nogaim_init();
+	nogaim_init();
 	
 	srand( time( NULL ) ^ getpid() );
