Index: bitlbee.c
===================================================================
--- bitlbee.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ bitlbee.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -34,5 +34,5 @@
 #include <errno.h>
 
-void bitlbee_io_new_client( gpointer data, gint source, GaimInputCondition condition );
+static gboolean bitlbee_io_new_client( gpointer data, gint source, b_input_condition condition );
 
 int bitlbee_daemon_init()
@@ -90,5 +90,5 @@
 	}
 	
-	global.listen_watch_source_id = gaim_input_add( global.listen_socket, GAIM_INPUT_READ, bitlbee_io_new_client, NULL );
+	global.listen_watch_source_id = b_input_add( global.listen_socket, GAIM_INPUT_READ, bitlbee_io_new_client, NULL );
 	
 #ifndef _WIN32
@@ -145,5 +145,5 @@
 }
 
-void bitlbee_io_current_client_read( gpointer data, gint source, GaimInputCondition cond )
+gboolean bitlbee_io_current_client_read( gpointer data, gint source, b_input_condition cond )
 {
 	irc_t *irc = data;
@@ -155,5 +155,5 @@
 	{
 		irc_abort( irc, 1, "Connection reset by peer" );
-		goto no_more_events;
+		return FALSE;
 	}
 	else if( st < 0 )
@@ -161,10 +161,10 @@
 		if( sockerr_again() )
 		{
-			return;
+			return TRUE;
 		}
 		else
 		{
 			irc_abort( irc, 1, "Read error: %s", strerror( errno ) );
-			goto no_more_events;
+			return FALSE;
 		}
 	}
@@ -187,5 +187,5 @@
 	{
 		log_message( LOGLVL_WARNING, "Abnormal termination of connection with fd %d.", irc->fd );
-		goto no_more_events;
+		return FALSE;
 	} 
 	
@@ -194,15 +194,11 @@
 	{
 		irc_abort( irc, 0, "Maximum line length exceeded" );
-		goto no_more_events;
-	}
-	
-	return;
-	
-no_more_events:
-	gaim_input_remove( irc->r_watch_source_id );
-	irc->r_watch_source_id = 0;
-}
-
-void bitlbee_io_current_client_write( gpointer data, gint source, GaimInputCondition cond )
+		return FALSE;
+	}
+	
+	return TRUE;
+}
+
+gboolean bitlbee_io_current_client_write( gpointer data, gint source, b_input_condition cond )
 {
 	irc_t *irc = data;
@@ -211,5 +207,5 @@
 
 	if( irc->sendbuffer == NULL )
-		goto no_more_events;
+		return FALSE;
 	
 	size = strlen( irc->sendbuffer );
@@ -219,9 +215,9 @@
 	{
 		irc_abort( irc, 1, "Write error: %s", strerror( errno ) );
-		goto no_more_events;
+		return FALSE;
 	}
 	else if( st < 0 ) /* && sockerr_again() */
 	{
-		return;
+		return TRUE;
 	}
 	
@@ -230,9 +226,10 @@
 		g_free( irc->sendbuffer );
 		irc->sendbuffer = NULL;
+		irc->w_watch_source_id = 0;
 		
 		if( irc->status == USTATUS_SHUTDOWN )
 			irc_free( irc );
 		
-		goto no_more_events;
+		return FALSE;
 	}
 	else
@@ -242,13 +239,9 @@
 		irc->sendbuffer = temp;
 		
-		return;
-	}
-	
-no_more_events:
-	gaim_input_remove( irc->w_watch_source_id );
-	irc->w_watch_source_id = 0;
-}
-
-void bitlbee_io_new_client( gpointer data, gint source, GaimInputCondition condition )
+		return TRUE;
+	}
+}
+
+static gboolean bitlbee_io_new_client( gpointer data, gint source, b_input_condition condition )
 {
 	socklen_t size = sizeof( struct sockaddr_in );
@@ -260,5 +253,5 @@
 	{
 		log_message( LOGLVL_WARNING, "Could not accept new connection: %s", strerror( errno ) );
-		return;
+		return TRUE;
 	}
 	
@@ -285,5 +278,5 @@
 			child->pid = client_pid;
 			child->ipc_fd = fds[0];
-			child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
+			child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
 			child_list = g_slist_append( child_list, child );
 			
@@ -300,5 +293,5 @@
 			/* Close the listening socket, we're a client. */
 			close( global.listen_socket );
-			g_source_remove( global.listen_watch_source_id );
+			b_event_remove( global.listen_watch_source_id );
 			
 			/* Make the connection. */
@@ -307,5 +300,5 @@
 			/* We can store the IPC fd there now. */
 			global.listen_socket = fds[1];
-			global.listen_watch_source_id = gaim_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc );
+			global.listen_watch_source_id = b_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc );
 			
 			close( fds[0] );
@@ -319,7 +312,9 @@
 		irc_new( new_socket );
 	}
-}
-
-void bitlbee_shutdown( gpointer data )
+	
+	return TRUE;
+}
+
+gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond )
 {
 	/* Try to save data for all active connections (if desired). */
@@ -328,4 +323,6 @@
 	
 	/* We'll only reach this point when not running in inetd mode: */
-	g_main_quit( global.loop );
-}
+	b_main_quit();
+	
+	return FALSE;
+}
Index: bitlbee.h
===================================================================
--- bitlbee.h	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ bitlbee.h	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -82,6 +82,10 @@
 #undef g_timeout_add_full
 #define g_timeout_add_full	__PLEASE_USE_B_TIMEOUT_ADD__
+#undef g_io_add_watch
+#define g_io_add_watch		__PLEASE_USE_B_INPUT_ADD__
+#undef g_io_add_watch_full
+#define g_io_add_watch_full	__PLEASE_USE_B_INPUT_ADD__
 #undef g_source_remove
-#define g_source_remove		__PLEASE_USE_B_SOURCE_REMOVE__
+#define g_source_remove		__PLEASE_USE_B_EVENT_REMOVE__
 #undef g_source_remove_by_user_data
 #define g_source_remove_by_user_data	__PLEASE_USE_B_SOURCE_REMOVE_BY_USER_DATA__
@@ -137,5 +141,4 @@
 	GList *storage; /* The first backend in the list will be used for saving */
 	char *helpfile;
-	GMainLoop *loop;
 	int restart;
 } global_t;
@@ -144,10 +147,10 @@
 int bitlbee_inetd_init( void );
 
-void bitlbee_io_current_client_read( gpointer data, gint source, GaimInputCondition cond );
-void bitlbee_io_current_client_write( gpointer data, gint source, GaimInputCondition cond );
+gboolean bitlbee_io_current_client_read( gpointer data, gint source, b_input_condition cond );
+gboolean bitlbee_io_current_client_write( gpointer data, gint source, b_input_condition cond );
 
 void root_command_string( irc_t *irc, user_t *u, char *command, int flags );
 void root_command( irc_t *irc, char *command[] );
-void bitlbee_shutdown( gpointer data );
+gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond );
 
 extern global_t global;
Index: ipc.c
===================================================================
--- ipc.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ ipc.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -60,5 +60,5 @@
 		ipc_to_children_str( "DIE\r\n" );
 	
-	bitlbee_shutdown( NULL );
+	bitlbee_shutdown( NULL, -1, 0 );
 }
 
@@ -91,5 +91,5 @@
 	
 	global.restart = -1;
-	bitlbee_shutdown( NULL );
+	bitlbee_shutdown( NULL, -1, 0 );
 }
 
@@ -246,5 +246,5 @@
 }
 
-void ipc_master_read( gpointer data, gint source, GaimInputCondition cond )
+gboolean ipc_master_read( gpointer data, gint source, b_input_condition cond )
 {
 	char *buf, **cmd;
@@ -272,7 +272,9 @@
 		}
 	}
-}
-
-void ipc_child_read( gpointer data, gint source, GaimInputCondition cond )
+	
+	return TRUE;
+}
+
+gboolean ipc_child_read( gpointer data, gint source, b_input_condition cond )
 {
 	char *buf, **cmd;
@@ -286,9 +288,11 @@
 	else
 	{
-		gaim_input_remove( global.listen_watch_source_id );
+		b_event_remove( global.listen_watch_source_id );
 		close( global.listen_socket );
 		
 		global.listen_socket = -1;
 	}
+	
+	return TRUE;
 }
 
@@ -397,5 +401,5 @@
 void ipc_master_free_one( struct bitlbee_child *c )
 {
-	gaim_input_remove( c->ipc_inpa );
+	b_event_remove( c->ipc_inpa );
 	closesocket( c->ipc_fd );
 	
@@ -463,5 +467,5 @@
 
 
-static void new_ipc_client( gpointer data, gint serversock, GaimInputCondition cond )
+static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond )
 {
 	struct bitlbee_child *child = g_new0( struct bitlbee_child, 1 );
@@ -472,10 +476,12 @@
 	{
 		log_message( LOGLVL_WARNING, "Unable to accept connection on UNIX domain socket: %s", strerror(errno) );
-		return;
-	}
-		
-	child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
+		return TRUE;
+	}
+		
+	child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
 	
 	child_list = g_slist_append( child_list, child );
+	
+	return TRUE;
 }
 
@@ -512,5 +518,5 @@
 	}
 	
-	gaim_input_add( serversock, GAIM_INPUT_READ, new_ipc_client, NULL );
+	b_input_add( serversock, GAIM_INPUT_READ, new_ipc_client, NULL );
 	
 	return 1;
@@ -552,5 +558,5 @@
 			return 0;
 		}
-		child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
+		child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
 		
 		child_list = g_slist_append( child_list, child );
Index: ipc.h
===================================================================
--- ipc.h	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ ipc.h	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -40,6 +40,6 @@
 
 
-void ipc_master_read( gpointer data, gint source, GaimInputCondition cond );
-void ipc_child_read( gpointer data, gint source, GaimInputCondition cond );
+gboolean ipc_master_read( gpointer data, gint source, b_input_condition cond );
+gboolean ipc_child_read( gpointer data, gint source, b_input_condition cond );
 
 void ipc_master_free_one( struct bitlbee_child *child );
Index: irc.c
===================================================================
--- irc.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ irc.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -29,5 +29,5 @@
 #include "ipc.h"
 
-static gboolean irc_userping( gpointer _irc );
+static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond );
 
 GSList *irc_connection_list = NULL;
@@ -56,5 +56,5 @@
 	sock_make_nonblocking( irc->fd );
 	
-	irc->r_watch_source_id = gaim_input_add( irc->fd, GAIM_INPUT_READ, bitlbee_io_current_client_read, irc );
+	irc->r_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_READ, bitlbee_io_current_client_read, irc );
 	
 	irc->status = USTATUS_OFFLINE;
@@ -114,5 +114,5 @@
 
 	if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 )
-		irc->ping_source_id = g_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc );
+		irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc );
 	
 	irc_write( irc, ":%s NOTICE AUTH :%s", irc->myhost, "BitlBee-IRCd initialized, please go on" );
@@ -184,6 +184,6 @@
 		   bitlbee_.._write doesn't do it first. */
 		
-		g_source_remove( irc->r_watch_source_id );
-		irc->r_watch_source_id = g_timeout_add_full( G_PRIORITY_HIGH, 1000, (GSourceFunc) irc_free, irc, NULL );
+		b_event_remove( irc->r_watch_source_id );
+		irc->r_watch_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc );
 	}
 	else
@@ -218,8 +218,8 @@
 	
 	if( irc->ping_source_id > 0 )
-		g_source_remove( irc->ping_source_id );
-	g_source_remove( irc->r_watch_source_id );
+		b_event_remove( irc->ping_source_id );
+	b_event_remove( irc->r_watch_source_id );
 	if( irc->w_watch_source_id > 0 )
-		g_source_remove( irc->w_watch_source_id );
+		b_event_remove( irc->w_watch_source_id );
 	
 	irc_connection_list = g_slist_remove( irc_connection_list, irc );
@@ -272,5 +272,5 @@
 			if(user->host!=user->nick) g_free(user->host);
 			if(user->realname!=user->nick) g_free(user->realname);
-			gaim_input_remove(user->sendbuf_timer);
+			b_event_remove(user->sendbuf_timer);
 					
 			usertmp = user;
@@ -322,5 +322,5 @@
 	
 	if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON )
-		g_main_quit( global.loop );
+		b_main_quit();
 }
 
@@ -605,5 +605,5 @@
 	
 	if( irc->w_watch_source_id == 0 )
-		irc->w_watch_source_id = gaim_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc );
+		irc->w_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc );
 	
 	return;
@@ -1011,5 +1011,5 @@
 }
 
-gboolean buddy_send_handler_delayed( gpointer data )
+static gboolean buddy_send_handler_delayed( gpointer data, gint fd, b_input_condition cond )
 {
 	user_t *u = data;
@@ -1024,5 +1024,5 @@
 	u->sendbuf_flags = 0;
 	
-	return( FALSE );
+	return FALSE;
 }
 
@@ -1038,6 +1038,6 @@
 		{
 			//Flush the buffer
-			g_source_remove( u->sendbuf_timer );
-			buddy_send_handler_delayed( u );
+			b_event_remove( u->sendbuf_timer );
+			buddy_send_handler_delayed( u, -1, 0 );
 		}
 
@@ -1063,6 +1063,6 @@
 		
 		if( u->sendbuf_timer > 0 )
-			g_source_remove( u->sendbuf_timer );
-		u->sendbuf_timer = g_timeout_add( delay, buddy_send_handler_delayed, u );
+			b_event_remove( u->sendbuf_timer );
+		u->sendbuf_timer = b_timeout_add( delay, buddy_send_handler_delayed, u );
 	}
 	else
@@ -1148,5 +1148,5 @@
    pongs from the user. When not connected yet, we don't ping but drop the
    connection when the user fails to connect in IRC_LOGIN_TIMEOUT secs. */
-static gboolean irc_userping( gpointer _irc )
+static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond )
 {
 	irc_t *irc = _irc;
Index: protocols/events.h
===================================================================
--- protocols/events.h	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/events.h	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -42,6 +42,6 @@
 	GAIM_INPUT_READ = 1 << 0,
 	GAIM_INPUT_WRITE = 1 << 1
-} GaimInputCondition;
-typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition);
+} b_input_condition;
+typedef gboolean (*b_event_handler)(gpointer data, gint fd, b_input_condition cond);
 
 #define GAIM_READ_COND  (G_IO_IN | G_IO_HUP | G_IO_ERR)
@@ -49,8 +49,12 @@
 #define GAIM_ERR_COND   (G_IO_HUP | G_IO_ERR | G_IO_NVAL)
 
-G_MODULE_EXPORT gint gaim_input_add(int fd, GaimInputCondition cond, GaimInputFunction func, gpointer data);
-G_MODULE_EXPORT void gaim_input_remove(gint id);
+G_MODULE_EXPORT void b_main_init();
+G_MODULE_EXPORT void b_main_run();
+G_MODULE_EXPORT void b_main_quit();
 
-G_MODULE_EXPORT gint bee_timeout_add(gint timeout, GaimInputFunction func, gpointer data, gint priority);
+G_MODULE_EXPORT gint b_input_add(int fd, b_input_condition cond, b_event_handler func, gpointer data);
+G_MODULE_EXPORT gint b_timeout_add(gint timeout, b_event_handler func, gpointer data);
+G_MODULE_EXPORT void b_event_remove(gint id);
+G_MODULE_EXPORT gboolean b_event_remove_by_data(gpointer data);
 
 #endif /* _EVENTS_H_ */
Index: protocols/events_glib.c
===================================================================
--- protocols/events_glib.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/events_glib.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -47,13 +47,30 @@
 
 typedef struct _GaimIOClosure {
-	GaimInputFunction function;
+	b_event_handler function;
 	guint result;
 	gpointer data;
 } GaimIOClosure;
 
+static GMainLoop *loop;
+
+void b_main_init()
+{
+	loop = g_main_new( FALSE );
+}
+
+void b_main_run()
+{
+	g_main_run( loop );
+}
+
+void b_main_quit()
+{
+	g_main_quit( loop );
+}
+
 static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
 {
 	GaimIOClosure *closure = data;
-	GaimInputCondition gaim_cond = 0;
+	b_input_condition gaim_cond = 0;
 
 	if (condition & GAIM_READ_COND)
@@ -62,7 +79,5 @@
 		gaim_cond |= GAIM_INPUT_WRITE;
 
-	closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond);
-
-	return TRUE;
+	return closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond);
 }
 
@@ -72,5 +87,5 @@
 }
 
-gint gaim_input_add(gint source, GaimInputCondition condition, GaimInputFunction function, gpointer data)
+gint b_input_add(gint source, b_input_condition condition, b_event_handler function, gpointer data)
 {
 	GaimIOClosure *closure = g_new0(GaimIOClosure, 1);
@@ -94,7 +109,17 @@
 }
 
-void gaim_input_remove(gint tag)
+gint b_timeout_add(gint timeout, b_event_handler func, gpointer data)
+{
+	return g_timeout_add(timeout, func, data);
+}
+
+void b_event_remove(gint tag)
 {
 	if (tag > 0)
 		g_source_remove(tag);
 }
+
+gboolean b_event_remove_by_data(gpointer data)
+{
+	return g_source_remove_by_user_data(data);
+}
Index: protocols/http_client.c
===================================================================
--- protocols/http_client.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/http_client.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -32,7 +32,7 @@
 
 
-static void http_connected( gpointer data, int source, GaimInputCondition cond );
-static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond );
-static void http_incoming_data( gpointer data, int source, GaimInputCondition cond );
+static gboolean http_connected( gpointer data, int source, b_input_condition cond );
+static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond );
+static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond );
 
 
@@ -73,5 +73,5 @@
 /* This one is actually pretty simple... Might get more calls if we can't write 
    the whole request at once. */
-static void http_connected( gpointer data, int source, GaimInputCondition cond )
+static gboolean http_connected( gpointer data, int source, b_input_condition cond )
 {
 	struct http_request *req = data;
@@ -82,5 +82,5 @@
 	
 	if( req->inpa > 0 )
-		gaim_input_remove( req->inpa );
+		b_event_remove( req->inpa );
 	
 	sock_make_nonblocking( req->fd );
@@ -117,11 +117,11 @@
 	
 	if( req->bytes_written < req->request_length )
-		req->inpa = gaim_input_add( source,
-		                            req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
-	        	                    http_connected, req );
-	else
-		req->inpa = gaim_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
-	
-	return;
+		req->inpa = b_input_add( source,
+		                         req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
+	        	                 http_connected, req );
+	else
+		req->inpa = b_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
+	
+	return FALSE;
 	
 error:
@@ -131,8 +131,8 @@
 	g_free( req );
 	
-	return;
+	return FALSE;
 }
 
-static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond )
+static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond )
 {
 	struct http_request *req = data;
@@ -146,5 +146,5 @@
 }
 
-static void http_incoming_data( gpointer data, int source, GaimInputCondition cond )
+static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond )
 {
 	struct http_request *req = data;
@@ -155,5 +155,5 @@
 	
 	if( req->inpa > 0 )
-		gaim_input_remove( req->inpa );
+		b_event_remove( req->inpa );
 	
 	if( req->ssl )
@@ -202,9 +202,9 @@
 	
 	/* There will be more! */
-	req->inpa = gaim_input_add( req->fd,
-	                            req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
-	                            http_incoming_data, req );
-	
-	return;
+	req->inpa = b_input_add( req->fd,
+	                         req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
+	                         http_incoming_data, req );
+	
+	return FALSE;
 
 got_reply:
@@ -362,5 +362,5 @@
 		req->reply_headers = req->reply_body = NULL;
 		
-		return;
+		return FALSE;
 	}
 	
@@ -380,3 +380,5 @@
 	g_free( req->reply_headers );
 	g_free( req );
+	
+	return FALSE;
 }
Index: protocols/jabber/jabber.c
===================================================================
--- protocols/jabber/jabber.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/jabber/jabber.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -471,5 +471,5 @@
 }
 
-static void jabber_callback(gpointer data, gint source, GaimInputCondition condition)
+static gboolean jabber_callback(gpointer data, gint source, b_input_condition condition)
 {
 	struct gaim_connection *gc = (struct gaim_connection *)data;
@@ -477,4 +477,6 @@
 
 	gjab_recv(jd->gjc);
+	
+	return TRUE;
 }
 
@@ -487,5 +489,5 @@
 }
 
-static void gjab_connected(gpointer data, gint source, GaimInputCondition cond)
+static gboolean gjab_connected(gpointer data, gint source, b_input_condition cond)
 {
 	xmlnode x;
@@ -497,5 +499,5 @@
 	if (!g_slist_find(get_connections(), gc)) {
 		closesocket(source);
-		return;
+		return FALSE;
 	}
 
@@ -508,5 +510,5 @@
 	if (source == -1) {
 		STATE_EVT(JCONN_STATE_OFF)
-		return;
+		return FALSE;
 	}
 
@@ -530,8 +532,10 @@
 
 	gc = GJ_GC(gjc);
-	gc->inpa = gaim_input_add(gjc->fd, GAIM_INPUT_READ, jabber_callback, gc);
-}
-
-static void gjab_connected_ssl(gpointer data, void *source, GaimInputCondition cond)
+	gc->inpa = b_input_add(gjc->fd, GAIM_INPUT_READ, jabber_callback, gc);
+	
+	return FALSE;
+}
+
+static gboolean gjab_connected_ssl(gpointer data, void *source, b_input_condition cond)
 {
 	struct gaim_connection *gc = data;
@@ -544,13 +548,13 @@
 	if (source == NULL) {
 		STATE_EVT(JCONN_STATE_OFF)
-		return;
+		return FALSE;
 	}
 	
 	if (!g_slist_find(get_connections(), gc)) {
 		ssl_disconnect(source);
-		return;
+		return FALSE;
 	}
 	
-	gjab_connected(data, gjc->fd, cond);
+	return gjab_connected(data, gjc->fd, cond);
 }
 
@@ -1543,5 +1547,5 @@
 }
 
-static gboolean jabber_free(gpointer data)
+static gboolean jabber_free(gpointer data, gint fd, b_input_condition cond)
 {
 	struct jabber_data *jd = data;
@@ -1586,8 +1590,8 @@
 	}
 	if (gc->inpa)
-		gaim_input_remove(gc->inpa);
+		b_event_remove(gc->inpa);
 
 	if(jd) {
-		g_timeout_add(50, jabber_free, jd);
+		b_timeout_add(50, jabber_free, jd);
 		if(jd->gjc != NULL)
 			xmlnode_free(jd->gjc->current);
Index: protocols/msn/msn.h
===================================================================
--- protocols/msn/msn.h	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/msn/msn.h	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -146,5 +146,5 @@
 
 /* ns.c */
-void msn_ns_connected( gpointer data, gint source, GaimInputCondition cond );
+gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond );
 
 /* msn_util.c */
@@ -173,3 +173,3 @@
 void msn_sb_to_chat( struct msn_switchboard *sb );
 void msn_sb_destroy( struct msn_switchboard *sb );
-void msn_sb_connected( gpointer data, gint source, GaimInputCondition cond );
+gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
Index: protocols/msn/ns.c
===================================================================
--- protocols/msn/ns.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/msn/ns.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -30,5 +30,5 @@
 #include "md5.h"
 
-static void msn_ns_callback( gpointer data, gint source, GaimInputCondition cond );
+static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond );
 static int msn_ns_command( gpointer data, char **cmd, int num_parts );
 static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
@@ -36,5 +36,5 @@
 static void msn_auth_got_passport_id( struct passport_reply *rep );
 
-void msn_ns_connected( gpointer data, gint source, GaimInputCondition cond )
+gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
 {
 	struct gaim_connection *gc = data;
@@ -43,5 +43,5 @@
 	
 	if( !g_slist_find( msn_connections, gc ) )
-		return;
+		return FALSE;
 	
 	if( source == -1 )
@@ -49,5 +49,5 @@
 		hide_login_progress( gc, "Could not connect to server" );
 		signoff( gc );
-		return;
+		return FALSE;
 	}
 	
@@ -75,10 +75,12 @@
 	if( msn_write( gc, s, strlen( s ) ) )
 	{
-		gc->inpa = gaim_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc );
+		gc->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc );
 		set_login_progress( gc, 1, "Connected to server, waiting for reply" );
 	}
+	
+	return FALSE;
 }
 
-void msn_ns_callback( gpointer data, gint source, GaimInputCondition cond )
+static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond )
 {
 	struct gaim_connection *gc = data;
@@ -89,5 +91,9 @@
 		hide_login_progress( gc, "Error while reading from server" );
 		signoff( gc );
-	}
+		
+		return FALSE;
+	}
+	else
+		return TRUE;
 }
 
@@ -130,5 +136,5 @@
 		if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 )
 		{
-			gaim_input_remove( gc->inpa );
+			b_event_remove( gc->inpa );
 			gc->inpa = 0;
 			closesocket( md->fd );
Index: protocols/msn/sb.c
===================================================================
--- protocols/msn/sb.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/msn/sb.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -30,5 +30,5 @@
 #include "md5.h"
 
-static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond );
+static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond );
 static int msn_sb_command( gpointer data, char **cmd, int num_parts );
 static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
@@ -237,5 +237,5 @@
 	}
 	
-	if( sb->inp ) gaim_input_remove( sb->inp );
+	if( sb->inp ) b_event_remove( sb->inp );
 	closesocket( sb->fd );
 	
@@ -245,5 +245,5 @@
 }
 
-void msn_sb_connected( gpointer data, gint source, GaimInputCondition cond )
+gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )
 {
 	struct msn_switchboard *sb = data;
@@ -254,5 +254,5 @@
 	/* Are we still alive? */
 	if( !g_slist_find( msn_switchboards, sb ) )
-		return;
+		return FALSE;
 	
 	gc = sb->gc;
@@ -263,5 +263,5 @@
 		debug( "ERROR %d while connecting to switchboard server", 1 );
 		msn_sb_destroy( sb );
-		return;
+		return FALSE;
 	}
 	
@@ -280,10 +280,12 @@
 	
 	if( msn_sb_write( sb, buf, strlen( buf ) ) )
-		sb->inp = gaim_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
+		sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
 	else
 		debug( "ERROR %d while connecting to switchboard server", 2 );
-}
-
-static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond )
+	
+	return FALSE;
+}
+
+static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond )
 {
 	struct msn_switchboard *sb = data;
@@ -293,5 +295,9 @@
 		debug( "ERROR: Switchboard died" );
 		msn_sb_destroy( sb );
-	}
+		
+		return FALSE;
+	}
+	else
+		return TRUE;
 }
 
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/nogaim.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -328,5 +328,5 @@
 }
 
-static gboolean send_keepalive( gpointer d )
+static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
 {
 	struct gaim_connection *gc = d;
@@ -352,5 +352,5 @@
 	serv_got_crap( gc, "Logged in" );
 	
-	gc->keepalive = g_timeout_add( 60000, send_keepalive, gc );
+	gc->keepalive = b_timeout_add( 60000, send_keepalive, gc );
 	gc->flags |= OPT_LOGGED_IN;
 	
@@ -360,5 +360,5 @@
 }
 
-gboolean auto_reconnect( gpointer data )
+gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond )
 {
 	account_t *a = data;
@@ -372,5 +372,5 @@
 void cancel_auto_reconnect( account_t *a )
 {
-	while( g_source_remove_by_user_data( (gpointer) a ) );
+	while( b_event_remove_by_data( (gpointer) a ) );
 	a->reconnect = 0;
 }
@@ -384,8 +384,8 @@
 	serv_got_crap( gc, "Signing off.." );
 
-	gaim_input_remove( gc->keepalive );
+	b_event_remove( gc->keepalive );
 	gc->keepalive = 0;
 	gc->prpl->close( gc );
-	gaim_input_remove( gc->inpa );
+	b_event_remove( gc->inpa );
 	
 	while( u )
@@ -417,5 +417,5 @@
 		
 		a->reconnect = 1;
-		g_timeout_add( delay * 1000, auto_reconnect, a );
+		b_timeout_add( delay * 1000, auto_reconnect, a );
 	}
 	
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/nogaim.h	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -201,5 +201,5 @@
 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value );
 
-gboolean auto_reconnect( gpointer data );
+gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
 void cancel_auto_reconnect( struct account *a );
 
Index: protocols/oscar/oscar.c
===================================================================
--- protocols/oscar/oscar.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/oscar/oscar.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -253,6 +253,6 @@
 static int msgerrreasonlen = 25;
 
-static void oscar_callback(gpointer data, gint source,
-				GaimInputCondition condition) {
+static gboolean oscar_callback(gpointer data, gint source,
+				b_input_condition condition) {
 	aim_conn_t *conn = (aim_conn_t *)data;
 	aim_session_t *sess = aim_conn_getsess(conn);
@@ -262,5 +262,5 @@
 	if (!gc) {
 		/* gc is null. we return, else we seg SIGSEG on next line. */
-		return;
+		return FALSE;
 	}
       
@@ -268,5 +268,5 @@
 		/* oh boy. this is probably bad. i guess the only thing we 
 		 * can really do is return? */
-		return;
+		return FALSE;
 	}
 
@@ -288,5 +288,5 @@
 				c->conn = NULL;
 				if (c->inpa > 0)
-					gaim_input_remove(c->inpa);
+					b_event_remove(c->inpa);
 				c->inpa = 0;
 				c->fd = -1;
@@ -296,5 +296,5 @@
 			} else if (conn->type == AIM_CONN_TYPE_CHATNAV) {
 				if (odata->cnpa > 0)
-					gaim_input_remove(odata->cnpa);
+					b_event_remove(odata->cnpa);
 				odata->cnpa = 0;
 				while (odata->create_rooms) {
@@ -310,5 +310,5 @@
 			} else if (conn->type == AIM_CONN_TYPE_AUTH) {
 				if (odata->paspa > 0)
-					gaim_input_remove(odata->paspa);
+					b_event_remove(odata->paspa);
 				odata->paspa = 0;
 				aim_conn_kill(odata->sess, &conn);
@@ -317,8 +317,13 @@
 			}
 		}
-	}
-}
-
-static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond)
+	} else {
+		/* WTF??? */
+		return FALSE;
+	}
+		
+	return TRUE;
+}
+
+static gboolean oscar_login_connect(gpointer data, gint source, b_input_condition cond)
 {
 	struct gaim_connection *gc = data;
@@ -329,5 +334,5 @@
 	if (!g_slist_find(get_connections(), gc)) {
 		closesocket(source);
-		return;
+		return FALSE;
 	}
 
@@ -339,10 +344,12 @@
 		hide_login_progress(gc, _("Couldn't connect to host"));
 		signoff(gc);
-		return;
+		return FALSE;
 	}
 
 	aim_conn_completeconnect(sess, conn);
-	gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ,
+	gc->inpa = b_input_add(conn->fd, GAIM_INPUT_READ,
 			oscar_callback, conn);
+	
+	return FALSE;
 }
 
@@ -412,5 +419,5 @@
 		struct chat_connection *n = odata->oscar_chats->data;
 		if (n->inpa > 0)
-			gaim_input_remove(n->inpa);
+			b_event_remove(n->inpa);
 		g_free(n->name);
 		g_free(n->show);
@@ -431,9 +438,9 @@
 		g_free(odata->oldp);
 	if (gc->inpa > 0)
-		gaim_input_remove(gc->inpa);
+		b_event_remove(gc->inpa);
 	if (odata->cnpa > 0)
-		gaim_input_remove(odata->cnpa);
+		b_event_remove(odata->cnpa);
 	if (odata->paspa > 0)
-		gaim_input_remove(odata->paspa);
+		b_event_remove(odata->paspa);
 	aim_session_kill(odata->sess);
 	g_free(odata->sess);
@@ -443,5 +450,5 @@
 }
 
-static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) {
+static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) {
 	struct gaim_connection *gc = data;
 	struct oscar_data *odata;
@@ -451,5 +458,5 @@
 	if (!g_slist_find(get_connections(), gc)) {
 		closesocket(source);
-		return;
+		return FALSE;
 	}
 
@@ -461,11 +468,13 @@
 		hide_login_progress(gc, _("Could Not Connect"));
 		signoff(gc);
-		return;
+		return FALSE;
 	}
 
 	aim_conn_completeconnect(sess, bosconn);
-	gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ,
+	gc->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ,
 			oscar_callback, bosconn);
 	set_login_progress(gc, 4, _("Connection established, cookie sent"));
+	
+	return FALSE;
 }
 
@@ -570,5 +579,5 @@
 	}
 	aim_sendcookie(sess, bosconn, info->cookie);
-	gaim_input_remove(gc->inpa);
+	b_event_remove(gc->inpa);
 
 	return 1;
@@ -585,5 +594,5 @@
 };
 
-static void damn_you(gpointer data, gint source, GaimInputCondition c)
+static gboolean damn_you(gpointer data, gint source, b_input_condition c)
 {
 	struct pieceofcrap *pos = data;
@@ -605,19 +614,21 @@
 		do_error_dialog(pos->gc, "Gaim was unable to get a valid hash for logging into AIM."
 				" You may be disconnected shortly.", "Login Error");
-		gaim_input_remove(pos->inpa);
+		b_event_remove(pos->inpa);
 		closesocket(pos->fd);
 		g_free(pos);
-		return;
+		return FALSE;
 	}
 	/* [WvG] Wheeeee! Who needs error checking anyway? ;-) */
 	read(pos->fd, m, 16);
 	m[16] = '\0';
-	gaim_input_remove(pos->inpa);
+	b_event_remove(pos->inpa);
 	closesocket(pos->fd);
 	aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
 	g_free(pos);
-}
-
-static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) {
+	
+	return FALSE;
+}
+
+static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {
 	struct pieceofcrap *pos = data;
 	char buf[BUF_LONG];
@@ -629,5 +640,5 @@
 			g_free(pos->modname);
 		g_free(pos);
-		return;
+		return FALSE;
 	}
 
@@ -638,6 +649,6 @@
 	if (pos->modname)
 		g_free(pos->modname);
-	pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
-	return;
+	pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
+	return FALSE;
 }
 
@@ -761,5 +772,5 @@
 }
 
-static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) {
+static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) {
 	struct gaim_connection *gc = data;
 	struct oscar_data *odata;
@@ -769,5 +780,5 @@
 	if (!g_slist_find(get_connections(), gc)) {
 		closesocket(source);
-		return;
+		return FALSE;
 	}
 
@@ -778,13 +789,15 @@
 	if (source < 0) {
 		aim_conn_kill(sess, &tstconn);
-		return;
+		return FALSE;
 	}
 
 	aim_conn_completeconnect(sess, tstconn);
-	odata->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ,
+	odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
 					oscar_callback, tstconn);
-}
-
-static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond)
+	
+	return FALSE;
+}
+
+static gboolean oscar_auth_connect(gpointer data, gint source, b_input_condition cond)
 {
 	struct gaim_connection *gc = data;
@@ -795,5 +808,5 @@
 	if (!g_slist_find(get_connections(), gc)) {
 		closesocket(source);
-		return;
+		return FALSE;
 	}
 
@@ -804,13 +817,15 @@
 	if (source < 0) {
 		aim_conn_kill(sess, &tstconn);
-		return;
+		return FALSE;
 	}
 
 	aim_conn_completeconnect(sess, tstconn);
-	odata->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ,
+	odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
 				oscar_callback, tstconn);
-}
-
-static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond)
+	
+	return FALSE;
+}
+
+static gboolean oscar_chat_connect(gpointer data, gint source, b_input_condition cond)
 {
 	struct chat_connection *ccon = data;
@@ -825,5 +840,5 @@
 		g_free(ccon->name);
 		g_free(ccon);
-		return;
+		return FALSE;
 	}
 
@@ -837,12 +852,14 @@
 		g_free(ccon->name);
 		g_free(ccon);
-		return;
+		return FALSE;
 	}
 
 	aim_conn_completeconnect(sess, ccon->conn);
-	ccon->inpa = gaim_input_add(tstconn->fd,
+	ccon->inpa = b_input_add(tstconn->fd,
 			GAIM_INPUT_READ,
 			oscar_callback, tstconn);
 	odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon);
+	
+	return FALSE;
 }
 
@@ -2558,5 +2575,5 @@
 	od->oscar_chats = g_slist_remove(od->oscar_chats, cc);
 	if (cc->inpa > 0)
-		gaim_input_remove(cc->inpa);
+		b_event_remove(cc->inpa);
 	aim_conn_kill(od->sess, &cc->conn);
 	g_free(cc->name);
Index: protocols/proxy.c
===================================================================
--- protocols/proxy.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/proxy.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -49,5 +49,5 @@
 
 struct PHB {
-	GaimInputFunction func, proxy_func;
+	b_event_handler func, proxy_func;
 	gpointer data, proxy_data;
 	char *host;
@@ -78,5 +78,5 @@
 }
 
-static void gaim_io_connected(gpointer data, gint source, GaimInputCondition cond)
+static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond)
 {
 	struct PHB *phb = data;
@@ -88,5 +88,5 @@
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 		closesocket(source);
-		gaim_input_remove(phb->inpa);
+		b_event_remove(phb->inpa);
 		if( phb->proxy_func )
 			phb->proxy_func(phb->proxy_data, -1, GAIM_INPUT_READ);
@@ -95,9 +95,9 @@
 			g_free(phb);
 		}
-		return;
+		return FALSE;
 	}
 #endif
 	sock_make_blocking(source);
-	gaim_input_remove(phb->inpa);
+	b_event_remove(phb->inpa);
 	if( phb->proxy_func )
 		phb->proxy_func(phb->proxy_data, source, GAIM_INPUT_READ);
@@ -106,4 +106,6 @@
 		g_free(phb);
 	}
+	
+	return FALSE;
 }
 
@@ -127,5 +129,5 @@
 	if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) {
 		if (sockerr_again()) {
-			phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);
+			phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);
 			phb->fd = fd;
 		} else {
@@ -145,5 +147,5 @@
 #define HTTP_GOODSTRING2 "HTTP/1.1 200 Connection established"
 
-static void http_canread(gpointer data, gint source, GaimInputCondition cond)
+static gboolean http_canread(gpointer data, gint source, b_input_condition cond)
 {
 	int nlc = 0;
@@ -152,5 +154,5 @@
 	char inputline[8192];
 
-	gaim_input_remove(phb->inpa);
+	b_event_remove(phb->inpa);
 
 	while ((pos < sizeof(inputline)-1) && (nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) {
@@ -167,5 +169,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -174,8 +176,9 @@
 	g_free(phb->host);
 	g_free(phb);
-	return;
-}
-
-static void http_canwrite(gpointer data, gint source, GaimInputCondition cond)
+	
+	return FALSE;
+}
+
+static gboolean http_canwrite(gpointer data, gint source, b_input_condition cond)
 {
 	char cmd[384];
@@ -184,5 +187,5 @@
 	int error = ETIMEDOUT;
 	if (phb->inpa > 0)
-		gaim_input_remove(phb->inpa);
+		b_event_remove(phb->inpa);
 	len = sizeof(error);
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
@@ -191,5 +194,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 	sock_make_blocking(source);
@@ -202,5 +205,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -217,5 +220,5 @@
 			g_free(phb->host);
 			g_free(phb);
-			return;
+			return FALSE;
 		}
 	}
@@ -227,8 +230,10 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
-	}
-
-	phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_canread, phb);
+		return FALSE;
+	}
+
+	phb->inpa = b_input_add(source, GAIM_INPUT_READ, http_canread, phb);
+	
+	return FALSE;
 }
 
@@ -246,10 +251,10 @@
 /* Connecting to SOCKS4 proxies */
 
-static void s4_canread(gpointer data, gint source, GaimInputCondition cond)
+static gboolean s4_canread(gpointer data, gint source, b_input_condition cond)
 {
 	unsigned char packet[12];
 	struct PHB *phb = data;
 
-	gaim_input_remove(phb->inpa);
+	b_event_remove(phb->inpa);
 
 	memset(packet, 0, sizeof(packet));
@@ -258,5 +263,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -265,7 +270,9 @@
 	g_free(phb->host);
 	g_free(phb);
-}
-
-static void s4_canwrite(gpointer data, gint source, GaimInputCondition cond)
+	
+	return FALSE;
+}
+
+static gboolean s4_canwrite(gpointer data, gint source, b_input_condition cond)
 {
 	unsigned char packet[12];
@@ -275,5 +282,5 @@
 	int error = ETIMEDOUT;
 	if (phb->inpa > 0)
-		gaim_input_remove(phb->inpa);
+		b_event_remove(phb->inpa);
 	len = sizeof(error);
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
@@ -282,5 +289,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 	sock_make_blocking(source);
@@ -292,5 +299,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -309,8 +316,10 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
-	}
-
-	phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s4_canread, phb);
+		return FALSE;
+	}
+
+	phb->inpa = b_input_add(source, GAIM_INPUT_READ, s4_canread, phb);
+	
+	return FALSE;
 }
 
@@ -328,10 +337,10 @@
 /* Connecting to SOCKS5 proxies */
 
-static void s5_canread_again(gpointer data, gint source, GaimInputCondition cond)
+static gboolean s5_canread_again(gpointer data, gint source, b_input_condition cond)
 {
 	unsigned char buf[512];
 	struct PHB *phb = data;
 
-	gaim_input_remove(phb->inpa);
+	b_event_remove(phb->inpa);
 
 	if (read(source, buf, 10) < 10) {
@@ -340,5 +349,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 	if ((buf[0] != 0x05) || (buf[1] != 0x00)) {
@@ -347,5 +356,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -353,5 +362,6 @@
 	g_free(phb->host);
 	g_free(phb);
-	return;
+	
+	return FALSE;
 }
 
@@ -361,5 +371,5 @@
 	struct PHB *phb = data;
 	int hlen = strlen(phb->host);
-
+	
 	buf[0] = 0x05;
 	buf[1] = 0x01;		/* CONNECT */
@@ -379,13 +389,13 @@
 	}
 
-	phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb);
-}
-
-static void s5_readauth(gpointer data, gint source, GaimInputCondition cond)
+	phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb);
+}
+
+static gboolean s5_readauth(gpointer data, gint source, b_input_condition cond)
 {
 	unsigned char buf[512];
 	struct PHB *phb = data;
 
-	gaim_input_remove(phb->inpa);
+	b_event_remove(phb->inpa);
 
 	if (read(source, buf, 2) < 2) {
@@ -394,5 +404,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -402,16 +412,18 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
 	s5_sendconnect(phb, source);
-}
-
-static void s5_canread(gpointer data, gint source, GaimInputCondition cond)
+	
+	return FALSE;
+}
+
+static gboolean s5_canread(gpointer data, gint source, b_input_condition cond)
 {
 	unsigned char buf[512];
 	struct PHB *phb = data;
 
-	gaim_input_remove(phb->inpa);
+	b_event_remove(phb->inpa);
 
 	if (read(source, buf, 2) < 2) {
@@ -420,5 +432,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -428,5 +440,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 
@@ -443,14 +455,16 @@
 			g_free(phb->host);
 			g_free(phb);
-			return;
+			return FALSE;
 		}
 
-		phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_readauth, phb);
+		phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_readauth, phb);
 	} else {
 		s5_sendconnect(phb, source);
 	}
-}
-
-static void s5_canwrite(gpointer data, gint source, GaimInputCondition cond)
+	
+	return FALSE;
+}
+
+static gboolean s5_canwrite(gpointer data, gint source, b_input_condition cond)
 {
 	unsigned char buf[512];
@@ -460,5 +474,5 @@
 	int error = ETIMEDOUT;
 	if (phb->inpa > 0)
-		gaim_input_remove(phb->inpa);
+		b_event_remove(phb->inpa);
 	len = sizeof(error);
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
@@ -467,5 +481,5 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
+		return FALSE;
 	}
 	sock_make_blocking(source);
@@ -489,8 +503,10 @@
 		g_free(phb->host);
 		g_free(phb);
-		return;
-	}
-
-	phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread, phb);
+		return FALSE;
+	}
+
+	phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread, phb);
+	
+	return FALSE;
 }
 
@@ -508,5 +524,5 @@
 /* Export functions */
 
-int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data)
+int proxy_connect(const char *host, int port, b_event_handler func, gpointer data)
 {
 	struct PHB *phb;
Index: protocols/proxy.h
===================================================================
--- protocols/proxy.h	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/proxy.h	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -49,5 +49,5 @@
 extern char proxypass[128];
 
-G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data);
+G_MODULE_EXPORT int proxy_connect(const char *host, int port, b_event_handler func, gpointer data);
 
 #endif /* _PROXY_H_ */
Index: protocols/ssl_bogus.c
===================================================================
--- protocols/ssl_bogus.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/ssl_bogus.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -52,5 +52,5 @@
 }
 
-GaimInputCondition ssl_getdirection( void *conn )
+b_input_condition ssl_getdirection( void *conn )
 {
 	return GAIM_INPUT_READ;
Index: protocols/ssl_client.h
===================================================================
--- protocols/ssl_client.h	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/ssl_client.h	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -33,5 +33,5 @@
 extern int ssl_errno;
 
-typedef void (*ssl_input_function)(gpointer, void*, GaimInputCondition);
+typedef gboolean (*ssl_input_function)(gpointer, void*, b_input_condition);
 
 G_MODULE_EXPORT void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data );
@@ -40,3 +40,3 @@
 G_MODULE_EXPORT void ssl_disconnect( void *conn_ );
 G_MODULE_EXPORT int ssl_getfd( void *conn );
-G_MODULE_EXPORT GaimInputCondition ssl_getdirection( void *conn );
+G_MODULE_EXPORT b_input_condition ssl_getdirection( void *conn );
Index: protocols/ssl_gnutls.c
===================================================================
--- protocols/ssl_gnutls.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/ssl_gnutls.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -48,5 +48,5 @@
 };
 
-static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );
+static void ssl_connected( gpointer data, gint source, b_input_condition cond );
 
 
@@ -81,7 +81,7 @@
 }
 
-static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );
-
-static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
+static void ssl_handshake( gpointer data, gint source, b_input_condition cond );
+
+static void ssl_connected( gpointer data, gint source, b_input_condition cond )
 {
 	struct scd *conn = data;
@@ -105,5 +105,5 @@
 }
 
-static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )
+static void ssl_handshake( gpointer data, gint source, b_input_condition cond )
 {
 	struct scd *conn = data;
@@ -204,5 +204,5 @@
 }
 
-GaimInputCondition ssl_getdirection( void *conn )
+b_input_condition ssl_getdirection( void *conn )
 {
 	return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ?
Index: protocols/ssl_nss.c
===================================================================
--- protocols/ssl_nss.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/ssl_nss.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -52,5 +52,5 @@
 };
 
-static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );
+static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond );
 
 
@@ -116,5 +116,5 @@
 }
 
-static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
+static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond )
 {
 	struct scd *conn = data;
@@ -140,5 +140,5 @@
 	conn->established = TRUE;
 	conn->func( conn->data, conn, cond );
-	return;
+	return FALSE;
 	
 	ssl_connected_failure:
@@ -149,4 +149,6 @@
 	if( source >= 0 ) closesocket( source );
 	g_free( conn );
+	
+	return FALSE;
 }
 
@@ -182,5 +184,5 @@
 }
 
-GaimInputCondition ssl_getdirection( void *conn )
+b_input_condition ssl_getdirection( void *conn )
 {
 	/* Just in case someone calls us, let's return the most likely case: */
Index: protocols/ssl_openssl.c
===================================================================
--- protocols/ssl_openssl.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/ssl_openssl.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -52,5 +52,5 @@
 };
 
-static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );
+static void ssl_connected( gpointer data, gint source, b_input_condition cond );
 
 
@@ -95,7 +95,7 @@
 }
 
-static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );
-
-static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
+static void ssl_handshake( gpointer data, gint source, b_input_condition cond );
+
+static void ssl_connected( gpointer data, gint source, b_input_condition cond )
 {
 	struct scd *conn = data;
@@ -111,5 +111,5 @@
 }	
 
-static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )
+static void ssl_handshake( gpointer data, gint source, b_input_condition cond )
 {
 	struct scd *conn = data;
@@ -221,5 +221,5 @@
 }
 
-GaimInputCondition ssl_getdirection( void *conn )
+b_input_condition ssl_getdirection( void *conn )
 {
 	return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ );
Index: protocols/yahoo/yahoo.c
===================================================================
--- protocols/yahoo/yahoo.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ protocols/yahoo/yahoo.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -443,5 +443,5 @@
 };
 
-void byahoo_connect_callback( gpointer data, gint source, GaimInputCondition cond )
+void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond )
 {
 	struct byahoo_connect_callback_data *d = data;
@@ -465,5 +465,5 @@
 };
 
-void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition cond )
+gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond )
 {
 	struct byahoo_read_ready_data *d = data;
@@ -473,5 +473,5 @@
 		/* WTF doesn't libyahoo clean this up? */
 		ext_yahoo_remove_handler( d->id, d->tag );
-		return;
+		return FALSE;
 	}
 	
@@ -487,5 +487,5 @@
 };
 
-void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition cond )
+gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond )
 {
 	struct byahoo_write_ready_data *d = data;
@@ -495,5 +495,5 @@
 		/* WTF doesn't libyahoo clean this up? */
 		ext_yahoo_remove_handler( d->id, d->tag );
-		return;
+		return FALSE;
 	}
 	
@@ -686,5 +686,5 @@
 		
 		inp->d = d;
-		d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_READ, (GaimInputFunction) byahoo_read_ready_callback, (gpointer) d );
+		d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );
 	}
 	else if( cond == YAHOO_INPUT_WRITE )
@@ -697,5 +697,5 @@
 		
 		inp->d = d;
-		d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_WRITE, (GaimInputFunction) byahoo_write_ready_callback, (gpointer) d );
+		d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );
 	}
 	else
@@ -728,5 +728,5 @@
 	}
 	
-	gaim_input_remove( tag );
+	b_event_remove( tag );
 }
 
@@ -737,5 +737,5 @@
 	
 	d = g_new0( struct byahoo_connect_callback_data, 1 );
-	if( ( fd = proxy_connect( host, port, (GaimInputFunction) byahoo_connect_callback, (gpointer) d ) ) < 0 )
+	if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 )
 	{
 		g_free( d );
Index: unix.c
===================================================================
--- unix.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ unix.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -47,5 +47,5 @@
 	memset( &global, 0, sizeof( global_t ) );
 	
-	global.loop = g_main_new( FALSE );
+	b_main_init();
 	
 	log_init();
@@ -117,5 +117,5 @@
 		log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
 	
-	g_main_run( global.loop );
+	b_main_run();
 	
 	if( global.restart )
@@ -165,5 +165,5 @@
 			
 			log_message( LOGLVL_ERROR, "SIGTERM received, cleaning up process." );
-			g_timeout_add_full( G_PRIORITY_LOW, 1, (GSourceFunc) bitlbee_shutdown, NULL, NULL );
+			b_timeout_add( 1, (b_event_handler) bitlbee_shutdown, NULL );
 			
 			first = 0;
Index: user.c
===================================================================
--- user.c	(revision 67b6766489f1b9b5f2249659b0ddf260e6f8f51b)
+++ user.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
@@ -109,5 +109,5 @@
 			if( u->handle ) g_free( u->handle );
 			if( u->sendbuf ) g_free( u->sendbuf );
-			if( u->sendbuf_timer ) g_source_remove( u->sendbuf_timer );
+			if( u->sendbuf_timer ) b_event_remove( u->sendbuf_timer );
 			g_free( u );
 			
