Index: protocols/purple/bpurple.h
===================================================================
--- protocols/purple/bpurple.h	(revision d93c8bebaf03ee9e7ed9eb94d9bb432a6517ce2b)
+++ protocols/purple/bpurple.h	(revision d93c8bebaf03ee9e7ed9eb94d9bb432a6517ce2b)
@@ -0,0 +1,12 @@
+#ifndef BPURPLE_H
+# define BPURPLE_H
+
+#include <purple.h>
+#include <glib.h>
+
+struct purple_data
+{
+    PurpleAccount *account;
+};
+
+#endif /* !BPURPLE_H */
Index: protocols/purple/ft-direct.c
===================================================================
--- protocols/purple/ft-direct.c	(revision 5ff46180e5378acd6d103d9314175c78530bda7e)
+++ protocols/purple/ft-direct.c	(revision d93c8bebaf03ee9e7ed9eb94d9bb432a6517ce2b)
@@ -28,4 +28,5 @@
 
 #include "bitlbee.h"
+#include "bpurple.h"
 
 #include <stdarg.h>
@@ -207,5 +208,5 @@
 void purple_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *handle)
 {
-	PurpleAccount *pa = ic->proto_data;
+	struct purple_data *pd = ic->proto_data;
 	struct prpl_xfer_data *px;
 
@@ -213,5 +214,6 @@
 	   multi-threaded anyway. */
 	next_ft = ft;
-	serv_send_file(purple_account_get_connection(pa), handle, ft->file_name);
+	serv_send_file(purple_account_get_connection(pd->account), handle,
+	               ft->file_name);
 
 	ft->write = prpl_xfer_write;
Index: protocols/purple/ft.c
===================================================================
--- protocols/purple/ft.c	(revision 5ff46180e5378acd6d103d9314175c78530bda7e)
+++ protocols/purple/ft.c	(revision d93c8bebaf03ee9e7ed9eb94d9bb432a6517ce2b)
@@ -28,4 +28,5 @@
 
 #include "bitlbee.h"
+#include "bpurple.h"
 
 #include <stdarg.h>
@@ -285,10 +286,11 @@
 {
 	struct prpl_xfer_data *px = ft->data;
-	PurpleAccount *pa = px->ic->proto_data;
+	struct purple_data *pd = px->ic->proto_data;
 
 	/* xfer_new() will pick up this variable. It's a hack but we're not
 	   multi-threaded anyway. */
 	next_ft = ft;
-	serv_send_file(purple_account_get_connection(pa), px->handle, px->fn);
+	serv_send_file(purple_account_get_connection(pd->account),
+                   px->handle, px->fn);
 }
 
Index: protocols/purple/purple.c
===================================================================
--- protocols/purple/purple.c	(revision 5ff46180e5378acd6d103d9314175c78530bda7e)
+++ protocols/purple/purple.c	(revision d93c8bebaf03ee9e7ed9eb94d9bb432a6517ce2b)
@@ -23,4 +23,5 @@
 
 #include "bitlbee.h"
+#include "bpurple.h"
 #include "help.h"
 
@@ -42,7 +43,9 @@
 {
 	GSList *i;
+	struct purple_data *pd;
 
 	for (i = purple_connections; i; i = i->next) {
-		if (((struct im_connection *) i->data)->proto_data == pa) {
+		pd = ((struct im_connection *) i->data)->proto_data;
+		if (pd->account == pa) {
 			return i->data;
 		}
@@ -290,5 +293,5 @@
 {
 	struct im_connection *ic = imcb_new(acc);
-	PurpleAccount *pa;
+	struct purple_data *pd;
 
 	if ((local_bee != NULL && local_bee != acc->bee) ||
@@ -306,18 +309,20 @@
 	purple_connections = g_slist_prepend(purple_connections, ic);
 
-	ic->proto_data = pa = purple_account_new(acc->user, (char *) acc->prpl->data);
-	purple_account_set_password(pa, acc->pass);
-	purple_sync_settings(acc, pa);
-
-	purple_account_set_enabled(pa, "BitlBee", TRUE);
+	ic->proto_data = pd = g_new0(struct purple_data, 1);
+	pd->account = purple_account_new(acc->user, (char *) acc->prpl->data);
+	purple_account_set_password(pd->account, acc->pass);
+	purple_sync_settings(acc, pd->account);
+
+	purple_account_set_enabled(pd->account, "BitlBee", TRUE);
 }
 
 static void purple_logout(struct im_connection *ic)
 {
-	PurpleAccount *pa = ic->proto_data;
-
-	purple_account_set_enabled(pa, "BitlBee", FALSE);
+	struct purple_data *pd = ic->proto_data;
+
+	purple_account_set_enabled(pd->account, "BitlBee", FALSE);
 	purple_connections = g_slist_remove(purple_connections, ic);
-	purple_accounts_remove(pa);
+	purple_accounts_remove(pd->account);
+	g_free(pd);
 }
 
@@ -325,9 +330,10 @@
 {
 	PurpleConversation *conv;
+	struct purple_data *pd = ic->proto_data;
 
 	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
-	                                                  who, ic->proto_data)) == NULL) {
+	                                                  who, pd->account)) == NULL) {
 		conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
-		                               ic->proto_data, who);
+		                               pd->account, who);
 	}
 
@@ -339,8 +345,8 @@
 static GList *purple_away_states(struct im_connection *ic)
 {
-	PurpleAccount *pa = ic->proto_data;
+	struct purple_data *pd = ic->proto_data;
 	GList *st, *ret = NULL;
 
-	for (st = purple_account_get_status_types(pa); st; st = st->next) {
+	for (st = purple_account_get_status_types(pd->account); st; st = st->next) {
 		PurpleStatusPrimitive prim = purple_status_type_get_primitive(st->data);
 		if (prim != PURPLE_STATUS_AVAILABLE && prim != PURPLE_STATUS_OFFLINE) {
@@ -354,6 +360,6 @@
 static void purple_set_away(struct im_connection *ic, char *state_txt, char *message)
 {
-	PurpleAccount *pa = ic->proto_data;
-	GList *status_types = purple_account_get_status_types(pa), *st;
+	struct purple_data *pd = ic->proto_data;
+	GList *status_types = purple_account_get_status_types(pd->account), *st;
 	PurpleStatusType *pst = NULL;
 	GList *args = NULL;
@@ -378,5 +384,6 @@
 	}
 
-	purple_account_set_status_list(pa, st ? purple_status_type_get_id(pst) : "away",
+	purple_account_set_status_list(pd->account,
+	                               st ? purple_status_type_get_id(pst) : "away",
 	                               TRUE, args);
 
@@ -447,4 +454,5 @@
 	PurpleBuddy *pb;
 	PurpleGroup *pg = NULL;
+	struct purple_data *pd = ic->proto_data;
 
 	if (group && !(pg = purple_find_group(group))) {
@@ -453,9 +461,9 @@
 	}
 
-	pb = purple_buddy_new((PurpleAccount *) ic->proto_data, who, NULL);
+	pb = purple_buddy_new(pd->account, who, NULL);
 	purple_blist_add_buddy(pb, NULL, pg, NULL);
-	purple_account_add_buddy((PurpleAccount *) ic->proto_data, pb);
-
-	purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc);
+	purple_account_add_buddy(pd->account, pb);
+
+	purple_gg_buddylist_export(pd->account->gc);
 }
 
@@ -463,49 +471,52 @@
 {
 	PurpleBuddy *pb;
-
-	pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who);
+	struct purple_data *pd = ic->proto_data;
+
+	pb = purple_find_buddy(pd->account, who);
 	if (pb != NULL) {
 		PurpleGroup *group;
 
 		group = purple_buddy_get_group(pb);
-		purple_account_remove_buddy((PurpleAccount *) ic->proto_data, pb, group);
+		purple_account_remove_buddy(pd->account, pb, group);
 
 		purple_blist_remove_buddy(pb);
 	}
 
-	purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc);
+	purple_gg_buddylist_export(pd->account->gc);
 }
 
 static void purple_add_permit(struct im_connection *ic, char *who)
 {
-	PurpleAccount *pa = ic->proto_data;
-
-	purple_privacy_permit_add(pa, who, FALSE);
+	struct purple_data *pd = ic->proto_data;
+
+	purple_privacy_permit_add(pd->account, who, FALSE);
 }
 
 static void purple_add_deny(struct im_connection *ic, char *who)
 {
-	PurpleAccount *pa = ic->proto_data;
-
-	purple_privacy_deny_add(pa, who, FALSE);
+	struct purple_data *pd = ic->proto_data;
+
+	purple_privacy_deny_add(pd->account, who, FALSE);
 }
 
 static void purple_rem_permit(struct im_connection *ic, char *who)
 {
-	PurpleAccount *pa = ic->proto_data;
-
-	purple_privacy_permit_remove(pa, who, FALSE);
+	struct purple_data *pd = ic->proto_data;
+
+	purple_privacy_permit_remove(pd->account, who, FALSE);
 }
 
 static void purple_rem_deny(struct im_connection *ic, char *who)
 {
-	PurpleAccount *pa = ic->proto_data;
-
-	purple_privacy_deny_remove(pa, who, FALSE);
+	struct purple_data *pd = ic->proto_data;
+
+	purple_privacy_deny_remove(pd->account, who, FALSE);
 }
 
 static void purple_get_info(struct im_connection *ic, char *who)
 {
-	serv_get_info(purple_account_get_connection(ic->proto_data), who);
+	struct purple_data *pd = ic->proto_data;
+
+	serv_get_info(purple_account_get_connection(pd->account), who);
 }
 
@@ -517,5 +528,5 @@
 {
 	PurpleTypingState state = PURPLE_NOT_TYPING;
-	PurpleAccount *pa = ic->proto_data;
+	struct purple_data *pd = ic->proto_data;
 
 	if (flags & OPT_TYPING) {
@@ -525,5 +536,5 @@
 	}
 
-	serv_send_typing(purple_account_get_connection(pa), who, state);
+	serv_send_typing(purple_account_get_connection(pd->account), who, state);
 
 	return 1;
@@ -559,8 +570,8 @@
 	/* There went my nice afternoon. :-( */
 
-	PurpleAccount *pa = ic->proto_data;
-	PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id);
+	struct purple_data *pd = ic->proto_data;
+	PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
 	PurplePluginProtocolInfo *pi = prpl->info->extra_info;
-	PurpleBuddy *pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who);
+	PurpleBuddy *pb = purple_find_buddy(pd->account, who);
 	PurpleMenuAction *mi;
 	GList *menu;
@@ -597,6 +608,7 @@
 	PurpleConversation *pc = gc->data;
 	PurpleConvChat *pcc = PURPLE_CONV_CHAT(pc);
-
-	serv_chat_invite(purple_account_get_connection(gc->ic->proto_data),
+	struct purple_data *pd = gc->ic->proto_data;
+
+	serv_chat_invite(purple_account_get_connection(pd->account),
 	                 purple_conv_chat_get_id(pcc),
 	                 message && *message ? message : "Please join my chat",
@@ -623,6 +635,6 @@
                                    set_t **sets)
 {
-	PurpleAccount *pa = ic->proto_data;
-	PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id);
+	struct purple_data *pd = ic->proto_data;
+	PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
 	PurplePluginProtocolInfo *pi = prpl->info->extra_info;
 	GHashTable *chat_hash;
@@ -631,14 +643,17 @@
 
 	if (!pi->chat_info || !pi->chat_info_defaults ||
-	    !(info = pi->chat_info(purple_account_get_connection(pa)))) {
+	    !(info = pi->chat_info(purple_account_get_connection(pd->account)))) {
 		imcb_error(ic, "Joining chatrooms not supported by this protocol");
 		return NULL;
 	}
 
-	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, room, pa))) {
+	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
+	                                                  room, pd->account))) {
 		purple_conversation_destroy(conv);
 	}
 
-	chat_hash = pi->chat_info_defaults(purple_account_get_connection(pa), room);
+	chat_hash = pi->chat_info_defaults(
+	        purple_account_get_connection(pd->account), room
+	);
 
 	for (l = info; l; l = l->next) {
@@ -654,5 +669,5 @@
 	}
 
-	serv_join_chat(purple_account_get_connection(pa), chat_hash);
+	serv_join_chat(purple_account_get_connection(pd->account), chat_hash);
 
 	return NULL;
