Index: protocols/jabber/conference.c
===================================================================
--- protocols/jabber/conference.c	(revision 1fdb0a48438d6dc4a4795d195737890ed3e46a96)
+++ protocols/jabber/conference.c	(revision 4aa0f6bc5645e124738ab15ad1eb65d4147dba25)
@@ -92,9 +92,11 @@
 {
 	char *normalized = jabber_normalize( name );
+	GSList *l;
 	struct groupchat *ret;
 	struct jabber_chat *jc;
 	
-	for( ret = ic->groupchats; ret; ret = ret->next )
-	{
+	for( l = ic->groupchats; l; l = l->next )
+	{
+		ret = l->data;
 		jc = ret->data;
 		if( strcmp( normalized, jc->name ) == 0 )
@@ -103,5 +105,5 @@
 	g_free( normalized );
 	
-	return ret;
+	return l ? ret : NULL;
 }
 
Index: protocols/jabber/iq.c
===================================================================
--- protocols/jabber/iq.c	(revision 1fdb0a48438d6dc4a4795d195737890ed3e46a96)
+++ protocols/jabber/iq.c	(revision 4aa0f6bc5645e124738ab15ad1eb65d4147dba25)
@@ -382,5 +382,5 @@
 	while( ( c = xt_find_node( c, "item" ) ) )
 	{
-		struct xt_node *group = xt_find_node( node->children, "group" );
+		struct xt_node *group = xt_find_node( c->children, "group" );
 		char *jid = xt_find_attr( c, "jid" );
 		char *name = xt_find_attr( c, "name" );
@@ -391,7 +391,6 @@
 			if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
 			{
-				if( initial || imcb_find_buddy( ic, jid ) == NULL )
-					imcb_add_buddy( ic, jid, ( group && group->text_len ) ?
-					                           group->text : NULL );
+				imcb_add_buddy( ic, jid, ( group && group->text_len ) ?
+				                           group->text : NULL );
 				
 				if( name )
@@ -589,5 +588,5 @@
 	    strcmp( s, "result" ) == 0 )
 	{
-		if( imcb_find_buddy( ic, jid ) == NULL )
+		if( bee_user_by_handle( ic->bee, ic, jid ) == NULL )
 			imcb_add_buddy( ic, jid, NULL );
 	}
Index: protocols/jabber/jabber.c
===================================================================
--- protocols/jabber/jabber.c	(revision 1fdb0a48438d6dc4a4795d195737890ed3e46a96)
+++ protocols/jabber/jabber.c	(revision 4aa0f6bc5645e124738ab15ad1eb65d4147dba25)
@@ -267,5 +267,5 @@
 	
 	while( jd->filetransfers )
-		imcb_file_canceled( ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" );
+		imcb_file_canceled( ic, ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" );
 
 	while( jd->streamhosts )
@@ -282,5 +282,5 @@
 	
 	while( ic->groupchats )
-		jabber_chat_free( ic->groupchats );
+		jabber_chat_free( ic->groupchats->data );
 	
 	if( jd->r_inpa >= 0 )
Index: protocols/jabber/jabber_util.c
===================================================================
--- protocols/jabber/jabber_util.c	(revision 1fdb0a48438d6dc4a4795d195737890ed3e46a96)
+++ protocols/jabber/jabber_util.c	(revision 4aa0f6bc5645e124738ab15ad1eb65d4147dba25)
@@ -279,6 +279,5 @@
 	presence_send_request( bla->ic, bla->handle, "subscribed" );
 	
-	if( imcb_find_buddy( bla->ic, bla->handle ) == NULL )
-		imcb_ask_add( bla->ic, bla->handle, NULL );
+	imcb_ask_add( bla->ic, bla->handle, NULL );
 	
 	g_free( bla->handle );
@@ -462,5 +461,5 @@
 		
 		if( bud == NULL && ( flags & GET_BUDDY_CREAT ) &&
-		    ( bare_exists || imcb_find_buddy( ic, jid ) ) )
+		    ( bare_exists || bee_user_by_handle( ic->bee, ic, jid ) ) )
 		{
 			*s = '/';
@@ -483,5 +482,6 @@
 		if( bud == NULL )
 			/* No match. Create it now? */
-			return ( ( flags & GET_BUDDY_CREAT ) && imcb_find_buddy( ic, jid_ ) ) ?
+			return ( ( flags & GET_BUDDY_CREAT ) &&
+			         bee_user_by_handle( ic->bee, ic, jid_ ) ) ?
 			           jabber_buddy_add( ic, jid_ ) : NULL;
 		else if( bud->resource && ( flags & GET_BUDDY_EXACT ) )
Index: protocols/jabber/presence.c
===================================================================
--- protocols/jabber/presence.c	(revision 1fdb0a48438d6dc4a4795d195737890ed3e46a96)
+++ protocols/jabber/presence.c	(revision 4aa0f6bc5645e124738ab15ad1eb65d4147dba25)
@@ -205,5 +205,5 @@
 	struct jabber_data *jd = ic->proto_data;
 	struct xt_node *node, *cap;
-	struct groupchat *c;
+	GSList *l;
 	int st;
 	
@@ -229,6 +229,7 @@
 	/* Have to send this update to all groupchats too, the server won't
 	   do this automatically. */
-	for( c = ic->groupchats; c && st; c = c->next )
-	{
+	for( l = ic->groupchats; l && st; l = l->next )
+	{
+		struct groupchat *c = l->data;
 		struct jabber_chat *jc = c->data;
 		
Index: protocols/jabber/s5bytestream.c
===================================================================
--- protocols/jabber/s5bytestream.c	(revision 1fdb0a48438d6dc4a4795d195737890ed3e46a96)
+++ protocols/jabber/s5bytestream.c	(revision 4aa0f6bc5645e124738ab15ad1eb65d4147dba25)
@@ -567,5 +567,5 @@
 	xt_free_node( reply );
 
-	imcb_file_canceled( tf->ft, "couldn't connect to any streamhosts" );
+	imcb_file_canceled( tf->ic, tf->ft, "couldn't connect to any streamhosts" );
 
 	bt->tf->watch_in = 0;
@@ -604,5 +604,5 @@
 		
 	if( !jabber_write_packet( tf->ic, reply ) )
-		imcb_file_canceled( tf->ft, "Error transmitting bytestream response" );
+		imcb_file_canceled( tf->ic, tf->ft, "Error transmitting bytestream response" );
 	xt_free_node( reply );
 }
@@ -644,5 +644,5 @@
 
 	if( tf->bytesread >= tf->ft->file_size )
-		imcb_file_finished( tf->ft );
+		imcb_file_finished( tf->ic, tf->ft );
 
 	tf->ft->write( tf->ft, tf->ft->buffer, ret );	
@@ -660,5 +660,5 @@
 	if( tf->watch_in )
 	{
-		imcb_file_canceled( ft, "BUG in jabber file transfer: write_request called when already watching for input" );
+		imcb_file_canceled( tf->ic, ft, "BUG in jabber file transfer: write_request called when already watching for input" );
 		return FALSE;
 	}
@@ -706,5 +706,5 @@
 
 	if( tf->byteswritten >= ft->file_size )
-		imcb_file_finished( ft );
+		imcb_file_finished( tf->ic, ft );
 	else
 		bt->tf->watch_out = b_input_add( tf->fd, B_EV_IO_WRITE, jabber_bs_send_can_write, bt );
@@ -1006,5 +1006,5 @@
 
 	if( !jabber_write_packet( tf->ic, iq ) )
-		imcb_file_canceled( tf->ft, "Error transmitting bytestream request" );
+		imcb_file_canceled( tf->ic, tf->ft, "Error transmitting bytestream request" );
 	return TRUE;
 }
@@ -1021,5 +1021,5 @@
 
 	if( jd->streamhosts==NULL ) /* we're done here unless we have a proxy to try */
-		imcb_file_canceled( tf->ft, error );
+		imcb_file_canceled( tf->ic, tf->ft, error );
 
 	/* MUST always return FALSE! */
Index: protocols/jabber/si.c
===================================================================
--- protocols/jabber/si.c	(revision 1fdb0a48438d6dc4a4795d195737890ed3e46a96)
+++ protocols/jabber/si.c	(revision 4aa0f6bc5645e124738ab15ad1eb65d4147dba25)
@@ -91,9 +91,9 @@
 
 	if( !foundft )
-		imcb_file_canceled( tf->ft, "Buddy's client doesn't feature file transfers" );
+		imcb_file_canceled( tf->ic, tf->ft, "Buddy's client doesn't feature file transfers" );
 	else if( !foundbt )
-		imcb_file_canceled( tf->ft, "Buddy's client doesn't feature byte streams (required)" );
+		imcb_file_canceled( tf->ic, tf->ft, "Buddy's client doesn't feature byte streams (required)" );
 	else if( !foundsi )
-		imcb_file_canceled( tf->ft, "Buddy's client doesn't feature stream initiation (required)" );
+		imcb_file_canceled( tf->ic, tf->ft, "Buddy's client doesn't feature stream initiation (required)" );
 		
 	return foundft && foundbt && foundsi;
@@ -109,5 +109,5 @@
 
 	/* and start the receive logic */
-	imcb_file_recv_start( tf->ft );
+	imcb_file_recv_start( tf->ic, tf->ft );
 
 }
@@ -156,5 +156,5 @@
 	if( bud == NULL )
 	{
-		imcb_file_canceled( ft, "Couldn't find buddy (BUG?)" );
+		imcb_file_canceled( ic, ft, "Couldn't find buddy (BUG?)" );
 		return;
 	}
