Index: bitlbee.c
===================================================================
--- bitlbee.c	(revision 006a84f999248d1bc1c1e36fa3437765d4bd1142)
+++ bitlbee.c	(revision 69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06)
@@ -370,5 +370,6 @@
 	/* Try to save data for all active connections (if desired). */
 	while( irc_connection_list != NULL )
-		irc_free( irc_connection_list->data );
+		irc_abort( irc_connection_list->data, FALSE,
+		           "BitlBee server shutting down" );
 	
 	/* We'll only reach this point when not running in inetd mode: */
Index: doc/user-guide/commands.xml
===================================================================
--- doc/user-guide/commands.xml	(revision 006a84f999248d1bc1c1e36fa3437765d4bd1142)
+++ doc/user-guide/commands.xml	(revision 69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06)
@@ -1093,4 +1093,18 @@
 	</bitlbee-setting>
 
+	<bitlbee-setting name="translate_to_nicks" type="boolean" scope="channel">
+		<default>true</default>
+
+		<description>
+			<para>
+				IRC's nickname namespace is quite limited compared to most IM protocols. Not any non-ASCII characters are allowed, in fact nicknames have to be mostly alpha-numeric. Also, BitlBee has to add underscores sometimes to avoid nickname collisions.
+			</para>
+
+			<para>
+				While normally the BitlBee user is the only one seeing these names, they may be exposed to other chatroom participants for example when addressing someone in the channel (with or without tab completion). By default BitlBee will translate these stripped nicknames back to the original nick. If you don't want this, disable this setting.
+			</para>
+		</description>
+	</bitlbee-setting>
+
 	<bitlbee-setting name="type" type="string" scope="channel">
 		<default>control</default>
Index: irc_im.c
===================================================================
--- irc_im.c	(revision 006a84f999248d1bc1c1e36fa3437765d4bd1142)
+++ irc_im.c	(revision 69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06)
@@ -603,8 +603,29 @@
 {
 	struct groupchat *c = ic->data;
+	char *trans = NULL, *s;
 	
 	if( c == NULL )
 		return FALSE;
-	else if( set_getbool( &ic->irc->b->set, "paste_buffer" ) )
+	
+	if( set_getbool( &ic->set, "translate_to_nicks" ) )
+	{
+		char nick[MAX_NICK_LENGTH+1];
+		irc_user_t *iu;
+		
+		strncpy( nick, msg, MAX_NICK_LENGTH );
+		nick[MAX_NICK_LENGTH] = '\0';
+		if( ( s = strchr( nick, ':' ) ) || ( s = strchr( nick, ',' ) ) )
+		{
+			*s = '\0';
+			if( ( iu = irc_user_by_name( ic->irc, nick ) ) &&
+			    iu->bu->nick && irc_channel_has_user( ic, iu ) )
+			{
+				trans = g_strconcat( iu->bu->nick, msg + ( s - nick ), NULL );
+				msg = trans;
+			}
+		}
+	}
+	
+	if( set_getbool( &ic->irc->b->set, "paste_buffer" ) )
 	{
 		int delay;
@@ -623,4 +644,5 @@
 		ic->pastebuf_timer = b_timeout_add( delay, bee_irc_channel_chat_privmsg_cb, ic );
 		
+		g_free( trans );
 		return TRUE;
 	}
@@ -628,4 +650,5 @@
 		bee_chat_msg( ic->irc->b, c, msg, 0 );
 	
+	g_free( trans );
 	return TRUE;
 }
@@ -747,4 +770,5 @@
 	set_add( &ic->set, "nick", NULL, NULL, ic );
 	set_add( &ic->set, "room", NULL, NULL, ic );
+	set_add( &ic->set, "translate_to_nicks", "true", set_eval_bool, ic );
 	
 	/* chat_type == groupchat */
@@ -790,4 +814,5 @@
 	set_del( &ic->set, "nick" );
 	set_del( &ic->set, "room" );
+	set_del( &ic->set, "translate_to_nicks" );
 	
 	ic->flags &= ~IRC_CHANNEL_TEMP;
Index: protocols/bee.h
===================================================================
--- protocols/bee.h	(revision 006a84f999248d1bc1c1e36fa3437765d4bd1142)
+++ protocols/bee.h	(revision 69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06)
@@ -62,4 +62,5 @@
 	char *handle;
 	char *fullname;
+	char *nick;
 	struct bee_group *group;
 
Index: protocols/bee_user.c
===================================================================
--- protocols/bee_user.c	(revision 006a84f999248d1bc1c1e36fa3437765d4bd1142)
+++ protocols/bee_user.c	(revision 69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06)
@@ -60,4 +60,5 @@
 	g_free( bu->handle );
 	g_free( bu->fullname );
+	g_free( bu->nick );
 	g_free( bu->status );
 	g_free( bu->status_msg );
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 006a84f999248d1bc1c1e36fa3437765d4bd1142)
+++ protocols/nogaim.c	(revision 69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06)
@@ -427,4 +427,7 @@
 	
 	if( !bu || !nick ) return;
+	
+	g_free( bu->nick );
+	bu->nick = g_strdup( nick );
 	
 	if( bee->ui->user_nick_hint )
