From 7d5177b035aed270dc6e9f4e7a2692597abb9230 Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Mon, 27 Jan 2014 13:29:32 +0000
Subject: code cleaning

git-svn-id: http://svn.miranda-ng.org/main/trunk@7913 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 protocols/IRCG/src/clist.cpp          |  168 ++---
 protocols/IRCG/src/commandmonitor.cpp | 1127 ++++++++++++++--------------
 protocols/IRCG/src/input.cpp          |  699 +++++++++---------
 protocols/IRCG/src/irclib.cpp         |  804 ++++++++++----------
 protocols/IRCG/src/ircproto.cpp       |  434 +++++------
 protocols/IRCG/src/main.cpp           |   20 +-
 protocols/IRCG/src/options.cpp        |  280 +++----
 protocols/IRCG/src/output.cpp         |   99 +--
 protocols/IRCG/src/scripting.cpp      |  114 +--
 protocols/IRCG/src/services.cpp       |  491 ++++++-------
 protocols/IRCG/src/tools.cpp          |    7 +-
 protocols/IRCG/src/userinfo.cpp       |  168 ++---
 protocols/IRCG/src/windows.cpp        | 1300 +++++++++++++++++----------------
 13 files changed, 2875 insertions(+), 2836 deletions(-)

(limited to 'protocols')

diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp
index 6c2a92de29..f95dc36351 100644
--- a/protocols/IRCG/src/clist.cpp
+++ b/protocols/IRCG/src/clist.cpp
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "irc.h"
 
-BOOL CIrcProto::CList_AddDCCChat(const CMString& name, const CMString& hostmask, unsigned long adr, int port) 
+BOOL CIrcProto::CList_AddDCCChat(const CMString& name, const CMString& hostmask, unsigned long adr, int port)
 {
 	HANDLE hContact;
 	HANDLE hc;
@@ -30,57 +30,54 @@ BOOL CIrcProto::CList_AddDCCChat(const CMString& name, const CMString& hostmask,
 	char szService[256];
 	bool bFlag = false;
 
-	CONTACT usertemp = { (TCHAR*)name.c_str(), NULL, NULL, false, false, true};
-	hc = CList_FindContact( &usertemp );
-	if ( hc && db_get_b( hc, "CList", "NotOnList", 0) == 0
-		&& db_get_b(hc,"CList", "Hidden", 0) == 0)
-	{
+	CONTACT usertemp = { (TCHAR*)name.c_str(), NULL, NULL, false, false, true };
+	hc = CList_FindContact(&usertemp);
+	if (hc && db_get_b(hc, "CList", "NotOnList", 0) == 0 && db_get_b(hc, "CList", "Hidden", 0) == 0)
 		bFlag = true;
-	}
 
 	CMString contactname = name; contactname += _T(DCCSTRING);
 
-	CONTACT user = { (TCHAR*)contactname.c_str(), NULL, NULL, false, false, true};
+	CONTACT user = { (TCHAR*)contactname.c_str(), NULL, NULL, false, false, true };
 	hContact = CList_AddContact(&user, false, false);
 	setByte(hContact, "DCC", 1);
 
 	DCCINFO* pdci = new DCCINFO;
 	pdci->sHostmask = hostmask;
 	pdci->hContact = hContact;
-	pdci->dwAdr = (DWORD) adr;
+	pdci->dwAdr = (DWORD)adr;
 	pdci->iPort = port;
 	pdci->iType = DCC_CHAT;
 	pdci->bSender = false;
 	pdci->sContactName = name;
 
-	if ( m_DCCChatAccept == 3 || m_DCCChatAccept == 2 && bFlag ) {
-		CDccSession* dcc = new CDccSession( this, pdci );
+	if (m_DCCChatAccept == 3 || m_DCCChatAccept == 2 && bFlag) {
+		CDccSession* dcc = new CDccSession(this, pdci);
 
 		CDccSession* olddcc = FindDCCSession(hContact);
-		if ( olddcc )
+		if (olddcc)
 			olddcc->Disconnect();
 
 		AddDCCSession(hContact, dcc);
 		dcc->Connect();
-		if (getByte( "MirVerAutoRequest", 1))
-		  PostIrcMessage( _T("/PRIVMSG %s \001VERSION\001"), name.c_str());
+		if (getByte("MirVerAutoRequest", 1))
+			PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), name.c_str());
 	}
 	else {
-		CLISTEVENT cle = {0};
+		CLISTEVENT cle = { 0 };
 		cle.cbSize = sizeof(cle);
 		cle.hContact = (HANDLE)hContact;
-		cle.hDbEvent = (HANDLE)"dccchat";	
+		cle.hDbEvent = (HANDLE)"dccchat";
 		cle.flags = CLEF_TCHAR;
 		cle.hIcon = LoadIconEx(IDI_DCC);
-		mir_snprintf(szService, sizeof(szService),"%s/DblClickEvent", m_szModuleName);
+		mir_snprintf(szService, sizeof(szService), "%s/DblClickEvent", m_szModuleName);
 		cle.pszService = szService;
 		mir_sntprintf(szNick, SIZEOF(szNick), TranslateT("CTCP chat request from %s"), name.c_str());
 		cle.ptszTooltip = szNick;
 		cle.lParam = (LPARAM)pdci;
 
-		if ( CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0))
+		if (CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0))
 			CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)"dccchat");
-		CallService(MS_CLIST_ADDEVENT,(WPARAM) hContact,(LPARAM) &cle);
+		CallService(MS_CLIST_ADDEVENT, (WPARAM)hContact, (LPARAM)&cle);
 	}
 	return TRUE;
 }
@@ -89,33 +86,33 @@ HANDLE CIrcProto::CList_AddContact(CONTACT * user, bool InList, bool SetOnline)
 {
 	if (user->name == NULL)
 		return 0;
-	
+
 	HANDLE hContact = CList_FindContact(user);
-	if ( hContact ) {
-		if ( InList )
-			db_unset( hContact, "CList", "NotOnList" );
+	if (hContact) {
+		if (InList)
+			db_unset(hContact, "CList", "NotOnList");
 		setTString(hContact, "Nick", user->name);
 		db_unset(hContact, "CList", "Hidden");
-		if (SetOnline && getWord(hContact, "Status", ID_STATUS_OFFLINE)== ID_STATUS_OFFLINE)
+		if (SetOnline && getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
 			setWord(hContact, "Status", ID_STATUS_ONLINE);
 		return hContact;
 	}
-	
+
 	// here we create a new one since no one is to be found
 	hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
-	if ( hContact ) {
-		CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM)m_szModuleName );
+	if (hContact) {
+		CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName);
 
-		if ( InList )
+		if (InList)
 			db_unset(hContact, "CList", "NotOnList");
 		else
 			db_set_b(hContact, "CList", "NotOnList", 1);
 		db_unset(hContact, "CList", "Hidden");
 		setTString(hContact, "Nick", user->name);
 		setTString(hContact, "Default", user->name);
-		setWord(hContact, "Status", SetOnline ? ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
-		if ( !InList && getByte( "MirVerAutoRequestTemp", 0))
-			PostIrcMessage( _T("/PRIVMSG %s \001VERSION\001"), user->name);
+		setWord(hContact, "Status", SetOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
+		if (!InList && getByte("MirVerAutoRequestTemp", 0))
+			PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), user->name);
 		return hContact;
 	}
 	return false;
@@ -123,17 +120,18 @@ HANDLE CIrcProto::CList_AddContact(CONTACT * user, bool InList, bool SetOnline)
 
 HANDLE CIrcProto::CList_SetOffline(struct CONTACT * user)
 {
-	DBVARIANT dbv;
 	HANDLE hContact = CList_FindContact(user);
-	if ( hContact ) {
-		if ( !getTString( hContact, "Default", &dbv )) {
+	if (hContact) {
+		DBVARIANT dbv;
+		if (!getTString(hContact, "Default", &dbv)) {
 			setString(hContact, "User", "");
 			setString(hContact, "Host", "");
 			setTString(hContact, "Nick", dbv.ptszVal);
 			setWord(hContact, "Status", ID_STATUS_OFFLINE);
 			db_free(&dbv);
 			return hContact;
-	}	}
+		}
+	}
 
 	return 0;
 }
@@ -145,92 +143,74 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo)
 	DisconnectAllDCCSessions(false);
 
 	for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
-		if ( isChatRoom(hContact))
+		if (isChatRoom(hContact))
 			continue;
 
-		if ( getByte(hContact, "DCC", 0 ) != 0 ) {
-			if ( ChatsToo )
+		if (getByte(hContact, "DCC", 0) != 0) {
+			if (ChatsToo)
 				setWord(hContact, "Status", ID_STATUS_OFFLINE);
 		}
-		else if ( !getTString( hContact, "Default", &dbv )) {
-			setTString( hContact, "Nick", dbv.ptszVal);
-			setWord( hContact, "Status", ID_STATUS_OFFLINE );
-			db_free( &dbv );
+		else if (!getTString(hContact, "Default", &dbv)) {
+			setTString(hContact, "Nick", dbv.ptszVal);
+			setWord(hContact, "Status", ID_STATUS_OFFLINE);
+			db_free(&dbv);
 		}
-		db_unset( hContact, m_szModuleName, "IP" );
-		setString( hContact, "User", "" );
-		setString( hContact, "Host", "" );
+		db_unset(hContact, m_szModuleName, "IP");
+		setString(hContact, "User", "");
+		setString(hContact, "Host", "");
 	}
 	return true;
 }
 
-HANDLE CIrcProto::CList_FindContact (CONTACT* user) 
+HANDLE CIrcProto::CList_FindContact(CONTACT* user)
 {
-	if ( !user || !user->name )
+	if (!user || !user->name)
 		return 0;
-	
-	TCHAR* lowercasename = mir_tstrdup( user->name );
+
+	TCHAR* lowercasename = mir_tstrdup(user->name);
 	CharLower(lowercasename);
-	
-	DBVARIANT dbv1;
-	DBVARIANT dbv2;	
-	DBVARIANT dbv3;	
-	DBVARIANT dbv4;	
-	DBVARIANT dbv5;	
 
 	for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
-		if ( isChatRoom(hContact))
+		if (isChatRoom(hContact))
 			continue;
 
 		HANDLE hContact_temp = NULL;
-		TCHAR* DBDefault = NULL;
-		TCHAR* DBNick = NULL;
-		TCHAR* DBWildcard = NULL;
-		TCHAR* DBUser = NULL;
-		TCHAR* DBHost = NULL;
-		if ( !getTString(hContact, "Default",   &dbv1)) DBDefault = dbv1.ptszVal;
-		if ( !getTString(hContact, "Nick",      &dbv2)) DBNick = dbv2.ptszVal;
-		if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal;
-		if ( !getTString(hContact, "UUser",     &dbv4)) DBUser = dbv4.ptszVal;
-		if ( !getTString(hContact, "UHost",     &dbv5)) DBHost = dbv5.ptszVal;
-				
-		if ( DBWildcard )
-			CharLower( DBWildcard );
-		if ( IsChannel( user->name )) {
-			if ( DBDefault && !lstrcmpi( DBDefault, user->name ))
+		ptrT DBNick(getTStringA(hContact, "Nick"));
+		ptrT DBUser(getTStringA(hContact, "UUser"));
+		ptrT DBHost(getTStringA(hContact, "UHost"));
+		ptrT DBDefault(getTStringA(hContact, "Default"));
+		ptrT DBWildcard(getTStringA(hContact, "UWildcard"));
+
+		if (DBWildcard)
+			CharLower(DBWildcard);
+		if (IsChannel(user->name)) {
+			if (DBDefault && !lstrcmpi(DBDefault, user->name))
 				hContact_temp = (HANDLE)-1;
 		}
-		else if ( user->ExactNick && DBNick && !lstrcmpi( DBNick, user->name ))
+		else if (user->ExactNick && DBNick && !lstrcmpi(DBNick, user->name))
 			hContact_temp = hContact;
-				
-		else if ( user->ExactOnly && DBDefault && !lstrcmpi( DBDefault, user->name ))
+
+		else if (user->ExactOnly && DBDefault && !lstrcmpi(DBDefault, user->name))
 			hContact_temp = hContact;
-			
-		else if ( user->ExactWCOnly ) {
-			if ( DBWildcard && !lstrcmpi( DBWildcard, lowercasename ) 
-				|| ( DBWildcard && !lstrcmpi( DBNick, lowercasename ) && !WCCmp( DBWildcard, lowercasename ))
-				|| ( !DBWildcard && !lstrcmpi(DBNick, lowercasename)))
-			{
+
+		else if (user->ExactWCOnly) {
+			if (DBWildcard && !lstrcmpi(DBWildcard, lowercasename)
+				|| (DBWildcard && !lstrcmpi(DBNick, lowercasename) && !WCCmp(DBWildcard, lowercasename))
+				|| (!DBWildcard && !lstrcmpi(DBNick, lowercasename))) {
 				hContact_temp = hContact;
 			}
 		}
-		else if ( _tcschr(user->name, ' ' ) == 0 ) {
-			if (( DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) || 
-					DBWildcard && WCCmp( DBWildcard, lowercasename ))
-				&& ( WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host)))
-			{
+		else if (_tcschr(user->name, ' ') == 0) {
+			if ((DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) ||
+				DBWildcard && WCCmp(DBWildcard, lowercasename))
+				&& (WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host))) {
 				hContact_temp = hContact;
-		}	}
-
-		if ( DBDefault )   db_free(&dbv1);
-		if ( DBNick )      db_free(&dbv2);
-		if ( DBWildcard )  db_free(&dbv3);
-		if ( DBUser )      db_free(&dbv4);
-		if ( DBHost )      db_free(&dbv5);
+			}
+		}
 
-		if ( hContact_temp != NULL ) {
+		if (hContact_temp != NULL) {
 			mir_free(lowercasename);
-			if ( hContact_temp != (HANDLE)-1 )
+			if (hContact_temp != (HANDLE)-1)
 				return hContact_temp;
 			return 0;
 		}
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index 603ab055c2..c67304d98d 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -26,231 +26,233 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 using namespace irc;
 
-VOID CALLBACK IdentTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
+VOID CALLBACK IdentTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
 {
-	CIrcProto *ppro = GetTimerOwner( idEvent );
+	CIrcProto *ppro = GetTimerOwner(idEvent);
 	if (ppro == NULL)
 		return;
 
-	ppro->KillChatTimer( ppro->IdentTimer );
-	if ( ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING )
+	ppro->KillChatTimer(ppro->IdentTimer);
+	if (ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING)
 		return;
 
-	if ( ppro->IsConnected() && ppro->m_identTimer )
+	if (ppro->IsConnected() && ppro->m_identTimer)
 		ppro->KillIdent();
 }
 
-VOID CALLBACK TimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
+VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
 {
-	CIrcProto *ppro = GetTimerOwner( idEvent );
+	CIrcProto *ppro = GetTimerOwner(idEvent);
 	if (ppro == NULL)
 		return;
 
-	ppro->KillChatTimer( ppro->InitTimer );
-	if ( ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING )
+	ppro->KillChatTimer(ppro->InitTimer);
+	if (ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING)
 		return;
 
-	if ( ppro->m_forceVisible )
-		ppro->PostIrcMessage( _T("/MODE %s -i"), ppro->m_info.sNick.c_str());
+	if (ppro->m_forceVisible)
+		ppro->PostIrcMessage(_T("/MODE %s -i"), ppro->m_info.sNick.c_str());
 
-	if ( lstrlenA( ppro->m_myHost ) == 0 && ppro->IsConnected())
+	if (lstrlenA(ppro->m_myHost) == 0 && ppro->IsConnected())
 		ppro->DoUserhostWithReason(2, (_T("S") + ppro->m_info.sNick).c_str(), true, _T("%s"), ppro->m_info.sNick.c_str());
 }
 
-VOID CALLBACK KeepAliveTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
+VOID CALLBACK KeepAliveTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
 {
-	CIrcProto *ppro = GetTimerOwner( idEvent );
+	CIrcProto *ppro = GetTimerOwner(idEvent);
 	if (ppro == NULL)
 		return;
 
-	if ( !ppro->m_sendKeepAlive || ( ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING )) {
-		ppro->KillChatTimer( ppro->KeepAliveTimer );
+	if (!ppro->m_sendKeepAlive || (ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING)) {
+		ppro->KillChatTimer(ppro->KeepAliveTimer);
 		return;
 	}
 
 	TCHAR temp2[270];
-	if ( !ppro->m_info.sServerName.IsEmpty())
+	if (!ppro->m_info.sServerName.IsEmpty())
 		mir_sntprintf(temp2, SIZEOF(temp2), _T("PING %s"), ppro->m_info.sServerName.c_str());
 	else
 		mir_sntprintf(temp2, SIZEOF(temp2), _T("PING %u"), time(0));
 
-	if ( ppro->IsConnected())
-		ppro->SendIrcMessage( temp2, false );
+	if (ppro->IsConnected())
+		ppro->SendIrcMessage(temp2, false);
 }
 
-VOID CALLBACK OnlineNotifTimerProc3( HWND, UINT, UINT_PTR idEvent, DWORD )
+VOID CALLBACK OnlineNotifTimerProc3(HWND, UINT, UINT_PTR idEvent, DWORD)
 {
-	CIrcProto *ppro = GetTimerOwner( idEvent );
+	CIrcProto *ppro = GetTimerOwner(idEvent);
 	if (ppro == NULL)
 		return;
 
-	if ( !ppro->m_channelAwayNotification || 
-		  ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING || 
-		  ( !ppro->m_autoOnlineNotification && !ppro->bTempForceCheck) || ppro->bTempDisableCheck ) {
-		ppro->KillChatTimer( ppro->OnlineNotifTimer3 );
+	if (!ppro->m_channelAwayNotification ||
+		ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING ||
+		(!ppro->m_autoOnlineNotification && !ppro->bTempForceCheck) || ppro->bTempDisableCheck) {
+		ppro->KillChatTimer(ppro->OnlineNotifTimer3);
 		ppro->m_channelsToWho = _T("");
 		return;
 	}
 
-	CMString name = GetWord( ppro->m_channelsToWho.c_str(), 0 );
-	if ( name.IsEmpty()) {
+	CMString name = GetWord(ppro->m_channelsToWho.c_str(), 0);
+	if (name.IsEmpty()) {
 		ppro->m_channelsToWho = _T("");
 		int count = (int)CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)ppro->m_szModuleName);
-		for ( int i = 0; i < count; i++ ) {
-			GC_INFO gci = {0};
+		for (int i = 0; i < count; i++) {
+			GC_INFO gci = { 0 };
 			gci.Flags = BYINDEX | NAME | TYPE | COUNT;
 			gci.iItem = i;
 			gci.pszModule = ppro->m_szModuleName;
-			if ( !CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci ) && gci.iType == GCW_CHATROOM )
-				if ( gci.iCount <= ppro->m_onlineNotificationLimit )
-					ppro->m_channelsToWho += CMString(gci.pszName) + _T(" ");
-	}	}
+			if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.iType == GCW_CHATROOM)
+			if (gci.iCount <= ppro->m_onlineNotificationLimit)
+				ppro->m_channelsToWho += CMString(gci.pszName) + _T(" ");
+		}
+	}
 
-	if ( ppro->m_channelsToWho.IsEmpty()) {
-		ppro->SetChatTimer( ppro->OnlineNotifTimer3, 60*1000, OnlineNotifTimerProc3 );
+	if (ppro->m_channelsToWho.IsEmpty()) {
+		ppro->SetChatTimer(ppro->OnlineNotifTimer3, 60 * 1000, OnlineNotifTimerProc3);
 		return;
 	}
 
-	name = GetWord( ppro->m_channelsToWho.c_str(), 0 );
+	name = GetWord(ppro->m_channelsToWho.c_str(), 0);
 	ppro->DoUserhostWithReason(2, _T("S") + name, true, _T("%s"), name.c_str());
-	CMString temp = GetWordAddress( ppro->m_channelsToWho.c_str(), 1 );
+	CMString temp = GetWordAddress(ppro->m_channelsToWho.c_str(), 1);
 	ppro->m_channelsToWho = temp;
-	if ( ppro->m_iTempCheckTime )
-		ppro->SetChatTimer( ppro->OnlineNotifTimer3, ppro->m_iTempCheckTime*1000, OnlineNotifTimerProc3 );
+	if (ppro->m_iTempCheckTime)
+		ppro->SetChatTimer(ppro->OnlineNotifTimer3, ppro->m_iTempCheckTime * 1000, OnlineNotifTimerProc3);
 	else
-		ppro->SetChatTimer( ppro->OnlineNotifTimer3, ppro->m_onlineNotificationTime*1000, OnlineNotifTimerProc3 );
+		ppro->SetChatTimer(ppro->OnlineNotifTimer3, ppro->m_onlineNotificationTime * 1000, OnlineNotifTimerProc3);
 }
 
-VOID CALLBACK OnlineNotifTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
+VOID CALLBACK OnlineNotifTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
 {
-	CIrcProto *ppro = GetTimerOwner( idEvent );
+	CIrcProto *ppro = GetTimerOwner(idEvent);
 	if (ppro == NULL)
 		return;
 
-	if ( ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING || 
-		  ( !ppro->m_autoOnlineNotification && !ppro->bTempForceCheck) || ppro->bTempDisableCheck ) {
-		ppro->KillChatTimer( ppro->OnlineNotifTimer );
+	if (ppro->m_iStatus == ID_STATUS_OFFLINE || ppro->m_iStatus == ID_STATUS_CONNECTING ||
+		(!ppro->m_autoOnlineNotification && !ppro->bTempForceCheck) || ppro->bTempDisableCheck) {
+		ppro->KillChatTimer(ppro->OnlineNotifTimer);
 		ppro->m_namesToWho = _T("");
 		return;
 	}
 
-	CMString name = GetWord( ppro->m_namesToWho.c_str(), 0);
-	CMString name2 = GetWord( ppro->m_namesToUserhost.c_str(), 0);
+	CMString name = GetWord(ppro->m_namesToWho.c_str(), 0);
+	CMString name2 = GetWord(ppro->m_namesToUserhost.c_str(), 0);
 
-	if ( name.IsEmpty() && name2.IsEmpty()) {
+	if (name.IsEmpty() && name2.IsEmpty()) {
 		DBVARIANT dbv;
 		for (HANDLE hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName)) {
-			if ( ppro->isChatRoom(hContact))
+			if (ppro->isChatRoom(hContact))
 				continue;
 
 			BYTE bDCC = ppro->getByte(hContact, "DCC", 0);
-			BYTE bHidden = db_get_b(hContact,"CList", "Hidden", 0);
-			if ( bDCC || bHidden)
+			BYTE bHidden = db_get_b(hContact, "CList", "Hidden", 0);
+			if (bDCC || bHidden)
 				continue;
-			if ( ppro->getTString( hContact, "Default", &dbv ))
+			if (ppro->getTString(hContact, "Default", &dbv))
 				continue;
 
-			BYTE bAdvanced = ppro->getByte(hContact, "AdvancedMode", 0) ;
-			if ( !bAdvanced ) {
-				db_free( &dbv );
-				if ( !ppro->getTString( hContact, "Nick", &dbv )) {	
+			BYTE bAdvanced = ppro->getByte(hContact, "AdvancedMode", 0);
+			if (!bAdvanced) {
+				db_free(&dbv);
+				if (!ppro->getTString(hContact, "Nick", &dbv)) {
 					ppro->m_namesToUserhost += CMString(dbv.ptszVal) + _T(" ");
-					db_free( &dbv );
+					db_free(&dbv);
 				}
 			}
 			else {
-				db_free( &dbv );
+				db_free(&dbv);
 				DBVARIANT dbv2;
-								
+
 				TCHAR* DBNick = NULL;
 				TCHAR* DBWildcard = NULL;
-				if ( !ppro->getTString( hContact, "Nick", &dbv ))
+				if (!ppro->getTString(hContact, "Nick", &dbv))
 					DBNick = dbv.ptszVal;
-				if ( !ppro->getTString( hContact, "UWildcard", &dbv2 ))
+				if (!ppro->getTString(hContact, "UWildcard", &dbv2))
 					DBWildcard = dbv2.ptszVal;
 
-				if ( DBNick && ( !DBWildcard || !WCCmp(CharLower(DBWildcard), CharLower(DBNick)))) 
+				if (DBNick && (!DBWildcard || !WCCmp(CharLower(DBWildcard), CharLower(DBNick))))
 					ppro->m_namesToWho += CMString(DBNick) + _T(" ");
-				else if ( DBWildcard )
+				else if (DBWildcard)
 					ppro->m_namesToWho += CMString(DBWildcard) + _T(" ");
 
-				if ( DBNick )     db_free(&dbv);
-            if ( DBWildcard ) db_free(&dbv2);
+				if (DBNick)     db_free(&dbv);
+				if (DBWildcard) db_free(&dbv2);
 			}
 		}
 	}
 
-	if ( ppro->m_namesToWho.IsEmpty() && ppro->m_namesToUserhost.IsEmpty()) {
-		ppro->SetChatTimer( ppro->OnlineNotifTimer, 60*1000, OnlineNotifTimerProc );
+	if (ppro->m_namesToWho.IsEmpty() && ppro->m_namesToUserhost.IsEmpty()) {
+		ppro->SetChatTimer(ppro->OnlineNotifTimer, 60 * 1000, OnlineNotifTimerProc);
 		return;
 	}
 
-	name = GetWord( ppro->m_namesToWho.c_str(), 0);
-	name2 = GetWord( ppro->m_namesToUserhost.c_str(), 0);
+	name = GetWord(ppro->m_namesToWho.c_str(), 0);
+	name2 = GetWord(ppro->m_namesToUserhost.c_str(), 0);
 	CMString temp;
-	if ( !name.IsEmpty()) {
+	if (!name.IsEmpty()) {
 		ppro->DoUserhostWithReason(2, _T("S") + name, true, _T("%s"), name.c_str());
-		temp = GetWordAddress( ppro->m_namesToWho.c_str(), 1 );
+		temp = GetWordAddress(ppro->m_namesToWho.c_str(), 1);
 		ppro->m_namesToWho = temp;
 	}
 
-	if ( !name2.IsEmpty()) {
+	if (!name2.IsEmpty()) {
 		CMString params;
-		for ( int i = 0; i < 3; i++ ) {
+		for (int i = 0; i < 3; i++) {
 			params = _T("");
-			for ( int j = 0; j < 5; j++ ) 
-				params += GetWord( ppro->m_namesToUserhost, i *5 + j) + _T(" ");
+			for (int j = 0; j < 5; j++)
+				params += GetWord(ppro->m_namesToUserhost, i * 5 + j) + _T(" ");
 
-			if ( params[0] != ' ' )
+			if (params[0] != ' ')
 				ppro->DoUserhostWithReason(1, CMString(_T("S")) + params, true, params);
 		}
-		temp = GetWordAddress( ppro->m_namesToUserhost.c_str(), 15 );
+		temp = GetWordAddress(ppro->m_namesToUserhost.c_str(), 15);
 		ppro->m_namesToUserhost = temp;
 	}
 
-	if ( ppro->m_iTempCheckTime )
-		ppro->SetChatTimer( ppro->OnlineNotifTimer, ppro->m_iTempCheckTime*1000, OnlineNotifTimerProc );
+	if (ppro->m_iTempCheckTime)
+		ppro->SetChatTimer(ppro->OnlineNotifTimer, ppro->m_iTempCheckTime * 1000, OnlineNotifTimerProc);
 	else
-		ppro->SetChatTimer( ppro->OnlineNotifTimer, ppro->m_onlineNotificationTime*1000, OnlineNotifTimerProc );
+		ppro->SetChatTimer(ppro->OnlineNotifTimer, ppro->m_onlineNotificationTime * 1000, OnlineNotifTimerProc);
 }
 
 int CIrcProto::AddOutgoingMessageToDB(HANDLE hContact, TCHAR* msg)
 {
-	if ( m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_CONNECTING )
+	if (m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_CONNECTING)
 		return 0;
 
-	CMString S = DoColorCodes( msg, TRUE, FALSE );
+	CMString S = DoColorCodes(msg, TRUE, FALSE);
 
 	DBEVENTINFO dbei = { sizeof(dbei) };
 	dbei.szModule = m_szModuleName;
 	dbei.eventType = EVENTTYPE_MESSAGE;
 	dbei.timestamp = (DWORD)time(NULL);
 	dbei.flags = DBEF_SENT + DBEF_UTF;
-	dbei.pBlob = ( PBYTE )mir_utf8encodeW( S.c_str());
-	dbei.cbBlob = (DWORD)strlen(( char* )dbei.pBlob) + 1;
+	dbei.pBlob = (PBYTE)mir_utf8encodeW(S.c_str());
+	dbei.cbBlob = (DWORD)strlen((char*)dbei.pBlob) + 1;
 	db_event_add(hContact, &dbei);
-	mir_free( dbei.pBlob );
+	mir_free(dbei.pBlob);
 	return 1;
 }
 
 void __cdecl CIrcProto::ResolveIPThread(LPVOID di)
 {
-	IPRESOLVE* ipr = (IPRESOLVE *) di;
+	IPRESOLVE* ipr = (IPRESOLVE *)di;
 
-	EnterCriticalSection( &m_resolve);
+	EnterCriticalSection(&m_resolve);
 
-	if ( ipr != NULL && (ipr->iType == IP_AUTO && lstrlenA(m_myHost) == 0 || ipr->iType == IP_MANUAL )) {
-		hostent* myhost = gethostbyname( ipr->sAddr.c_str());
-		if ( myhost ) {
+	if (ipr != NULL && (ipr->iType == IP_AUTO && lstrlenA(m_myHost) == 0 || ipr->iType == IP_MANUAL)) {
+		hostent* myhost = gethostbyname(ipr->sAddr.c_str());
+		if (myhost) {
 			IN_ADDR in;
-			memcpy( &in, myhost->h_addr, 4 );
-			if ( ipr->iType == IP_AUTO )
-				mir_snprintf( m_myHost, sizeof( m_myHost ), "%s", inet_ntoa( in ));
+			memcpy(&in, myhost->h_addr, 4);
+			if (ipr->iType == IP_AUTO)
+				mir_snprintf(m_myHost, sizeof(m_myHost), "%s", inet_ntoa(in));
 			else
-				mir_snprintf( m_mySpecifiedHostIP, sizeof( m_mySpecifiedHostIP ), "%s", inet_ntoa( in ));
-	}	}
-	
-	LeaveCriticalSection( &m_resolve );
+				mir_snprintf(m_mySpecifiedHostIP, sizeof(m_mySpecifiedHostIP), "%s", inet_ntoa(in));
+		}
+	}
+
+	LeaveCriticalSection(&m_resolve);
 	delete ipr;
 }
 
@@ -258,92 +260,95 @@ bool CIrcProto::OnIrc_PING(const CIrcMessage* pmsg)
 {
 	TCHAR szResponse[100];
 	mir_sntprintf(szResponse, SIZEOF(szResponse), _T("PONG %s"), pmsg->parameters[0].c_str());
-	SendIrcMessage( szResponse );
+	SendIrcMessage(szResponse);
 	return false;
 }
 
 bool CIrcProto::OnIrc_WELCOME(const CIrcMessage* pmsg)
 {
-	if ( pmsg->parameters[0] != m_info.sNick )
+	if (pmsg->parameters[0] != m_info.sNick)
 		m_info.sNick = pmsg->parameters[0];
 
-	if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) {
+	if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) {
 		static TCHAR host[1024];
 		int i = 0;
-		CMString word = GetWord( pmsg->parameters[1].c_str(), i );
-		while ( !word.IsEmpty()) {
-			if ( _tcschr( word.c_str(), '!') && _tcschr( word.c_str(), '@' )) {
-				lstrcpyn( host, word.c_str(), SIZEOF(host));
-				TCHAR* p1 = _tcschr( host, '@' );
-				if ( p1 )
-					ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( _T2A(p1+1), IP_AUTO ));
+		CMString word = GetWord(pmsg->parameters[1].c_str(), i);
+		while (!word.IsEmpty()) {
+			if (_tcschr(word.c_str(), '!') && _tcschr(word.c_str(), '@')) {
+				lstrcpyn(host, word.c_str(), SIZEOF(host));
+				TCHAR* p1 = _tcschr(host, '@');
+				if (p1)
+					ForkThread(&CIrcProto::ResolveIPThread, new IPRESOLVE(_T2A(p1 + 1), IP_AUTO));
 			}
-			
+
 			word = GetWord(pmsg->parameters[1].c_str(), ++i);
-	}	}			
-		
-	ShowMessage( pmsg ); 
+		}
+	}
+
+	ShowMessage(pmsg);
 	return true;
 }
 
 bool CIrcProto::OnIrc_WHOTOOLONG(const CIrcMessage* pmsg)
 {
 	CMString command = GetNextUserhostReason(2);
-	if ( command[0] == 'U' )
-		ShowMessage( pmsg ); 
+	if (command[0] == 'U')
+		ShowMessage(pmsg);
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_BACKFROMAWAY(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming ) {
+	if (pmsg->m_bIncoming) {
 		int Temp = m_iStatus;
 		m_iStatus = m_iDesiredStatus = ID_STATUS_ONLINE;
 		ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_ONLINE);
 
-		if ( m_perform )
-			DoPerform( "Event: Available" );
-	}			
-		
-	ShowMessage( pmsg );
+		if (m_perform)
+			DoPerform("Event: Available");
+	}
+
+	ShowMessage(pmsg);
 	return true;
 }
 
 bool CIrcProto::OnIrc_SETAWAY(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming ) {
+	if (pmsg->m_bIncoming) {
 		int Temp = m_iDesiredStatus;
 		m_iStatus = m_iDesiredStatus = ID_STATUS_AWAY;
 		ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_AWAY);
 
-		if ( m_perform ) {
-			switch ( m_iStatus ) {
+		if (m_perform) {
+			switch (m_iStatus) {
 			case ID_STATUS_AWAY:
-				DoPerform( "Event: Away" );
+				DoPerform("Event: Away");
 				break;
 			case ID_STATUS_NA:
-				DoPerform( "Event: N/A" );
+				DoPerform("Event: N/A");
 				break;
 			case ID_STATUS_DND:
-				DoPerform( "Event: DND" );
+				DoPerform("Event: DND");
 				break;
 			case ID_STATUS_OCCUPIED:
-				DoPerform( "Event: Occupied" );
+				DoPerform("Event: Occupied");
 				break;
 			case ID_STATUS_OUTTOLUNCH:
-				DoPerform( "Event: Out for lunch" );
+				DoPerform("Event: Out for lunch");
 				break;
 			case ID_STATUS_ONTHEPHONE:
-				DoPerform( "Event: On the phone" );
+				DoPerform("Event: On the phone");
 				break;
 			default:
 				m_iStatus = ID_STATUS_AWAY;
-				DoPerform( "Event: Away" );
+				DoPerform("Event: Away");
 				break;
-	}	}	}	
-		
-	ShowMessage( pmsg ); 
+			}
+		}
+	}
+
+	ShowMessage(pmsg);
 	return true;
 }
 
@@ -351,169 +356,169 @@ bool CIrcProto::OnIrc_JOIN(const CIrcMessage* pmsg)
 {
 	if (pmsg->parameters.getCount() > 0 && pmsg->m_bIncoming && pmsg->prefix.sNick != m_info.sNick) {
 		CMString host = pmsg->prefix.sUser + _T("@") + pmsg->prefix.sHost;
-		DoEvent(GC_EVENT_JOIN, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), NULL, _T("Normal"), host.c_str(), NULL, true, false); 
-		DoEvent(GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[0].c_str(),pmsg->prefix.sNick.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE); 
+		DoEvent(GC_EVENT_JOIN, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), NULL, _T("Normal"), host.c_str(), NULL, true, false);
+		DoEvent(GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE);
 	}
-	else ShowMessage( pmsg ); 
+	else ShowMessage(pmsg);
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_QUIT(const CIrcMessage* pmsg)
 {
-	if (pmsg->m_bIncoming) 
-	{
+	if (pmsg->m_bIncoming) {
 		CMString host = pmsg->prefix.sUser + _T("@") + pmsg->prefix.sHost;
-		DoEvent(GC_EVENT_QUIT, NULL, pmsg->prefix.sNick.c_str(), pmsg->parameters.getCount()>0?pmsg->parameters[0].c_str():NULL, NULL, host.c_str(), NULL, true, false);
-		struct CONTACT user = { (LPTSTR)pmsg->prefix.sNick.c_str(), (LPTSTR)pmsg->prefix.sUser.c_str(), (LPTSTR)pmsg->prefix.sHost.c_str(), false, false, false};
-		CList_SetOffline( &user );
-		if ( pmsg->prefix.sNick == m_info.sNick ) {
+		DoEvent(GC_EVENT_QUIT, NULL, pmsg->prefix.sNick.c_str(), pmsg->parameters.getCount() > 0 ? pmsg->parameters[0].c_str() : NULL, NULL, host.c_str(), NULL, true, false);
+		struct CONTACT user = { (LPTSTR)pmsg->prefix.sNick.c_str(), (LPTSTR)pmsg->prefix.sUser.c_str(), (LPTSTR)pmsg->prefix.sHost.c_str(), false, false, false };
+		CList_SetOffline(&user);
+		if (pmsg->prefix.sNick == m_info.sNick) {
 			GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
 			GCEVENT gce = { sizeof(gce), &gcd };
 			CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
 		}
 	}
-	else ShowMessage( pmsg );
+	else ShowMessage(pmsg);
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_PART(const CIrcMessage* pmsg)
 {
-	if ( pmsg->parameters.getCount() > 0 && pmsg->m_bIncoming ) {
+	if (pmsg->parameters.getCount() > 0 && pmsg->m_bIncoming) {
 		CMString host = pmsg->prefix.sUser + _T("@") + pmsg->prefix.sHost;
-		DoEvent(GC_EVENT_PART, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters.getCount()>1?pmsg->parameters[1].c_str():NULL, NULL, host.c_str(), NULL, true, false); 
-		if ( pmsg->prefix.sNick == m_info.sNick ) {
+		DoEvent(GC_EVENT_PART, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters.getCount() > 1 ? pmsg->parameters[1].c_str() : NULL, NULL, host.c_str(), NULL, true, false);
+		if (pmsg->prefix.sNick == m_info.sNick) {
 			CMString S = MakeWndID(pmsg->parameters[0].c_str());
 			GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
 			GCEVENT gce = { sizeof(gce), &gcd };
 			CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
 		}
 	}
-	else ShowMessage( pmsg ); 
+	else ShowMessage(pmsg);
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_KICK(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 )
-		DoEvent( GC_EVENT_KICK, pmsg->parameters[0].c_str(), pmsg->parameters[1].c_str(), pmsg->parameters.getCount()>2?pmsg->parameters[2].c_str():NULL, pmsg->prefix.sNick.c_str(), NULL, NULL, true, false); 
+	if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1)
+		DoEvent(GC_EVENT_KICK, pmsg->parameters[0].c_str(), pmsg->parameters[1].c_str(), pmsg->parameters.getCount() > 2 ? pmsg->parameters[2].c_str() : NULL, pmsg->prefix.sNick.c_str(), NULL, NULL, true, false);
 	else
-		ShowMessage( pmsg ); 
+		ShowMessage(pmsg);
 
-	if ( pmsg->parameters[1] == m_info.sNick ) {
-		CMString S = MakeWndID( pmsg->parameters[0].c_str());
+	if (pmsg->parameters[1] == m_info.sNick) {
+		CMString S = MakeWndID(pmsg->parameters[0].c_str());
 		GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
 		GCEVENT gce = { sizeof(gce), &gcd };
 		CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
 
-		if ( m_rejoinIfKicked ) {
+		if (m_rejoinIfKicked) {
 			CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
-			if ( wi && wi->pszPassword )
-				PostIrcMessage( _T("/JOIN %s %s"), pmsg->parameters[0].c_str(), wi->pszPassword);
+			if (wi && wi->pszPassword)
+				PostIrcMessage(_T("/JOIN %s %s"), pmsg->parameters[0].c_str(), wi->pszPassword);
 			else
-				PostIrcMessage( _T("/JOIN %s"), pmsg->parameters[0].c_str());
-	}	}
+				PostIrcMessage(_T("/JOIN %s"), pmsg->parameters[0].c_str());
+		}
+	}
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_MODEQUERY(const CIrcMessage* pmsg)
 {
-	if ( pmsg->parameters.getCount() > 2 && pmsg->m_bIncoming && IsChannel( pmsg->parameters[1] )) {
+	if (pmsg->parameters.getCount() > 2 && pmsg->m_bIncoming && IsChannel(pmsg->parameters[1])) {
 		CMString sPassword = _T("");
 		CMString sLimit = _T("");
 		bool bAdd = false;
 		int iParametercount = 3;
 
 		LPCTSTR p1 = pmsg->parameters[2].c_str();
-		while ( *p1 != '\0' ) {
-			if ( *p1 == '+' )
+		while (*p1 != '\0') {
+			if (*p1 == '+')
 				bAdd = true;
-			if ( *p1 == '-' )
+			if (*p1 == '-')
 				bAdd = false;
-			if ( *p1 == 'l' && bAdd ) {
-				if (( int )pmsg->parameters.getCount() > iParametercount )
-					sLimit = pmsg->parameters[ iParametercount ];
+			if (*p1 == 'l' && bAdd) {
+				if ((int)pmsg->parameters.getCount() > iParametercount)
+					sLimit = pmsg->parameters[iParametercount];
 				iParametercount++;
 			}
-			if ( *p1 == 'k' && bAdd ) {
-				if (( int )pmsg->parameters.getCount() > iParametercount )
-					sPassword = pmsg->parameters[ iParametercount ];
+			if (*p1 == 'k' && bAdd) {
+				if ((int)pmsg->parameters.getCount() > iParametercount)
+					sPassword = pmsg->parameters[iParametercount];
 				iParametercount++;
 			}
 
 			p1++;
 		}
 
-		AddWindowItemData( pmsg->parameters[1].c_str(), sLimit.IsEmpty() ? 0 : sLimit.c_str(), pmsg->parameters[2].c_str(), sPassword.IsEmpty() ? 0 : sPassword.c_str(), 0 );
+		AddWindowItemData(pmsg->parameters[1].c_str(), sLimit.IsEmpty() ? 0 : sLimit.c_str(), pmsg->parameters[2].c_str(), sPassword.IsEmpty() ? 0 : sPassword.c_str(), 0);
 	}
-	ShowMessage( pmsg );
+	ShowMessage(pmsg);
 	return true;
 }
 
 bool CIrcProto::OnIrc_MODE(const CIrcMessage* pmsg)
-{	
-	bool flag = false; 
+{
+	bool flag = false;
 	bool bContainsValidModes = false;
 	CMString sModes = _T("");
 	CMString sParams = _T("");
 
-	if ( pmsg->parameters.getCount() > 1 && pmsg->m_bIncoming ) {
-		if ( IsChannel( pmsg->parameters[0] )) {
+	if (pmsg->parameters.getCount() > 1 && pmsg->m_bIncoming) {
+		if (IsChannel(pmsg->parameters[0])) {
 			bool bAdd = false;
 			int  iParametercount = 2;
 			LPCTSTR p1 = pmsg->parameters[1].c_str();
 
-			while ( *p1 != '\0' ) {
-				if ( *p1 == '+' ) {
+			while (*p1 != '\0') {
+				if (*p1 == '+') {
 					bAdd = true;
 					sModes += _T("+");
 				}
-				if ( *p1 == '-' ) {
+				if (*p1 == '-') {
 					bAdd = false;
 					sModes += _T("-");
 				}
-				if ( *p1 == 'l' && bAdd && iParametercount < (int)pmsg->parameters.getCount()) {
+				if (*p1 == 'l' && bAdd && iParametercount < (int)pmsg->parameters.getCount()) {
 					bContainsValidModes = true;
 					sModes += _T("l");
 					sParams += _T(" ") + pmsg->parameters[iParametercount];
 					iParametercount++;
 				}
-				if ( *p1 == 'b' || *p1 == 'k' && iParametercount < (int)pmsg->parameters.getCount()) {
+				if (*p1 == 'b' || *p1 == 'k' && iParametercount < (int)pmsg->parameters.getCount()) {
 					bContainsValidModes = true;
 					sModes += *p1;
 					sParams += _T(" ") + pmsg->parameters[iParametercount];
 					iParametercount++;
 				}
-				if ( strchr( sUserModes.c_str(), (char)*p1 )) {
-					CMString sStatus = ModeToStatus( *p1 );
-					if (( int )pmsg->parameters.getCount() > iParametercount ) {	
-						if ( !_tcscmp(pmsg->parameters[2].c_str(), m_info.sNick.c_str())) {
+				if (strchr(sUserModes.c_str(), (char)*p1)) {
+					CMString sStatus = ModeToStatus(*p1);
+					if ((int)pmsg->parameters.getCount() > iParametercount) {
+						if (!_tcscmp(pmsg->parameters[2].c_str(), m_info.sNick.c_str())) {
 							char cModeBit = -1;
-							CHANNELINFO *wi = (CHANNELINFO *)DoEvent( GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, false, false, 0 );
+							CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, false, false, 0);
 							switch (*p1) {
-								case 'v':      cModeBit = 0;       break;
-								case 'h':      cModeBit = 1;       break;
-								case 'o':      cModeBit = 2;       break;
-								case 'a':      cModeBit = 3;       break;
-								case 'q':      cModeBit = 4;       break;
+							case 'v':      cModeBit = 0;       break;
+							case 'h':      cModeBit = 1;       break;
+							case 'o':      cModeBit = 2;       break;
+							case 'a':      cModeBit = 3;       break;
+							case 'q':      cModeBit = 4;       break;
 							}
 
 							// set bit for own mode on this channel (voice/hop/op/admin/owner)
-							if ( bAdd && cModeBit >= 0 )
-								wi->OwnMode |= ( 1 << cModeBit );
+							if (bAdd && cModeBit >= 0)
+								wi->OwnMode |= (1 << cModeBit);
 							else
-								wi->OwnMode &= ~( 1 << cModeBit );
+								wi->OwnMode &= ~(1 << cModeBit);
 
-							DoEvent( GC_EVENT_SETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, (DWORD_PTR)wi, false, false, 0 );
+							DoEvent(GC_EVENT_SETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, (DWORD_PTR)wi, false, false, 0);
 						}
-						DoEvent( bAdd ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS, pmsg->parameters[0].c_str(), pmsg->parameters[iParametercount].c_str(), pmsg->prefix.sNick.c_str(), sStatus.c_str(), NULL, NULL, m_oldStyleModes?false:true, false); 
+						DoEvent(bAdd ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS, pmsg->parameters[0].c_str(), pmsg->parameters[iParametercount].c_str(), pmsg->prefix.sNick.c_str(), sStatus.c_str(), NULL, NULL, m_oldStyleModes ? false : true, false);
 						iParametercount++;
 					}
 				}
-				else if (*p1 != 'b' && *p1 != ' ' && *p1 != '+' && *p1 != '-' ) {
+				else if (*p1 != 'b' && *p1 != ' ' && *p1 != '+' && *p1 != '-') {
 					bContainsValidModes = true;
 					if (*p1 != 'l' && *p1 != 'k')
 						sModes += *p1;
@@ -523,150 +528,150 @@ bool CIrcProto::OnIrc_MODE(const CIrcMessage* pmsg)
 				p1++;
 			}
 
-			if ( m_oldStyleModes ) {
+			if (m_oldStyleModes) {
 				TCHAR temp[256];
-				mir_sntprintf( temp, SIZEOF(temp), TranslateT("%s sets mode %s"), 
+				mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s sets mode %s"),
 					pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str());
-				
+
 				CMString sMessage = temp;
-				for ( int i=2; i < (int)pmsg->parameters.getCount(); i++ )
+				for (int i = 2; i < (int)pmsg->parameters.getCount(); i++)
 					sMessage += _T(" ") + pmsg->parameters[i];
 
-				DoEvent( GC_EVENT_INFORMATION, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), sMessage.c_str(), NULL, NULL, NULL, true, false ); 
+				DoEvent(GC_EVENT_INFORMATION, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), sMessage.c_str(), NULL, NULL, NULL, true, false);
 			}
-			else if ( bContainsValidModes ) {
-				for ( int i = iParametercount; i < (int)pmsg->parameters.getCount(); i++ )
+			else if (bContainsValidModes) {
+				for (int i = iParametercount; i < (int)pmsg->parameters.getCount(); i++)
 					sParams += _T(" ") + pmsg->parameters[i];
 
 				TCHAR temp[4000];
-				mir_sntprintf( temp, 3999, TranslateT(	"%s sets mode %s%s" ), pmsg->prefix.sNick.c_str(), sModes.c_str(), sParams.c_str());
-				DoEvent(GC_EVENT_INFORMATION, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), temp, NULL, NULL, NULL, true, false); 
+				mir_sntprintf(temp, 3999, TranslateT("%s sets mode %s%s"), pmsg->prefix.sNick.c_str(), sModes.c_str(), sParams.c_str());
+				DoEvent(GC_EVENT_INFORMATION, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
 			}
 
-			if ( flag )
-				PostIrcMessage( _T("/MODE %s"), pmsg->parameters[0].c_str());
+			if (flag)
+				PostIrcMessage(_T("/MODE %s"), pmsg->parameters[0].c_str());
 		}
 		else {
 			TCHAR temp[256];
-			mir_sntprintf( temp, SIZEOF(temp), TranslateT("%s sets mode %s"), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str());
+			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s sets mode %s"), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str());
 
 			CMString sMessage = temp;
-			for ( int i=2; i < (int)pmsg->parameters.getCount(); i++ )
+			for (int i = 2; i < (int)pmsg->parameters.getCount(); i++)
 				sMessage += _T(" ") + pmsg->parameters[i];
 
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, pmsg->prefix.sNick.c_str(), sMessage.c_str(), NULL, NULL, NULL, true, false); 
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, pmsg->prefix.sNick.c_str(), sMessage.c_str(), NULL, NULL, NULL, true, false);
 		}
 	}
-	else ShowMessage( pmsg ); 
+	else ShowMessage(pmsg);
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_NICK(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 0 ) {
+	if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 0) {
 		bool bIsMe = pmsg->prefix.sNick.c_str() == m_info.sNick ? true : false;
 
-		if ( m_info.sNick == pmsg->prefix.sNick && pmsg->parameters.getCount() > 0 ) {
+		if (m_info.sNick == pmsg->prefix.sNick && pmsg->parameters.getCount() > 0) {
 			m_info.sNick = pmsg->parameters[0];
 			setTString("Nick", m_info.sNick.c_str());
 		}
 
 		CMString host = pmsg->prefix.sUser + _T("@") + pmsg->prefix.sHost;
-		DoEvent(GC_EVENT_NICK, NULL, pmsg->prefix.sNick.c_str(), pmsg->parameters[0].c_str(), NULL, host.c_str(), NULL, true, bIsMe); 
-		DoEvent(GC_EVENT_CHUID, NULL, pmsg->prefix.sNick.c_str(), pmsg->parameters[0].c_str(), NULL, NULL, NULL, true, false); 
-		
-		struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false};
+		DoEvent(GC_EVENT_NICK, NULL, pmsg->prefix.sNick.c_str(), pmsg->parameters[0].c_str(), NULL, host.c_str(), NULL, true, bIsMe);
+		DoEvent(GC_EVENT_CHUID, NULL, pmsg->prefix.sNick.c_str(), pmsg->parameters[0].c_str(), NULL, NULL, NULL, true, false);
+
+		struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false };
 		HANDLE hContact = CList_FindContact(&user);
 		if (hContact) {
-			if ( getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
+			if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
 				setWord(hContact, "Status", ID_STATUS_ONLINE);
 			setTString(hContact, "Nick", pmsg->parameters[0].c_str());
 			setTString(hContact, "User", pmsg->prefix.sUser.c_str());
 			setTString(hContact, "Host", pmsg->prefix.sHost.c_str());
 		}
 	}
-	else ShowMessage( pmsg );
+	else ShowMessage(pmsg);
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_NOTICE(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) {
-		if ( IsCTCP( pmsg ))
+	if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) {
+		if (IsCTCP(pmsg))
 			return true;
 
-		if ( !m_ignore || !IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'n' )) {
+		if (!m_ignore || !IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'n')) {
 			CMString S;
 			CMString S2;
 			CMString S3;
-			if ( pmsg->prefix.sNick.GetLength() > 0 )
+			if (pmsg->prefix.sNick.GetLength() > 0)
 				S = pmsg->prefix.sNick;
 			else
 				S = m_info.sNetwork;
 			S3 = m_info.sNetwork;
-			if ( IsChannel( pmsg->parameters[0] ))
+			if (IsChannel(pmsg->parameters[0]))
 				S2 = pmsg->parameters[0].c_str();
 			else {
-				GC_INFO gci = {0};
+				GC_INFO gci = { 0 };
 				gci.Flags = BYID | TYPE;
 				gci.pszModule = m_szModuleName;
 
-				CMString S3 = GetWord( pmsg->parameters[1].c_str(), 0);
-				if ( S3[0] == '[' && S3[1] == '#' && S3[S3.GetLength()-1] == ']' ) {
-					S3.Delete(S3.GetLength()-1, 1);
-					S3.Delete(0,1);
-					CMString Wnd = MakeWndID( S3.c_str());
+				CMString S3 = GetWord(pmsg->parameters[1].c_str(), 0);
+				if (S3[0] == '[' && S3[1] == '#' && S3[S3.GetLength() - 1] == ']') {
+					S3.Delete(S3.GetLength() - 1, 1);
+					S3.Delete(0, 1);
+					CMString Wnd = MakeWndID(S3.c_str());
 					gci.pszID = Wnd.c_str();
-					if ( !CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci ) && gci.iType == GCW_CHATROOM )
-						S2 = GetWord( gci.pszID, 0 );
+					if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.iType == GCW_CHATROOM)
+						S2 = GetWord(gci.pszID, 0);
 					else
 						S2 = _T("");
 				}
 				else S2 = _T("");
 			}
-			DoEvent(GC_EVENT_NOTICE, S2.IsEmpty() ? 0 : S2.c_str(), S.c_str(), pmsg->parameters[1].c_str(), NULL, S3.c_str(), NULL, true, false); 
+			DoEvent(GC_EVENT_NOTICE, S2.IsEmpty() ? 0 : S2.c_str(), S.c_str(), pmsg->parameters[1].c_str(), NULL, S3.c_str(), NULL, true, false);
 		}
 	}
-	else ShowMessage( pmsg );
+	else ShowMessage(pmsg);
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_YOURHOST(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming ) {
+	if (pmsg->m_bIncoming) {
 		static const TCHAR* lpszFmt = _T("Your host is %99[^ \x5b,], running version %99s");
 		TCHAR szHostName[100], szVersion[100];
-		if ( _stscanf(pmsg->parameters[1].c_str(), lpszFmt, &szHostName, &szVersion) > 0 )
+		if (_stscanf(pmsg->parameters[1].c_str(), lpszFmt, &szHostName, &szVersion) > 0)
 			m_info.sServerName = szHostName;
-		if ( pmsg->parameters[0] != m_info.sNick)
+		if (pmsg->parameters[0] != m_info.sNick)
 			m_info.sNick = pmsg->parameters[0];
 	}
-	
-	ShowMessage( pmsg );
+
+	ShowMessage(pmsg);
 	return true;
 }
 
 bool CIrcProto::OnIrc_INVITE(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming && ( m_ignore && IsIgnored( pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'i' )))
+	if (pmsg->m_bIncoming && (m_ignore && IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'i')))
 		return true;
 
-	if ( pmsg->m_bIncoming && m_joinOnInvite && pmsg->parameters.getCount() >1 && lstrcmpi(pmsg->parameters[0].c_str(), m_info.sNick.c_str()) == 0 ) 
-		PostIrcMessage( _T("/JOIN %s"), pmsg->parameters[1].c_str());
+	if (pmsg->m_bIncoming && m_joinOnInvite && pmsg->parameters.getCount() > 1 && lstrcmpi(pmsg->parameters[0].c_str(), m_info.sNick.c_str()) == 0)
+		PostIrcMessage(_T("/JOIN %s"), pmsg->parameters[1].c_str());
 
-	ShowMessage( pmsg );
+	ShowMessage(pmsg);
 	return true;
 }
 
 bool CIrcProto::OnIrc_PINGPONG(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming && pmsg->sCommand == _T("PING")) {
+	if (pmsg->m_bIncoming && pmsg->sCommand == _T("PING")) {
 		TCHAR szResponse[100];
 		mir_sntprintf(szResponse, SIZEOF(szResponse), _T("PONG %s"), pmsg->parameters[0].c_str());
-		SendIrcMessage( szResponse );
+		SendIrcMessage(szResponse);
 	}
 
 	return true;
@@ -674,25 +679,25 @@ bool CIrcProto::OnIrc_PINGPONG(const CIrcMessage* pmsg)
 
 bool CIrcProto::OnIrc_PRIVMSG(const CIrcMessage* pmsg)
 {
-	if ( pmsg->parameters.getCount() > 1 ) {
-		if ( IsCTCP( pmsg ))
+	if (pmsg->parameters.getCount() > 1) {
+		if (IsCTCP(pmsg))
 			return true;
 
 		CMString mess = pmsg->parameters[1];
 		bool bIsChannel = IsChannel(pmsg->parameters[0]);
 
-		if ( pmsg->m_bIncoming && !bIsChannel ) {
-			mess = DoColorCodes( mess.c_str(), TRUE, FALSE );
+		if (pmsg->m_bIncoming && !bIsChannel) {
+			mess = DoColorCodes(mess.c_str(), TRUE, FALSE);
 
-			struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false};
+			struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false };
 
-			if ( CallService(MS_IGNORE_ISIGNORED, NULL, IGNOREEVENT_MESSAGE)) 
-				if ( !CList_FindContact(&user))
-					return true;
+			if (CallService(MS_IGNORE_ISIGNORED, NULL, IGNOREEVENT_MESSAGE))
+			if (!CList_FindContact(&user))
+				return true;
 
-			if (( m_ignore && IsIgnored( pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'q' ))) {
+			if ((m_ignore && IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'q'))) {
 				HANDLE hContact = CList_FindContact(&user);
-				if ( !hContact || ( hContact && db_get_b( hContact,"CList", "Hidden", 0) == 1 ))
+				if (!hContact || (hContact && db_get_b(hContact, "CList", "Hidden", 0) == 1))
 					return true;
 			}
 
@@ -701,24 +706,25 @@ bool CIrcProto::OnIrc_PRIVMSG(const CIrcMessage* pmsg)
 			PROTORECVEVENT pre = { 0 };
 			pre.timestamp = (DWORD)time(NULL);
 			pre.flags = PREF_UTF;
-			pre.szMessage = mir_utf8encodeW( mess.c_str());
+			pre.szMessage = mir_utf8encodeW(mess.c_str());
 			setTString(hContact, "User", pmsg->prefix.sUser.c_str());
 			setTString(hContact, "Host", pmsg->prefix.sHost.c_str());
 			ProtoChainRecvMsg(hContact, &pre);
-			mir_free( pre.szMessage );
+			mir_free(pre.szMessage);
 			return true;
 		}
-		
-		if ( bIsChannel ) {
-			if ( !(pmsg->m_bIncoming && m_ignore && IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'm' ))) {
-				if ( !pmsg->m_bIncoming )
-					ReplaceString( mess, _T("%%"), _T("%"));
-				DoEvent(GC_EVENT_MESSAGE, pmsg->parameters[0].c_str(), pmsg->m_bIncoming?pmsg->prefix.sNick.c_str():m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming?false:true); 				
+
+		if (bIsChannel) {
+			if (!(pmsg->m_bIncoming && m_ignore && IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'm'))) {
+				if (!pmsg->m_bIncoming)
+					ReplaceString(mess, _T("%%"), _T("%"));
+				DoEvent(GC_EVENT_MESSAGE, pmsg->parameters[0].c_str(), pmsg->m_bIncoming ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming ? false : true);
 			}
 			return true;
-	}	}
+		}
+	}
 
-	ShowMessage( pmsg );
+	ShowMessage(pmsg);
 	return true;
 }
 
@@ -726,18 +732,18 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg)
 {
 	// is it a ctcp command, i e is the first and last characer of a PRIVMSG or NOTICE text ASCII 1
 	CMString mess = pmsg->parameters[1];
-	if ( !( mess.GetLength() > 3 && mess[0] == 1 && mess[ mess.GetLength()-1] == 1 ))
+	if (!(mess.GetLength() > 3 && mess[0] == 1 && mess[mess.GetLength() - 1] == 1))
 		return false;
 
 	// set mess to contain the ctcp command, excluding the leading and trailing  ASCII 1
-	mess.Delete(0,1);
-	mess.Delete(mess.GetLength()-1,1);
-	
+	mess.Delete(0, 1);
+	mess.Delete(mess.GetLength() - 1, 1);
+
 	// exploit???
-	if ( mess.Find(1) != -1 || mess.Find( _T("%newl")) != -1 ) {
+	if (mess.Find(1) != -1 || mess.Find(_T("%newl")) != -1) {
 		TCHAR temp[4096];
-		mir_sntprintf(temp, SIZEOF(temp), TranslateT( "CTCP ERROR: Malformed CTCP command received from %s!%s@%s. Possible attempt to take control of your IRC client registered"), pmsg->prefix.sNick.c_str(), pmsg->prefix.sUser.c_str(), pmsg->prefix.sHost.c_str());
-		DoEvent( GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false); 
+		mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP ERROR: Malformed CTCP command received from %s!%s@%s. Possible attempt to take control of your IRC client registered"), pmsg->prefix.sNick.c_str(), pmsg->prefix.sUser.c_str(), pmsg->prefix.sHost.c_str());
+		DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
 		return true;
 	}
 
@@ -747,40 +753,40 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg)
 	command.MakeLower();
 
 	// should it be ignored?
-	if ( m_ignore ) {
-		if ( IsChannel( pmsg->parameters[0] )) {
-			if ( command == _T("action") && IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'm'))
+	if (m_ignore) {
+		if (IsChannel(pmsg->parameters[0])) {
+			if (command == _T("action") && IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'm'))
 				return true;
 		}
 		else {
-			if ( command == _T("action")) {
-				if ( IsIgnored( pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'q' ))
+			if (command == _T("action")) {
+				if (IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'q'))
 					return true;
 			}
-			else if ( command == _T("dcc")) {
-				if ( IsIgnored( pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'd' ))
+			else if (command == _T("dcc")) {
+				if (IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'd'))
 					return true;
 			}
-			else if ( IsIgnored( pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'c' ))
+			else if (IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'c'))
 				return true;
-	}	}
+		}
+	}
 
-	if ( pmsg->sCommand == _T("PRIVMSG")) {
+	if (pmsg->sCommand == _T("PRIVMSG")) {
 		// incoming ACTION
-		if ( command == _T("action")) {
-			mess.Delete(0,6);
+		if (command == _T("action")) {
+			mess.Delete(0, 6);
 
-			if ( IsChannel( pmsg->parameters[0] )) {
-				if ( mess.GetLength() > 1 ) {
-					mess.Delete(0,1);
-					if ( !pmsg->m_bIncoming )
+			if (IsChannel(pmsg->parameters[0])) {
+				if (mess.GetLength() > 1) {
+					mess.Delete(0, 1);
+					if (!pmsg->m_bIncoming)
 						ReplaceString(mess, _T("%%"), _T("%"));
 
-					DoEvent(GC_EVENT_ACTION, pmsg->parameters[0].c_str(), pmsg->m_bIncoming?pmsg->prefix.sNick.c_str():m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming?false:true); 
+					DoEvent(GC_EVENT_ACTION, pmsg->parameters[0].c_str(), pmsg->m_bIncoming ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming ? false : true);
 				}
 			}
-			else if (pmsg->m_bIncoming)
-			{
+			else if (pmsg->m_bIncoming) {
 				mess.Insert(0, pmsg->prefix.sNick.c_str());
 				mess.Insert(0, _T("* "));
 				mess.Insert(mess.GetLength(), _T(" *"));
@@ -791,58 +797,58 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg)
 		}
 		// incoming FINGER
 		else if (pmsg->m_bIncoming && command == _T("finger")) {
-			PostIrcMessage( _T("/NOTICE %s \001FINGER %s (%s)\001"), pmsg->prefix.sNick.c_str(), m_name, m_userID);
-			
+			PostIrcMessage(_T("/NOTICE %s \001FINGER %s (%s)\001"), pmsg->prefix.sNick.c_str(), m_name, m_userID);
+
 			TCHAR temp[300];
-			mir_sntprintf( temp, SIZEOF(temp), TranslateT("CTCP FINGER requested by %s"), pmsg->prefix.sNick.c_str());
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); 
+			mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP FINGER requested by %s"), pmsg->prefix.sNick.c_str());
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false);
 		}
 
 		// incoming VERSION
 		else if (pmsg->m_bIncoming && command == _T("version")) {
-			PostIrcMessage( _T("/NOTICE %s \001VERSION Miranda NG %%mirver (IRC v.%%version), (c) 2003-2014 J.Persson, G.Hazan\001"), pmsg->prefix.sNick.c_str());
-				
+			PostIrcMessage(_T("/NOTICE %s \001VERSION Miranda NG %%mirver (IRC v.%%version), (c) 2003-2014 J.Persson, G.Hazan\001"), pmsg->prefix.sNick.c_str());
+
 			TCHAR temp[300];
-			mir_sntprintf( temp, SIZEOF(temp), TranslateT("CTCP VERSION requested by %s"), pmsg->prefix.sNick.c_str());
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); 
+			mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP VERSION requested by %s"), pmsg->prefix.sNick.c_str());
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false);
 		}
 
 		// incoming SOURCE
 		else if (pmsg->m_bIncoming && command == _T("source")) {
-			PostIrcMessage( _T("/NOTICE %s \001SOURCE Get Miranda IRC here: http://miranda-ng.org/ \001"), pmsg->prefix.sNick.c_str());
-			
+			PostIrcMessage(_T("/NOTICE %s \001SOURCE Get Miranda IRC here: http://miranda-ng.org/ \001"), pmsg->prefix.sNick.c_str());
+
 			TCHAR temp[300];
-			mir_sntprintf( temp, SIZEOF(temp), TranslateT("CTCP SOURCE requested by %s"), pmsg->prefix.sNick.c_str());
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); 
+			mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP SOURCE requested by %s"), pmsg->prefix.sNick.c_str());
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false);
 		}
 
 		// incoming USERINFO
 		else if (pmsg->m_bIncoming && command == _T("userinfo")) {
-			PostIrcMessage( _T("/NOTICE %s \001USERINFO %s\001"), pmsg->prefix.sNick.c_str(), m_userInfo );
-			
+			PostIrcMessage(_T("/NOTICE %s \001USERINFO %s\001"), pmsg->prefix.sNick.c_str(), m_userInfo);
+
 			TCHAR temp[300];
-			mir_sntprintf( temp, SIZEOF(temp), TranslateT("CTCP USERINFO requested by %s") , pmsg->prefix.sNick.c_str());
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); 
+			mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP USERINFO requested by %s"), pmsg->prefix.sNick.c_str());
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false);
 		}
 
 		// incoming PING
 		else if (pmsg->m_bIncoming && command == _T("ping")) {
-			PostIrcMessage( _T("/NOTICE %s \001%s\001"), pmsg->prefix.sNick.c_str(), mess.c_str());
-			
+			PostIrcMessage(_T("/NOTICE %s \001%s\001"), pmsg->prefix.sNick.c_str(), mess.c_str());
+
 			TCHAR temp[300];
-			mir_sntprintf( temp, SIZEOF(temp), TranslateT("CTCP PING requested by %s"), pmsg->prefix.sNick.c_str());
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); 
+			mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP PING requested by %s"), pmsg->prefix.sNick.c_str());
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false);
 		}
 
 		// incoming TIME
 		else if (pmsg->m_bIncoming && command == _T("time")) {
 			TCHAR temp[300];
 			time_t tim = time(NULL);
-			lstrcpyn( temp, _tctime( &tim ), 25 );
-			PostIrcMessage( _T("/NOTICE %s \001TIME %s\001"), pmsg->prefix.sNick.c_str(), temp);
-			
+			lstrcpyn(temp, _tctime(&tim), 25);
+			PostIrcMessage(_T("/NOTICE %s \001TIME %s\001"), pmsg->prefix.sNick.c_str(), temp);
+
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP TIME requested by %s"), pmsg->prefix.sNick.c_str());
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); 
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false);
 		}
 
 		// incoming DCC request... lots of stuff happening here...
@@ -856,63 +862,65 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg)
 			int iPort = 0;
 			unsigned __int64 dwSize = 0;
 			CMString sToken = _T("");
-			bool bIsChat = ( type == _T("chat"));
+			bool bIsChat = (type == _T("chat"));
 
 			// 1. separate the dcc command into the correct pieces
-			if ( bIsChat || type == _T("send")) {
+			if (bIsChat || type == _T("send")) {
 				// if the filename is surrounded by quotes, do this
-				if ( GetWord(mess.c_str(), 2)[0] == '\"' ) {
+				if (GetWord(mess.c_str(), 2)[0] == '\"') {
 					int end = 0;
 					int begin = mess.Find('\"', 0);
-					if ( begin >= 0 ) {
-						end = mess.Find('\"', begin + 1); 
-						if ( end >= 0 ) {
-							sFile = mess.Mid(begin+1, end-begin-1);
+					if (begin >= 0) {
+						end = mess.Find('\"', begin + 1);
+						if (end >= 0) {
+							sFile = mess.Mid(begin + 1, end - begin - 1);
 
 							begin = mess.Find(' ', end);
-							if ( begin >= 0 ) {
+							if (begin >= 0) {
 								CMString rest = mess.Mid(begin, mess.GetLength());
 								dwAdr = _tcstoul(GetWord(rest.c_str(), 0).c_str(), NULL, 10);
 								iPort = _ttoi(GetWord(rest.c_str(), 1).c_str());
 								dwSize = _ttoi64(GetWord(rest.c_str(), 2).c_str());
 								sToken = GetWord(rest.c_str(), 3);
-					}	}	}
+							}
+						}
+					}
 				}
 				// ... or try another method of separating the dcc command
-				else if ( !GetWord(mess.c_str(), (bIsChat) ? 4 : 5 ).IsEmpty()) {
+				else if (!GetWord(mess.c_str(), (bIsChat) ? 4 : 5).IsEmpty()) {
 					int index = (bIsChat) ? 4 : 5;
 					bool bFlag = false;
 
 					// look for the part of the ctcp command that contains adress, port and size
-					while ( !bFlag && !GetWord(mess.c_str(), index).IsEmpty()) {
+					while (!bFlag && !GetWord(mess.c_str(), index).IsEmpty()) {
 						CMString sTemp;
-						
-						if ( type == _T("chat"))
-							sTemp = GetWord(mess.c_str(), index-1) + GetWord(mess.c_str(), index);
-						else	
-							sTemp = GetWord(mess.c_str(), index-2) + GetWord(mess.c_str(), index-1) + GetWord(mess.c_str(), index);
-						
+
+						if (type == _T("chat"))
+							sTemp = GetWord(mess.c_str(), index - 1) + GetWord(mess.c_str(), index);
+						else
+							sTemp = GetWord(mess.c_str(), index - 2) + GetWord(mess.c_str(), index - 1) + GetWord(mess.c_str(), index);
+
 						// if all characters are number it indicates we have found the adress, port and size parameters
 						int ind = 0;
-						while ( sTemp[ind] != '\0' ) {
-							if ( !_istdigit( sTemp[ind] ))
+						while (sTemp[ind] != '\0') {
+							if (!_istdigit(sTemp[ind]))
 								break;
 							ind++;
 						}
-						
-						if ( sTemp[ind] == '\0' && GetWord( mess.c_str(), index + ((bIsChat) ? 1 : 2 )).IsEmpty())
+
+						if (sTemp[ind] == '\0' && GetWord(mess.c_str(), index + ((bIsChat) ? 1 : 2)).IsEmpty())
 							bFlag = true;
 						index++;
 					}
-					
-					if ( bFlag ) {
-						TCHAR* p1 = _tcsdup( GetWordAddress(mess.c_str(), 2 ));
-						TCHAR* p2 = ( TCHAR* )GetWordAddress( p1, index-5 );
-						
-						if ( type == _T("send")) {
-							if ( p2 > p1 ) {
+
+					if (bFlag) {
+						TCHAR* p1 = _tcsdup(GetWordAddress(mess.c_str(), 2));
+						TCHAR* p2 = (TCHAR*)GetWordAddress(p1, index - 5);
+
+						if (type == _T("send")) {
+							if (p2 > p1) {
 								p2--;
-								while( p2 != p1 && *p2 == ' ' ) {
+								while (p2 != p1 && *p2 == ' ') {
 									*p2 = '\0';
 									p2--;
 								}
@@ -921,211 +929,218 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg)
 						}
 						else sFile = _T("chat");
 
-						free( p1 );
+						free(p1);
 
-						dwAdr = _tcstoul(GetWord(mess.c_str(), index - (bIsChat?2:3)).c_str(), NULL, 10);
-						iPort = _ttoi(GetWord(mess.c_str(), index - (bIsChat?1:2)).c_str());
-						dwSize = _ttoi64(GetWord(mess.c_str(), index-1).c_str());
+						dwAdr = _tcstoul(GetWord(mess.c_str(), index - (bIsChat ? 2 : 3)).c_str(), NULL, 10);
+						iPort = _ttoi(GetWord(mess.c_str(), index - (bIsChat ? 1 : 2)).c_str());
+						dwSize = _ttoi64(GetWord(mess.c_str(), index - 1).c_str());
 						sToken = GetWord(mess.c_str(), index);
-				}	} 
+					}
+				}
 			}
 			else if (type == _T("accept") || type == _T("resume")) {
 				// if the filename is surrounded by quotes, do this
-				if ( GetWord(mess.c_str(), 2)[0] == '\"' ) {
+				if (GetWord(mess.c_str(), 2)[0] == '\"') {
 					int end = 0;
 					int begin = mess.Find('\"', 0);
-					if ( begin >= 0 ) {
-						end = mess.Find('\"', begin + 1); 
-						if ( end >= 0 ) {
-							sFile = mess.Mid(begin+1, end);
+					if (begin >= 0) {
+						end = mess.Find('\"', begin + 1);
+						if (end >= 0) {
+							sFile = mess.Mid(begin + 1, end);
 
 							begin = mess.Find(' ', end);
-							if ( begin >= 0 ) {
+							if (begin >= 0) {
 								CMString rest = mess.Mid(begin, mess.GetLength());
 								iPort = _ttoi(GetWord(rest.c_str(), 0).c_str());
 								dwSize = _ttoi(GetWord(rest.c_str(), 1).c_str());
 								sToken = GetWord(rest.c_str(), 2);
-					}	}	}
+							}
+						}
+					}
 				}
 				// ... or try another method of separating the dcc command
-				else if ( !GetWord(mess.c_str(), 4).IsEmpty()) {
+				else if (!GetWord(mess.c_str(), 4).IsEmpty()) {
 					int index = 4;
 					bool bFlag = false;
 
 					// look for the part of the ctcp command that contains adress, port and size
-					while ( !bFlag && !GetWord(mess.c_str(), index).IsEmpty()) {
-						CMString sTemp = GetWord(mess.c_str(), index-1) + GetWord(mess.c_str(), index);
-						
+					while (!bFlag && !GetWord(mess.c_str(), index).IsEmpty()) {
+						CMString sTemp = GetWord(mess.c_str(), index - 1) + GetWord(mess.c_str(), index);
+
 						// if all characters are number it indicates we have found the adress, port and size parameters
 						int ind = 0;
 
-						while ( sTemp[ind] != '\0' ) {
-							if ( !_istdigit( sTemp[ind] ))
+						while (sTemp[ind] != '\0') {
+							if (!_istdigit(sTemp[ind]))
 								break;
 							ind++;
 						}
-						
-						if ( sTemp[ind] == '\0' && GetWord(mess.c_str(), index + 2).IsEmpty())
+
+						if (sTemp[ind] == '\0' && GetWord(mess.c_str(), index + 2).IsEmpty())
 							bFlag = true;
 						index++;
 					}
-					if ( bFlag ) {
+					if (bFlag) {
 						TCHAR* p1 = _tcsdup(GetWordAddress(mess.c_str(), 2));
-						TCHAR* p2 = ( TCHAR* )GetWordAddress(p1, index-4);
-						
-						if ( p2 > p1 ) {
+						TCHAR* p2 = (TCHAR*)GetWordAddress(p1, index - 4);
+
+						if (p2 > p1) {
 							p2--;
-							while( p2 != p1 && *p2 == ' ' ) {
+							while (p2 != p1 && *p2 == ' ') {
 								*p2 = '\0';
 								p2--;
 							}
 							sFile = p1;
 						}
 
-						free( p1 );
+						free(p1);
 
-						iPort = _ttoi(GetWord(mess.c_str(), index-2).c_str());
-						dwSize = _ttoi64(GetWord(mess.c_str(), index-1).c_str());
+						iPort = _ttoi(GetWord(mess.c_str(), index - 2).c_str());
+						dwSize = _ttoi64(GetWord(mess.c_str(), index - 1).c_str());
 						sToken = GetWord(mess.c_str(), index);
-			}	}	} 
+					}
+				}
+			}
 			// end separating dcc commands
 
 			// 2. Check for malformed dcc commands or other errors
-			if ( bIsChat || type == _T("send")) {
+			if (bIsChat || type == _T("send")) {
 				TCHAR szTemp[256];
 				szTemp[0] = '\0';
 
 				unsigned long ulAdr = 0;
-				if ( m_manualHost )
-					ulAdr = ConvertIPToInteger( m_mySpecifiedHostIP );
+				if (m_manualHost)
+					ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
 				else
-					ulAdr = ConvertIPToInteger( m_IPFromServer ? m_myHost : m_myLocalHost );
+					ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
+
+				if (bIsChat && !m_DCCChatEnabled)
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: Chat request from %s denied"), pmsg->prefix.sNick.c_str());
 
-				if ( bIsChat && !m_DCCChatEnabled)
-					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: Chat request from %s denied"),pmsg->prefix.sNick.c_str());
+				else if (type == _T("send") && !m_DCCFileEnabled)
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: File transfer request from %s denied"), pmsg->prefix.sNick.c_str());
 
-				else if(type == _T("send") && !m_DCCFileEnabled)
-					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: File transfer request from %s denied"),pmsg->prefix.sNick.c_str());
+				else if (type == _T("send") && !iPort && ulAdr == 0)
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: Reverse file transfer request from %s denied [No local IP]"), pmsg->prefix.sNick.c_str());
 
-				else if(type == _T("send") && !iPort && ulAdr == 0)
-					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: Reverse file transfer request from %s denied [No local IP]"),pmsg->prefix.sNick.c_str());
+				if (sFile.IsEmpty() || dwAdr == 0 || dwSize == 0 || iPort == 0 && sToken.IsEmpty())
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Malformed CTCP request from %s [%s]"), pmsg->prefix.sNick.c_str(), mess.c_str());
 
-				if ( sFile.IsEmpty() || dwAdr == 0 || dwSize == 0 || iPort == 0 && sToken.IsEmpty())
-					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Malformed CTCP request from %s [%s]"),pmsg->prefix.sNick.c_str(), mess.c_str());
-			
-				if ( szTemp[0] ) {
-					DoEvent( GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false); 
+				if (szTemp[0]) {
+					DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 					return true;
 				}
 
 				// remove path from the filename if the remote client (stupidly) sent it
 				CMString sFileCorrected = sFile;
-				int i = sFile.ReverseFind( '\\' );
-				if (i != -1 )
-					sFileCorrected = sFile.Mid(i+1, sFile.GetLength());
+				int i = sFile.ReverseFind('\\');
+				if (i != -1)
+					sFileCorrected = sFile.Mid(i + 1, sFile.GetLength());
 				sFile = sFileCorrected;
 			}
-			else if ( type == _T("accept") || type == _T("resume")) {
+			else if (type == _T("accept") || type == _T("resume")) {
 				TCHAR szTemp[256];
 				szTemp[0] = '\0';
 
-				if ( type == _T("resume") && !m_DCCFileEnabled)
-					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: File transfer resume request from %s denied"),pmsg->prefix.sNick.c_str());
+				if (type == _T("resume") && !m_DCCFileEnabled)
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: File transfer resume request from %s denied"), pmsg->prefix.sNick.c_str());
+
+				if (sToken.IsEmpty() && iPort == 0 || sFile.IsEmpty())
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Malformed CTCP request from %s [%s]"), pmsg->prefix.sNick.c_str(), mess.c_str());
 
-				if ( sToken.IsEmpty() && iPort == 0 || sFile.IsEmpty())
-					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Malformed CTCP request from %s [%s]"),pmsg->prefix.sNick.c_str(), mess.c_str());
-			
-				if ( szTemp[0] ) {
-					DoEvent( GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false); 
+				if (szTemp[0]) {
+					DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 					return true;
 				}
 
 				// remove path from the filename if the remote client (stupidly) sent it
 				CMString sFileCorrected = sFile;
-				int i = sFile.ReverseFind( '\\' );
-				if ( i != -1 )
-					sFileCorrected = sFile.Mid(i+1, sFile.GetLength());
+				int i = sFile.ReverseFind('\\');
+				if (i != -1)
+					sFileCorrected = sFile.Mid(i + 1, sFile.GetLength());
 				sFile = sFileCorrected;
 			}
 
 			// 3. Take proper actions considering type of command
 
 			// incoming chat request
-			if ( bIsChat ) {
-				CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), 0, 0, false, false, true};
-				HANDLE hContact = CList_FindContact( &user );
+			if (bIsChat) {
+				CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), 0, 0, false, false, true };
+				HANDLE hContact = CList_FindContact(&user);
 
 				// check if it should be ignored
-				if ( m_DCCChatIgnore == 1 || 
-					m_DCCChatIgnore == 2 && hContact && 
-					db_get_b(hContact,"CList", "NotOnList", 0) == 0 && 
-					db_get_b(hContact,"CList", "Hidden", 0) == 0)
-				{
+				if (m_DCCChatIgnore == 1 ||
+					m_DCCChatIgnore == 2 && hContact &&
+					db_get_b(hContact, "CList", "NotOnList", 0) == 0 &&
+					db_get_b(hContact, "CList", "Hidden", 0) == 0) {
 					CMString host = pmsg->prefix.sUser + _T("@") + pmsg->prefix.sHost;
 					CList_AddDCCChat(pmsg->prefix.sNick, host, dwAdr, iPort); // add a CHAT event to the clist
 				}
 				else {
 					TCHAR szTemp[512];
-					mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("DCC: Chat request from %s denied"),pmsg->prefix.sNick.c_str());
-					DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false); 
-			}	}
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC: Chat request from %s denied"), pmsg->prefix.sNick.c_str());
+					DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
+				}
+			}
 
 			// remote requested that the file should be resumed
-			if ( type == _T("resume")) {
+			if (type == _T("resume")) {
 				CDccSession* dcc;
-				if ( sToken.IsEmpty())
-					dcc = FindDCCSendByPort( iPort );
+				if (sToken.IsEmpty())
+					dcc = FindDCCSendByPort(iPort);
 				else
-					dcc = FindPassiveDCCSend( _ttoi( sToken.c_str())); // reverse ft
+					dcc = FindPassiveDCCSend(_ttoi(sToken.c_str())); // reverse ft
 
-				if ( dcc ) {
+				if (dcc) {
 					InterlockedExchange(&dcc->dwWhatNeedsDoing, (long)FILERESUME_RESUME);
 					dcc->dwResumePos = dwSize; // dwSize is the resume position
-					PostIrcMessage( _T("/PRIVMSG %s \001DCC ACCEPT %s\001"), pmsg->prefix.sNick.c_str(), GetWordAddress(mess.c_str(), 2));
-			}	}
+					PostIrcMessage(_T("/PRIVMSG %s \001DCC ACCEPT %s\001"), pmsg->prefix.sNick.c_str(), GetWordAddress(mess.c_str(), 2));
+				}
+			}
 
 			// remote accepted your request for a file resume
-			if ( type == _T("accept")) {
+			if (type == _T("accept")) {
 				CDccSession* dcc;
-				if ( sToken.IsEmpty())
+				if (sToken.IsEmpty())
 					dcc = FindDCCRecvByPortAndName(iPort, pmsg->prefix.sNick.c_str());
 				else
 					dcc = FindPassiveDCCRecv(pmsg->prefix.sNick, sToken); // reverse ft
 
-				if ( dcc ) {
-					InterlockedExchange( &dcc->dwWhatNeedsDoing, (long)FILERESUME_RESUME );
+				if (dcc) {
+					InterlockedExchange(&dcc->dwWhatNeedsDoing, (long)FILERESUME_RESUME);
 					dcc->dwResumePos = dwSize;	// dwSize is the resume position					
-					SetEvent( dcc->hEvent );
-			}	}
+					SetEvent(dcc->hEvent);
+				}
+			}
 
-			if ( type == _T("send")) {
+			if (type == _T("send")) {
 				CMString sTokenBackup = sToken;
 				bool bTurbo = false; // TDCC indicator
 
-				if ( !sToken.IsEmpty() && sToken[sToken.GetLength()-1] == 'T' ) {
+				if (!sToken.IsEmpty() && sToken[sToken.GetLength() - 1] == 'T') {
 					bTurbo = true;
-					sToken.Delete(sToken.GetLength()-1,1);
+					sToken.Delete(sToken.GetLength() - 1, 1);
 				}
 
 				// if a token exists and the port is non-zero it is the remote
 				// computer telling us that is has accepted to act as server for
 				// a reverse filetransfer. The plugin should connect to that computer
 				// and start sedning the file (if the token is valid). Compare to DCC RECV
-				if ( !sToken.IsEmpty() && iPort ) {
-					CDccSession* dcc = FindPassiveDCCSend( _ttoi( sToken.c_str()));
-					if ( dcc ) {
-						dcc->SetupPassive( dwAdr, iPort );
+				if (!sToken.IsEmpty() && iPort) {
+					CDccSession* dcc = FindPassiveDCCSend(_ttoi(sToken.c_str()));
+					if (dcc) {
+						dcc->SetupPassive(dwAdr, iPort);
 						dcc->Connect();
 					}
 				}
 				else {
-					struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false};
-					if ( CallService(MS_IGNORE_ISIGNORED, NULL, IGNOREEVENT_FILE))
-						if ( !CList_FindContact(&user))
-							return true;
+					struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false };
+					if (CallService(MS_IGNORE_ISIGNORED, NULL, IGNOREEVENT_FILE))
+					if (!CList_FindContact(&user))
+						return true;
 
-					HANDLE hContact = CList_AddContact( &user, false, true );
-					if ( hContact ) {
+					HANDLE hContact = CList_AddContact(&user, false, true);
+					if (hContact) {
 						DCCINFO* di = new DCCINFO;
 						di->hContact = hContact;
 						di->sFile = sFile;
@@ -1138,112 +1153,119 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg)
 						di->bTurbo = bTurbo;
 						di->bSSL = false;
 						di->bReverse = (iPort == 0 && !sToken.IsEmpty()) ? true : false;
-						if ( di->bReverse )
+						if (di->bReverse)
 							di->sToken = sTokenBackup;
 
 						setTString(hContact, "User", pmsg->prefix.sUser.c_str());
 						setTString(hContact, "Host", pmsg->prefix.sHost.c_str());
 
-						TCHAR* tszTemp = ( TCHAR* )sFile.c_str();
+						TCHAR* tszTemp = (TCHAR*)sFile.c_str();
 
-						PROTORECVFILET pre = {0};
+						PROTORECVFILET pre = { 0 };
 						pre.flags = PREF_TCHAR;
 						pre.timestamp = (DWORD)time(NULL);
 						pre.fileCount = 1;
-						pre.ptszFiles = &tszTemp;						
+						pre.ptszFiles = &tszTemp;
 						pre.lParam = (LPARAM)di;
 						ProtoChainRecvFile(hContact, &pre);
-			}	}	}
+					}
+				}
+			}
 			// end type == "send"
 		}
-		else if ( pmsg->m_bIncoming ) {
+		else if (pmsg->m_bIncoming) {
 			TCHAR temp[300];
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP %s requested by %s"), ocommand.c_str(), pmsg->prefix.sNick.c_str());
-			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); 
-	}	}
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false);
+		}
+	}
 
 	// handle incoming ctcp in notices. This technique is used for replying to CTCP queries
-	else if(pmsg->sCommand == _T("NOTICE")) {
-		TCHAR szTemp[300]; 
+	else if (pmsg->sCommand == _T("NOTICE")) {
+		TCHAR szTemp[300];
 		szTemp[0] = '\0';
 
 		//if we got incoming CTCP Version for contact in CList - then write its as MirVer for that contact!
-		if (pmsg->m_bIncoming && command == _T("version"))
-			{
-			struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false};
+		if (pmsg->m_bIncoming && command == _T("version")) {
+			struct CONTACT user = { (TCHAR*)pmsg->prefix.sNick.c_str(), (TCHAR*)pmsg->prefix.sUser.c_str(), (TCHAR*)pmsg->prefix.sHost.c_str(), false, false, false };
 			HANDLE hContact = CList_FindContact(&user);
-			if (hContact) 
-				setTString( hContact, "MirVer", DoColorCodes(GetWordAddress(mess.c_str(), 1), TRUE, FALSE)); 
-			}
+			if (hContact)
+				setTString(hContact, "MirVer", DoColorCodes(GetWordAddress(mess.c_str(), 1), TRUE, FALSE));
+		}
 
 		// if the whois window is visible and the ctcp reply belongs to the user in it, then show the reply in the whois window
-		if ( m_whoisDlg && IsWindowVisible( m_whoisDlg->GetHwnd())) {
-			m_whoisDlg->m_InfoNick.GetText( szTemp, SIZEOF(szTemp));
-			if ( lstrcmpi(szTemp, pmsg->prefix.sNick.c_str()) == 0 ) {
-				if ( pmsg->m_bIncoming && (command == _T("version") || command == _T("userinfo") || command == _T("time"))) {
-					SetActiveWindow( m_whoisDlg->GetHwnd());
-					m_whoisDlg->m_Reply.SetText( DoColorCodes(GetWordAddress(mess.c_str(), 1), TRUE, FALSE));
+		if (m_whoisDlg && IsWindowVisible(m_whoisDlg->GetHwnd())) {
+			m_whoisDlg->m_InfoNick.GetText(szTemp, SIZEOF(szTemp));
+			if (lstrcmpi(szTemp, pmsg->prefix.sNick.c_str()) == 0) {
+				if (pmsg->m_bIncoming && (command == _T("version") || command == _T("userinfo") || command == _T("time"))) {
+					SetActiveWindow(m_whoisDlg->GetHwnd());
+					m_whoisDlg->m_Reply.SetText(DoColorCodes(GetWordAddress(mess.c_str(), 1), TRUE, FALSE));
 					return true;
 				}
 				if (pmsg->m_bIncoming && command == _T("ping")) {
-					SetActiveWindow( m_whoisDlg->GetHwnd());
+					SetActiveWindow(m_whoisDlg->GetHwnd());
 					int s = (int)time(0) - (int)_ttol(GetWordAddress(mess.c_str(), 1));
 					TCHAR szTemp[30];
-					if ( s == 1 )
-						mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%u second"), s );
+					if (s == 1)
+						mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%u second"), s);
 					else
-						mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%u seconds"), s );
+						mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%u seconds"), s);
 
-					m_whoisDlg->m_Reply.SetText( DoColorCodes( szTemp, TRUE, FALSE ));
+					m_whoisDlg->m_Reply.SetText(DoColorCodes(szTemp, TRUE, FALSE));
 					return true;
-		}	}	}
+				}
+			}
+		}
 
 		//... else show the reply in the current window
-		if ( pmsg->m_bIncoming && command == _T("ping")) {
+		if (pmsg->m_bIncoming && command == _T("ping")) {
 			int s = (int)time(0) - (int)_ttol(GetWordAddress(mess.c_str(), 1));
-			mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("CTCP PING reply from %s: %u sec(s)"), pmsg->prefix.sNick.c_str(), s); 
-			DoEvent( GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false ); 
+			mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("CTCP PING reply from %s: %u sec(s)"), pmsg->prefix.sNick.c_str(), s);
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false);
 		}
 		else {
-			mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("CTCP %s reply from %s: %s"), ocommand.c_str(), pmsg->prefix.sNick.c_str(), GetWordAddress(mess.c_str(), 1));	
-			DoEvent( GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false ); 
-	}	}		
+			mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("CTCP %s reply from %s: %s"), ocommand.c_str(), pmsg->prefix.sNick.c_str(), GetWordAddress(mess.c_str(), 1));
+			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false);
+		}
+	}
 
 	return true;
 }
 
 bool CIrcProto::OnIrc_NAMES(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 3 )
+	if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 3)
 		sNamesList += pmsg->parameters[3] + _T(" ");
-	ShowMessage( pmsg );
+	ShowMessage(pmsg);
 	return true;
 }
 
 bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 {
-	if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) {
+	if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) {
 		CMString name = _T("a");
 		int i = 0;
 		BOOL bFlag = false;
 
 		// Is the user on the names list?
-		while ( !name.IsEmpty()) {
-			name = GetWord( sNamesList.c_str(), i );
+		while (!name.IsEmpty()) {
+			name = GetWord(sNamesList.c_str(), i);
 			i++;
-			if ( !name.IsEmpty()) {
+			if (!name.IsEmpty()) {
 				int index = 0;
-				while ( _tcschr( sUserModePrefixes.c_str(), name[index] ))
+				while (_tcschr(sUserModePrefixes.c_str(), name[index]))
 					index++;
 
-				if ( !lstrcmpi( name.Mid(index, name.GetLength()).c_str(), m_info.sNick.c_str())) {
+				if (!lstrcmpi(name.Mid(index, name.GetLength()).c_str(), m_info.sNick.c_str())) {
 					bFlag = true;
 					break;
-		}	}	}
+				}
+			}
+		}
 
-		if ( bFlag ) {
+		if (bFlag) {
 			const TCHAR* sChanName = pmsg->parameters[1].c_str();
-			if ( sChanName[0] == '@' || sChanName[0] == '*' || sChanName[0] == '=' )
+			if (sChanName[0] == '@' || sChanName[0] == '*' || sChanName[0] == '=')
 				sChanName++;
 
 			// Add a new chat window
@@ -1260,9 +1282,9 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 				GCDEST gcd = { m_szModuleName, sID.c_str(), GC_EVENT_ADDGROUP };
 				GCEVENT gce = { sizeof(gce), &gcd };
 
-				PostIrcMessage( _T("/MODE %s"), sChanName );
+				PostIrcMessage(_T("/MODE %s"), sChanName);
 
-				//register the statuses
+				// register the statuses
 				gce.ptszStatus = _T("Owner");
 				CallChatEvent(0, (LPARAM)&gce);
 				gce.ptszStatus = _T("Admin");
@@ -1284,17 +1306,17 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 					CMString sStat;
 					CMString sTemp2 = sTemp;
 					sStat = PrefixToStatus(sTemp[0]);
-					
+
 					// fix for networks like freshirc where they allow more than one prefix
-					while ( PrefixToStatus(sTemp[0]) != _T("Normal"))
-						sTemp.Delete(0,1);
-					
+					while (PrefixToStatus(sTemp[0]) != _T("Normal"))
+						sTemp.Delete(0, 1);
+
 					gcd.iType = GC_EVENT_JOIN;
 					gce.ptszUID = sTemp.c_str();
 					gce.ptszNick = sTemp.c_str();
 					gce.ptszStatus = sStat.c_str();
-					BOOL bIsMe = ( !lstrcmpi( gce.ptszNick, m_info.sNick.c_str())) ? TRUE : FALSE;
-					if ( bIsMe ) {
+					BOOL bIsMe = (!lstrcmpi(gce.ptszNick, m_info.sNick.c_str())) ? TRUE : FALSE;
+					if (bIsMe) {
 						char BitNr = -1;
 						switch (sTemp2[0]) {
 							case '+':   BitNr = 0;   break;
@@ -1303,8 +1325,8 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 							case '!':   BitNr = 3;   break;
 							case '*':   BitNr = 4;   break;
 						}
-						if (BitNr >=0)
-							btOwnMode = ( 1 << BitNr );
+						if (BitNr >= 0)
+							btOwnMode = (1 << BitNr);
 						else
 							btOwnMode = 0;
 					}
@@ -1326,10 +1348,10 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 					i++;
 					sTemp = GetWord(sNamesList.c_str(), i);
 				}
-				
+
 				//Set the item data for the window
 				{
-					CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, sChanName, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);					
+					CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, sChanName, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
 					if (!wi)
 						wi = new CHANNELINFO;
 					wi->OwnMode = btOwnMode;
@@ -1340,14 +1362,14 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 					wi->codepage = getCodepage();
 					DoEvent(GC_EVENT_SETITEMDATA, sChanName, NULL, NULL, NULL, NULL, (DWORD_PTR)wi, false, false, 0);
 
-					if ( !sTopic.IsEmpty() && !lstrcmpi(GetWord(sTopic.c_str(), 0).c_str(), sChanName )) {
+					if (!sTopic.IsEmpty() && !lstrcmpi(GetWord(sTopic.c_str(), 0).c_str(), sChanName)) {
 						DoEvent(GC_EVENT_TOPIC, sChanName, sTopicName.IsEmpty() ? NULL : sTopicName.c_str(), GetWordAddress(sTopic.c_str(), 1), NULL, sTopicTime.IsEmpty() ? NULL : sTopicTime.c_str(), NULL, true, false);
 						AddWindowItemData(sChanName, 0, 0, 0, GetWordAddress(sTopic.c_str(), 1));
 						sTopic = _T("");
 						sTopicName = _T("");
 						sTopicTime = _T("");
-				}	}
-				
+					}	}
+
 				gcd.ptszID = (TCHAR*)sID.c_str();
 				gcd.iType = GC_EVENT_CONTROL;
 				gce.cbSize = sizeof(GCEVENT);
@@ -1361,38 +1383,39 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 				gce.ptszUserInfo = NULL;
 				gce.time = time(0);
 				gce.pDest = &gcd;
-	
-				if ( !getTString( "JTemp", &dbv )) {
+
+				if (!getTString("JTemp", &dbv)) {
 					CMString command = _T("a");
 					CMString save = _T("");
 					int i = 0;
 
-					while ( !command.IsEmpty()) {
-						command = GetWord( dbv.ptszVal, i );
+					while (!command.IsEmpty()) {
+						command = GetWord(dbv.ptszVal, i);
 						i++;
-						if ( !command.IsEmpty()) {
+						if (!command.IsEmpty()) {
 							CMString S = command.Mid(1, command.GetLength());
-							if ( !lstrcmpi( sChanName, S.c_str()))
+							if (!lstrcmpi(sChanName, S.c_str()))
 								break;
 
 							save += command + _T(" ");
-					}	}
+						}
+					}
 
-					if ( !command.IsEmpty()) {
-						save += GetWordAddress( dbv.ptszVal, i );
-						switch ( command[0] ) {
+					if (!command.IsEmpty()) {
+						save += GetWordAddress(dbv.ptszVal, i);
+						switch (command[0]) {
 						case 'M':
-							CallChatEvent( WINDOW_HIDDEN, (LPARAM)&gce);
+							CallChatEvent(WINDOW_HIDDEN, (LPARAM)&gce);
 							break;
 						case 'X':
-							CallChatEvent( WINDOW_MAXIMIZE, (LPARAM)&gce);
+							CallChatEvent(WINDOW_MAXIMIZE, (LPARAM)&gce);
 							break;
 						default:
-							CallChatEvent( SESSION_INITDONE, (LPARAM)&gce);
+							CallChatEvent(SESSION_INITDONE, (LPARAM)&gce);
 							break;
 						}
 					}
-					else CallChatEvent( SESSION_INITDONE, (LPARAM)&gce);
+					else CallChatEvent(SESSION_INITDONE, (LPARAM)&gce);
 
 					if (save.IsEmpty())
 						db_unset(NULL, m_szModuleName, "JTemp");
@@ -1400,15 +1423,17 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
 						setTString("JTemp", save.c_str());
 					db_free(&dbv);
 				}
-				else CallChatEvent( SESSION_INITDONE, (LPARAM)&gce);
+				else CallChatEvent(SESSION_INITDONE, (LPARAM)&gce);
 
 				gcd.iType = GC_EVENT_CONTROL;
 				gce.pDest = &gcd;
-				CallChatEvent( SESSION_ONLINE, (LPARAM)&gce);
-	}	}	}
+				CallChatEvent(SESSION_ONLINE, (LPARAM)&gce);
+			}
+		}
+	}
 
 	sNamesList = _T("");
-	ShowMessage( pmsg );
+	ShowMessage(pmsg);
 	return true;
 }
 
@@ -1920,23 +1945,20 @@ bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg)
 			}
 
 			/// if it is not a channel
-			TCHAR* UserList = mir_tstrdup(m_whoReply.c_str());
+			ptrT UserList(mir_tstrdup(m_whoReply.c_str()));
 			const TCHAR* p1 = UserList;
 			m_whoReply = _T("");
 			CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, true, false };
 			HANDLE hContact = CList_FindContact(&user);
 
 			if (hContact && getByte(hContact, "AdvancedMode", 0) == 1) {
-				DBVARIANT dbv1, dbv2, dbv3, dbv4, dbv5, dbv6, dbv7;
-				TCHAR *DBDefault = NULL, *DBNick = NULL, *DBWildcard = NULL;
-				TCHAR *DBUser = NULL, *DBHost = NULL, *DBManUser = NULL, *DBManHost = NULL;
-				if (!getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal;
-				if (!getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal;
-				if (!getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal;
-				if (!getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal;
-				if (!getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal;
-				if (!getTString(hContact, "User", &dbv6)) DBManUser = dbv6.ptszVal;
-				if (!getTString(hContact, "Host", &dbv7)) DBManHost = dbv7.ptszVal;
+				ptrT DBHost(getTStringA(hContact, "UHost"));
+				ptrT DBNick(getTStringA(hContact, "Nick"));
+				ptrT DBUser(getTStringA(hContact, "UUser"));
+				ptrT DBDefault(getTStringA(hContact, "Default"));
+				ptrT DBManUser(getTStringA(hContact, "User"));
+				ptrT DBManHost(getTStringA(hContact, "Host"));
+				ptrT DBWildcard(getTStringA(hContact, "UWildcard"));
 				if (DBWildcard)
 					CharLower(DBWildcard);
 
@@ -1962,8 +1984,7 @@ bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg)
 							setTString(hContact, "User", user.c_str());
 						if ((DBManHost && lstrcmpi(host.c_str(), DBManHost)) || !DBManHost)
 							setTString(hContact, "Host", host.c_str());
-
-						goto LBL_Exit;
+						return true;
 					}
 					p1 = GetWordAddress(p1, 4);
 					away = GetWord(p1, 3);
@@ -1972,11 +1993,11 @@ bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg)
 				if (DBWildcard && DBNick && !WCCmp(CharLower(DBWildcard), CharLower(DBNick))) {
 					setTString(hContact, "Nick", DBDefault);
 
-					DoUserhostWithReason(2, ((CMString)_T("S") + DBWildcard).c_str(), true, DBWildcard);
+					DoUserhostWithReason(2, ((CMString)_T("S") + DBWildcard).c_str(), true, (TCHAR*)DBWildcard);
 
 					setString(hContact, "User", "");
 					setString(hContact, "Host", "");
-					goto LBL_Exit;
+					return true;
 				}
 
 				if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
@@ -1985,16 +2006,7 @@ bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg)
 					setString(hContact, "User", "");
 					setString(hContact, "Host", "");
 				}
-LBL_Exit:
-				if (DBDefault)  db_free(&dbv1);
-				if (DBNick)     db_free(&dbv2);
-				if (DBWildcard) db_free(&dbv3);
-				if (DBUser)     db_free(&dbv4);
-				if (DBHost)     db_free(&dbv5);
-				if (DBManUser)  db_free(&dbv6);
-				if (DBManHost)  db_free(&dbv7);
 			}
-			mir_free(UserList);
 		}
 	}
 	else ShowMessage(pmsg);
@@ -2101,25 +2113,26 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg)
 				// Do command
 				switch (command[0]) {
 				case 'S':	// Status check
-				{
-									finduser.name = (TCHAR*)nick.c_str();
-									finduser.host = (TCHAR*)host.c_str();
-									finduser.user = (TCHAR*)user.c_str();
-
-									HANDLE hContact = CList_FindContact(&finduser);
-									if (hContact && getByte(hContact, "AdvancedMode", 0) == 0) {
-										setWord(hContact, "Status", awaystatus == '-' ? ID_STATUS_AWAY : ID_STATUS_ONLINE);
-										setTString(hContact, "User", user.c_str());
-										setTString(hContact, "Host", host.c_str());
-										setTString(hContact, "Nick", nick.c_str());
-
-										// If user found, remove from checklist
-										for (i = 0; i < checklist.getCount(); i++)
-										if (!lstrcmpi(checklist[i].c_str(), nick.c_str()))
-											checklist.remove(i);
-									}
-									break;
-				}
+					{
+						finduser.name = (TCHAR*)nick.c_str();
+						finduser.host = (TCHAR*)host.c_str();
+						finduser.user = (TCHAR*)user.c_str();
+
+						HANDLE hContact = CList_FindContact(&finduser);
+						if (hContact && getByte(hContact, "AdvancedMode", 0) == 0) {
+							setWord(hContact, "Status", awaystatus == '-' ? ID_STATUS_AWAY : ID_STATUS_ONLINE);
+							setTString(hContact, "User", user.c_str());
+							setTString(hContact, "Host", host.c_str());
+							setTString(hContact, "Nick", nick.c_str());
+	
+							// If user found, remove from checklist
+							for (i = 0; i < checklist.getCount(); i++)
+							if (!lstrcmpi(checklist[i].c_str(), nick.c_str()))
+								checklist.remove(i);
+						}
+					}
+					break;
+
 				case 'I':	// m_ignore
 					mess = _T("/IGNORE %question=\"");
 					mess += TranslateT("Please enter the hostmask (nick!user@host)\nNOTE! Contacts on your contact list are never ignored");
diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp
index f9fc281ba5..b11400f6d2 100644
--- a/protocols/IRCG/src/input.cpp
+++ b/protocols/IRCG/src/input.cpp
@@ -42,102 +42,103 @@ void CIrcProto::FormatMsg(CMString& text)
 		S = GetWord(text.c_str(), 0) + _T(" ") + GetWord(text.c_str(), 1) + _T(" ") + GetWord(text.c_str(), 2) + _T(" :") + GetWordAddress(text.c_str(), 3);
 	}
 	else if (command == _T("/nick")) {
-		if ( !_tcsstr(GetWord(text.c_str(), 1).c_str(), NICKSUBSTITUTE )) {
+		if (!_tcsstr(GetWord(text.c_str(), 1).c_str(), NICKSUBSTITUTE)) {
 			sNick4Perform = GetWord(text.c_str(), 1);
 			S = GetWordAddress(text.c_str(), 0);
 		}
 		else {
 			CMString sNewNick = GetWord(text.c_str(), 1);
-			if ( sNick4Perform == _T("")) {
+			if (sNick4Perform == _T("")) {
 				DBVARIANT dbv;
-				if ( !getTString( "PNick", &dbv )) {
+				if (!getTString("PNick", &dbv)) {
 					sNick4Perform = dbv.ptszVal;
 					db_free(&dbv);
-			}	}
+				}
+			}
 
-			ReplaceString( sNewNick, NICKSUBSTITUTE, sNick4Perform.c_str());
+			ReplaceString(sNewNick, NICKSUBSTITUTE, sNick4Perform.c_str());
 			S = GetWord(text.c_str(), 0) + _T(" ") + sNewNick;
 		}
 	}
 	else S = GetWordAddress(text.c_str(), 0);
 
-	S.Delete(0,1);
+	S.Delete(0, 1);
 	text = S;
 }
 
-static void AddCR( CMString& text )
+static void AddCR(CMString& text)
 {
-	ReplaceString( text, _T("\n"), _T("\r\n"));
-	ReplaceString( text, _T("\r\r"), _T("\r"));
+	ReplaceString(text, _T("\n"), _T("\r\n"));
+	ReplaceString(text, _T("\r\r"), _T("\r"));
 }
 
-CMString CIrcProto::DoAlias( const TCHAR *text, TCHAR *window)
+CMString CIrcProto::DoAlias(const TCHAR *text, TCHAR *window)
 {
 	CMString Messageout = _T("");
 	const TCHAR* p1 = text;
 	const TCHAR* p2 = text;
 	bool LinebreakFlag = false, hasAlias = false;
 	p2 = _tcsstr(p1, _T("\r\n"));
-	if ( !p2 )
+	if (!p2)
 		p2 = _tcschr(p1, '\0');
-	if ( p1 == p2 )
+	if (p1 == p2)
 		return (CMString)text;
 
 	do {
-		if ( LinebreakFlag )
+		if (LinebreakFlag)
 			Messageout += _T("\r\n");
 
-		TCHAR* line = new TCHAR[p2-p1 +1];
-		lstrcpyn(line, p1, p2-p1+1);
+		TCHAR* line = new TCHAR[p2 - p1 + 1];
+		lstrcpyn(line, p1, p2 - p1 + 1);
 		TCHAR* test = line;
-		while ( *test == ' ' )
+		while (*test == ' ')
 			test++;
-		if ( *test == '/' ) {
-			lstrcpyn(line, GetWordAddress(line, 0), p2-p1+1);
+		if (*test == '/') {
+			lstrcpyn(line, GetWordAddress(line, 0), p2 - p1 + 1);
 			CMString S = line;
-			delete [] line;
-			line = new TCHAR[S.GetLength()+2];
-			lstrcpyn(line, S.c_str(), S.GetLength()+1);
-			CMString alias( m_alias );
-			const TCHAR* p3 = _tcsstr( alias.c_str(), (GetWord(line, 0)+ _T(" ")).c_str());
-			if ( p3 != alias.c_str()) {
+			delete[] line;
+			line = new TCHAR[S.GetLength() + 2];
+			lstrcpyn(line, S.c_str(), S.GetLength() + 1);
+			CMString alias(m_alias);
+			const TCHAR* p3 = _tcsstr(alias.c_str(), (GetWord(line, 0) + _T(" ")).c_str());
+			if (p3 != alias.c_str()) {
 				CMString S = _T("\r\n");
 				S += GetWord(line, 0) + _T(" ");
-				p3 = _tcsstr( alias.c_str(), S.c_str());
-				if ( p3 )
+				p3 = _tcsstr(alias.c_str(), S.c_str());
+				if (p3)
 					p3 += 2;
 			}
-			if ( p3 != NULL ) {
+			if (p3 != NULL) {
 				hasAlias = true;
-				const TCHAR* p4 = _tcsstr( p3, _T("\r\n"));
-				if ( !p4 )
-					p4 = _tcschr( p3, '\0' );
+				const TCHAR* p4 = _tcsstr(p3, _T("\r\n"));
+				if (!p4)
+					p4 = _tcschr(p3, '\0');
 
-				*( TCHAR* )p4 = 0;
+				*(TCHAR*)p4 = 0;
 				CMString S = p3;
-				ReplaceString( S, _T("##"), window );
-				ReplaceString( S, _T("$?"), _T("%question"));
+				ReplaceString(S, _T("##"), window);
+				ReplaceString(S, _T("$?"), _T("%question"));
 
-				for ( int index = 1; index < 8; index++ ) {
+				for (int index = 1; index < 8; index++) {
 					TCHAR str[5];
-					mir_sntprintf( str, SIZEOF(str), _T("#$%u"), index );
-					if ( !GetWord(line, index).IsEmpty() && IsChannel( GetWord( line, index )))
-						ReplaceString( S, str, GetWord(line, index).c_str());
+					mir_sntprintf(str, SIZEOF(str), _T("#$%u"), index);
+					if (!GetWord(line, index).IsEmpty() && IsChannel(GetWord(line, index)))
+						ReplaceString(S, str, GetWord(line, index).c_str());
 					else {
 						CMString S1 = _T("#");
-						S1 += GetWord( line, index );
-						ReplaceString( S, str, S1.c_str());
+						S1 += GetWord(line, index);
+						ReplaceString(S, str, S1.c_str());
 					}
 				}
-				for ( int index2 = 1; index2 <8; index2++ ) {
+				for (int index2 = 1; index2 < 8; index2++) {
 					TCHAR str[5];
-					mir_sntprintf( str, SIZEOF(str), _T("$%u-"), index2 );
-					ReplaceString( S, str, GetWordAddress( line, index2 ));
+					mir_sntprintf(str, SIZEOF(str), _T("$%u-"), index2);
+					ReplaceString(S, str, GetWordAddress(line, index2));
 				}
-				for ( int index3 = 1; index3 <8; index3++ ) {
+				for (int index3 = 1; index3 < 8; index3++) {
 					TCHAR str[5];
-					mir_sntprintf( str, SIZEOF(str), _T("$%u"), index3 );
-					ReplaceString( S, str, GetWord(line, index3).c_str());
+					mir_sntprintf(str, SIZEOF(str), _T("$%u"), index3);
+					ReplaceString(S, str, GetWord(line, index3).c_str());
 				}
 				Messageout += GetWordAddress(S.c_str(), 1);
 			}
@@ -146,33 +147,33 @@ CMString CIrcProto::DoAlias( const TCHAR *text, TCHAR *window)
 		else Messageout += line;
 
 		p1 = p2;
-		if ( *p1 == '\r' )
+		if (*p1 == '\r')
 			p1 += 2;
-		p2 = _tcsstr( p1, _T("\r\n"));
-		if ( !p2 )
-			p2 = _tcschr( p1, '\0' );
-		delete [] line;
+		p2 = _tcsstr(p1, _T("\r\n"));
+		if (!p2)
+			p2 = _tcschr(p1, '\0');
+		delete[] line;
 		LinebreakFlag = true;
 	}
-		while ( *p1 != '\0');
+	while (*p1 != '\0');
 
-		return hasAlias ? DoIdentifiers(Messageout, window) : Messageout;
+	return hasAlias ? DoIdentifiers(Messageout, window) : Messageout;
 }
 
-CMString CIrcProto::DoIdentifiers( CMString text, const TCHAR* )
+CMString CIrcProto::DoIdentifiers(CMString text, const TCHAR*)
 {
 	SYSTEMTIME time;
 	TCHAR str[2];
 
-	GetLocalTime( &time );
-	ReplaceString( text, _T("%mnick"), m_nick);
-	ReplaceString( text, _T("%anick"), m_alternativeNick);
-	ReplaceString( text, _T("%awaymsg"), m_statusMessage.c_str());
-	ReplaceString( text, _T("%module"), _A2T(m_szModuleName));
-	ReplaceString( text, _T("%name"), m_name);
-	ReplaceString( text, _T("%newl"), _T("\r\n"));
-	ReplaceString( text, _T("%network"), m_info.sNetwork.c_str());
-	ReplaceString( text, _T("%me"), m_info.sNick.c_str());
+	GetLocalTime(&time);
+	ReplaceString(text, _T("%mnick"), m_nick);
+	ReplaceString(text, _T("%anick"), m_alternativeNick);
+	ReplaceString(text, _T("%awaymsg"), m_statusMessage.c_str());
+	ReplaceString(text, _T("%module"), _A2T(m_szModuleName));
+	ReplaceString(text, _T("%name"), m_name);
+	ReplaceString(text, _T("%newl"), _T("\r\n"));
+	ReplaceString(text, _T("%network"), m_info.sNetwork.c_str());
+	ReplaceString(text, _T("%me"), m_info.sNick.c_str());
 
 	char mirver[100];
 	CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(mirver), LPARAM(mirver));
@@ -194,27 +195,27 @@ CMString CIrcProto::DoIdentifiers( CMString text, const TCHAR* )
 	return text;
 }
 
-static void __stdcall sttSetTimerOn( void* _pro )
+static void __stdcall sttSetTimerOn(void* _pro)
 {
-	CIrcProto *ppro = ( CIrcProto* )_pro;
-	ppro->DoEvent( GC_EVENT_INFORMATION, NULL, ppro->m_info.sNick.c_str(), TranslateT(	"The buddy check function is enabled"), NULL, NULL, NULL, true, false);
-	ppro->SetChatTimer( ppro->OnlineNotifTimer, 500, OnlineNotifTimerProc );
-	if ( ppro->m_channelAwayNotification )
-		ppro->SetChatTimer( ppro->OnlineNotifTimer3, 1500, OnlineNotifTimerProc3 );
+	CIrcProto *ppro = (CIrcProto*)_pro;
+	ppro->DoEvent(GC_EVENT_INFORMATION, NULL, ppro->m_info.sNick.c_str(), TranslateT("The buddy check function is enabled"), NULL, NULL, NULL, true, false);
+	ppro->SetChatTimer(ppro->OnlineNotifTimer, 500, OnlineNotifTimerProc);
+	if (ppro->m_channelAwayNotification)
+		ppro->SetChatTimer(ppro->OnlineNotifTimer3, 1500, OnlineNotifTimerProc3);
 }
 
-static void __stdcall sttSetTimerOff( void* _pro )
+static void __stdcall sttSetTimerOff(void* _pro)
 {
-	CIrcProto *ppro = ( CIrcProto* )_pro;
-	ppro->DoEvent( GC_EVENT_INFORMATION, NULL, ppro->m_info.sNick.c_str(), TranslateT("The buddy check function is disabled"), NULL, NULL, NULL, true, false);
-	ppro->KillChatTimer( ppro->OnlineNotifTimer );
-	ppro->KillChatTimer( ppro->OnlineNotifTimer3 );
+	CIrcProto *ppro = (CIrcProto*)_pro;
+	ppro->DoEvent(GC_EVENT_INFORMATION, NULL, ppro->m_info.sNick.c_str(), TranslateT("The buddy check function is disabled"), NULL, NULL, NULL, true, false);
+	ppro->KillChatTimer(ppro->OnlineNotifTimer);
+	ppro->KillChatTimer(ppro->OnlineNotifTimer3);
 }
 
-BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContact )
+BOOL CIrcProto::DoHardcodedCommand(CMString text, TCHAR* window, HANDLE hContact)
 {
 	TCHAR temp[30];
-	lstrcpyn(temp, GetWord(text.c_str(), 0).c_str(), 29 );
+	lstrcpyn(temp, GetWord(text.c_str(), 0).c_str(), 29);
 	CharLower(temp);
 	CMString command = temp;
 	CMString one = GetWord(text.c_str(), 1);
@@ -222,38 +223,38 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 	CMString three = GetWord(text.c_str(), 3);
 	CMString therest = GetWordAddress(text.c_str(), 4);
 
-	if ( command == _T("/servershow") || command == _T("/serverhide")) {
-		if ( m_useServer ) {
+	if (command == _T("/servershow") || command == _T("/serverhide")) {
+		if (m_useServer) {
 			GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
 			GCEVENT gce = { sizeof(gce), &gcd };
-			CallChatEvent( command == _T("/servershow") ? WINDOW_VISIBLE : WINDOW_HIDDEN, (LPARAM)&gce);
+			CallChatEvent(command == _T("/servershow") ? WINDOW_VISIBLE : WINDOW_HIDDEN, (LPARAM)&gce);
 		}
 		return true;
 	}
 
 	else if (command == _T("/sleep") || command == _T("/wait")) {
-   	if (!one.IsEmpty()) {
-      	int ms;
-         if (_stscanf(one.c_str(), _T("%d"), &ms) == 1 && ms > 0 && ms <= 4000)
-         	Sleep(ms);
+		if (!one.IsEmpty()) {
+			int ms;
+			if (_stscanf(one.c_str(), _T("%d"), &ms) == 1 && ms > 0 && ms <= 4000)
+				Sleep(ms);
 			else
-         	DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Incorrect parameters. Usage: /sleep [ms], ms should be greater than 0 and less than 4000."), NULL, NULL, NULL, true, false);
+				DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Incorrect parameters. Usage: /sleep [ms], ms should be greater than 0 and less than 4000."), NULL, NULL, NULL, true, false);
 		}
 		return true;
 	}
 
 	if (command == _T("/clear")) {
 		CMString S;
-		if ( !one.IsEmpty()) {
-			if ( one == _T("server"))
+		if (!one.IsEmpty()) {
+			if (one == _T("server"))
 				S = SERVERWINDOW;
 			else
-				S = MakeWndID( one.c_str());
+				S = MakeWndID(one.c_str());
 		}
-		else if ( lstrcmpi( window, SERVERWINDOW) == 0 )
+		else if (lstrcmpi(window, SERVERWINDOW) == 0)
 			S = window;
 		else
-			S = MakeWndID( window );
+			S = MakeWndID(window);
 
 		GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
 		GCEVENT gce = { sizeof(gce), &gcd };
@@ -261,107 +262,107 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 		return true;
 	}
 
-	if ( command == _T("/ignore")) {
-		if ( IsConnected()) {
+	if (command == _T("/ignore")) {
+		if (IsConnected()) {
 			CMString IgnoreFlags;
 			TCHAR temp[500];
-			if ( one.IsEmpty()) {
-				if ( m_ignore )
-					DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is enabled"), NULL, NULL, NULL, true, false);
+			if (one.IsEmpty()) {
+				if (m_ignore)
+					DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is enabled"), NULL, NULL, NULL, true, false);
 				else
-					DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is disabled"), NULL, NULL, NULL, true, false);
+					DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is disabled"), NULL, NULL, NULL, true, false);
 				return true;
 			}
-			if ( !lstrcmpi( one.c_str(), _T("on"))) {
+			if (!lstrcmpi(one.c_str(), _T("on"))) {
 				m_ignore = 1;
-				DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is enabled"), NULL, NULL, NULL, true, false);
+				DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is enabled"), NULL, NULL, NULL, true, false);
 				return true;
 			}
-			if ( !lstrcmpi( one.c_str(), _T("off"))) {
+			if (!lstrcmpi(one.c_str(), _T("off"))) {
 				m_ignore = 0;
-				DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is disabled"), NULL, NULL, NULL, true, false);
+				DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Ignore system is disabled"), NULL, NULL, NULL, true, false);
 				return true;
 			}
-			if ( !_tcschr( one.c_str(), '!' ) && !_tcschr( one.c_str(), '@' ))
+			if (!_tcschr(one.c_str(), '!') && !_tcschr(one.c_str(), '@'))
 				one += _T("!*@*");
 
-			if ( !two.IsEmpty() && two[0] == '+' ) {
-				if ( _tcschr( two.c_str(), 'q'))
+			if (!two.IsEmpty() && two[0] == '+') {
+				if (_tcschr(two.c_str(), 'q'))
 					IgnoreFlags += 'q';
-				if ( _tcschr( two.c_str(), 'n'))
+				if (_tcschr(two.c_str(), 'n'))
 					IgnoreFlags += 'n';
-				if ( _tcschr( two.c_str(), 'i'))
+				if (_tcschr(two.c_str(), 'i'))
 					IgnoreFlags += 'i';
-				if ( _tcschr( two.c_str(), 'd'))
+				if (_tcschr(two.c_str(), 'd'))
 					IgnoreFlags += 'd';
-				if ( _tcschr( two.c_str(), 'c'))
+				if (_tcschr(two.c_str(), 'c'))
 					IgnoreFlags += 'c';
-				if ( _tcschr( two.c_str(), 'm'))
+				if (_tcschr(two.c_str(), 'm'))
 					IgnoreFlags += 'm';
 			}
 			else IgnoreFlags = _T("qnidc");
 
 			CMString m_network;
-			if ( three.IsEmpty())
+			if (three.IsEmpty())
 				m_network = m_info.sNetwork;
 			else
 				m_network = three;
 
-			AddIgnore( one.c_str(), IgnoreFlags.c_str(), m_network.c_str());
+			AddIgnore(one.c_str(), IgnoreFlags.c_str(), m_network.c_str());
 
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s on %s is now ignored (+%s)"), one.c_str(), m_network.c_str(), IgnoreFlags.c_str());
-			DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
+			DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
 		}
 		return true;
 	}
 
 	if (command == _T("/unignore")) {
-		if ( !_tcschr( one.c_str(), '!' ) && !_tcschr(one.c_str(), '@'))
+		if (!_tcschr(one.c_str(), '!') && !_tcschr(one.c_str(), '@'))
 			one += _T("!*@*");
 
 		TCHAR temp[500];
-		if ( RemoveIgnore( one.c_str()))
+		if (RemoveIgnore(one.c_str()))
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s is not ignored now"), one.c_str());
 		else
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s was not ignored"), one.c_str());
-		DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
+		DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
 		return true;
 	}
 
-	if ( command == _T("/userhost")) {
- 		if ( one.IsEmpty())
+	if (command == _T("/userhost")) {
+		if (one.IsEmpty())
 			return true;
 
-		DoUserhostWithReason( 1, _T("U"), false, temp );
- 		return false;
- 	}
+		DoUserhostWithReason(1, _T("U"), false, temp);
+		return false;
+	}
 
-	if ( command == _T("/joinx")) {
-		if ( !one.IsEmpty()) {
-			for ( int i=1; ; i++ ) {
-				CMString tmp = GetWord( text.c_str(), i );
-				if ( tmp.IsEmpty())
+	if (command == _T("/joinx")) {
+		if (!one.IsEmpty()) {
+			for (int i = 1;; i++) {
+				CMString tmp = GetWord(text.c_str(), i);
+				if (tmp.IsEmpty())
 					break;
 
-				AddToJTemp( 'X', tmp );
+				AddToJTemp('X', tmp);
 			}
 
-			PostIrcMessage( _T("/JOIN %s"), GetWordAddress(text.c_str(), 1));
+			PostIrcMessage(_T("/JOIN %s"), GetWordAddress(text.c_str(), 1));
 		}
 		return true;
 	}
 
-	if ( command == _T("/joinm")) {
-		if ( !one.IsEmpty()) {
-			for ( int i=1; ; i++ ) {
-				CMString tmp = GetWord( text.c_str(), i );
-				if ( tmp.IsEmpty())
+	if (command == _T("/joinm")) {
+		if (!one.IsEmpty()) {
+			for (int i = 1;; i++) {
+				CMString tmp = GetWord(text.c_str(), i);
+				if (tmp.IsEmpty())
 					break;
 
-				AddToJTemp( 'M', tmp );
+				AddToJTemp('M', tmp);
 			}
 
-			PostIrcMessage( _T("/JOIN %s"), GetWordAddress(text.c_str(), 1));
+			PostIrcMessage(_T("/JOIN %s"), GetWordAddress(text.c_str(), 1));
 		}
 		return true;
 	}
@@ -369,28 +370,28 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 	if (command == _T("/nusers")) {
 		TCHAR szTemp[40];
 		CMString S = MakeWndID(window);
-		GC_INFO gci = {0};
-		gci.Flags = BYID|NAME|COUNT;
+		GC_INFO gci = { 0 };
+		gci.Flags = BYID | NAME | COUNT;
 		gci.pszModule = m_szModuleName;
 		gci.pszID = S.c_str();
-		if ( !CallServiceSync( MS_GC_GETINFO, 0, ( LPARAM )&gci ))
-			mir_sntprintf( szTemp, SIZEOF(szTemp), _T("users: %u"), gci.iCount);
+		if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci))
+			mir_sntprintf(szTemp, SIZEOF(szTemp), _T("users: %u"), gci.iCount);
 
-		DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
+		DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 		return true;
 	}
 
 	if (command == _T("/echo")) {
-		if ( one.IsEmpty())
+		if (one.IsEmpty())
 			return true;
 
-		if ( !lstrcmpi( one.c_str(), _T("on"))) {
+		if (!lstrcmpi(one.c_str(), _T("on"))) {
 			bEcho = TRUE;
-			DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Outgoing commands are shown"), NULL, NULL, NULL, true, false);
+			DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Outgoing commands are shown"), NULL, NULL, NULL, true, false);
 		}
 
-		if ( !lstrcmpi( one.c_str(), _T("off"))) {
-			DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Outgoing commands are not shown"), NULL, NULL, NULL, true, false);
+		if (!lstrcmpi(one.c_str(), _T("off"))) {
+			DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("Outgoing commands are not shown"), NULL, NULL, NULL, true, false);
 			bEcho = FALSE;
 		}
 
@@ -398,145 +399,148 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 	}
 
 	if (command == _T("/buddycheck")) {
-		if ( one.IsEmpty()) {
-			if (( m_autoOnlineNotification && !bTempDisableCheck) || bTempForceCheck )
-				DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("The buddy check function is enabled"), NULL, NULL, NULL, true, false);
+		if (one.IsEmpty()) {
+			if ((m_autoOnlineNotification && !bTempDisableCheck) || bTempForceCheck)
+				DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("The buddy check function is enabled"), NULL, NULL, NULL, true, false);
 			else
-				DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("The buddy check function is disabled"), NULL, NULL, NULL, true, false);
+				DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("The buddy check function is disabled"), NULL, NULL, NULL, true, false);
 			return true;
 		}
-		if ( !lstrcmpi( one.c_str(), _T("on"))) {
+		if (!lstrcmpi(one.c_str(), _T("on"))) {
 			bTempForceCheck = true;
 			bTempDisableCheck = false;
-			CallFunctionAsync( sttSetTimerOn, this );
+			CallFunctionAsync(sttSetTimerOn, this);
 		}
-		if ( !lstrcmpi( one.c_str(), _T("off"))) {
+		if (!lstrcmpi(one.c_str(), _T("off"))) {
 			bTempForceCheck = false;
 			bTempDisableCheck = true;
-			CallFunctionAsync( sttSetTimerOff, this );
+			CallFunctionAsync(sttSetTimerOff, this);
 		}
-		if ( !lstrcmpi( one.c_str(), _T("time")) && !two.IsEmpty()) {
-			m_iTempCheckTime = StrToInt( two.c_str());
-			if ( m_iTempCheckTime < 10 && m_iTempCheckTime != 0 )
+		if (!lstrcmpi(one.c_str(), _T("time")) && !two.IsEmpty()) {
+			m_iTempCheckTime = StrToInt(two.c_str());
+			if (m_iTempCheckTime < 10 && m_iTempCheckTime != 0)
 				m_iTempCheckTime = 10;
 
-			if ( m_iTempCheckTime == 0 )
-				DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("The time interval for the buddy check function is now at default setting"), NULL, NULL, NULL, true, false);
+			if (m_iTempCheckTime == 0)
+				DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), TranslateT("The time interval for the buddy check function is now at default setting"), NULL, NULL, NULL, true, false);
 			else {
 				TCHAR temp[200];
-				mir_sntprintf( temp, SIZEOF(temp), TranslateT("The time interval for the buddy check function is now %u seconds"), m_iTempCheckTime);
-				DoEvent( GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
-		}	}
+				mir_sntprintf(temp, SIZEOF(temp), TranslateT("The time interval for the buddy check function is now %u seconds"), m_iTempCheckTime);
+				DoEvent(GC_EVENT_INFORMATION, NULL, m_info.sNick.c_str(), temp, NULL, NULL, NULL, true, false);
+			}
+		}
 		return true;
 	}
 
 	if (command == _T("/whois")) {
-		if ( one.IsEmpty())
+		if (one.IsEmpty())
 			return false;
 		m_manualWhoisCount++;
 		return false;
 	}
 
-	if ( command == _T("/channelmanager")) {
-		if ( window && !hContact && IsChannel( window )) {
-			if ( IsConnected()) {
-				if ( m_managerDlg != NULL ) {
-					SetActiveWindow( m_managerDlg->GetHwnd());
+	if (command == _T("/channelmanager")) {
+		if (window && !hContact && IsChannel(window)) {
+			if (IsConnected()) {
+				if (m_managerDlg != NULL) {
+					SetActiveWindow(m_managerDlg->GetHwnd());
 					m_managerDlg->Close();
 				}
 				else {
-					m_managerDlg = new CManagerDlg( this );
+					m_managerDlg = new CManagerDlg(this);
 					m_managerDlg->Show();
-					m_managerDlg->InitManager( 1, window );
-		}	}	}
+					m_managerDlg->InitManager(1, window);
+				}
+			}
+		}
 
 		return true;
 	}
 
-	if ( command == _T("/who")) {
-		if ( one.IsEmpty())
+	if (command == _T("/who")) {
+		if (one.IsEmpty())
 			return true;
 
-		DoUserhostWithReason( 2, _T("U"), false, _T("%s"), one.c_str());
+		DoUserhostWithReason(2, _T("U"), false, _T("%s"), one.c_str());
 		return false;
 	}
 
 	if (command == _T("/hop")) {
-		if ( !IsChannel( window ))
+		if (!IsChannel(window))
 			return true;
 
-		PostIrcMessage( _T("/PART %s"), window );
+		PostIrcMessage(_T("/PART %s"), window);
 
-		if (( one.IsEmpty() || !IsChannel( one ))) {
+		if ((one.IsEmpty() || !IsChannel(one))) {
 			CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
-			if ( wi && wi->pszPassword )
-				PostIrcMessage( _T("/JOIN %s %s"), window, wi->pszPassword);
+			if (wi && wi->pszPassword)
+				PostIrcMessage(_T("/JOIN %s %s"), window, wi->pszPassword);
 			else
-				PostIrcMessage( _T("/JOIN %s"), window);
+				PostIrcMessage(_T("/JOIN %s"), window);
 			return true;
 		}
 
 		CMString S = MakeWndID(window);
 		GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
 		GCEVENT gce = { sizeof(gce), &gcd };
-		CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
+		CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
 
-		PostIrcMessage( _T("/JOIN %s"), GetWordAddress(text.c_str(), 1));
+		PostIrcMessage(_T("/JOIN %s"), GetWordAddress(text.c_str(), 1));
 		return true;
 	}
 
-	if (command == _T("/list" )) {
-		if ( m_listDlg == NULL ) {
-			m_listDlg = new CListDlg( this );
+	if (command == _T("/list")) {
+		if (m_listDlg == NULL) {
+			m_listDlg = new CListDlg(this);
 			m_listDlg->Show();
 		}
-		SetActiveWindow( m_listDlg->GetHwnd());
-		int minutes = ( int )m_noOfChannels/4000;
-		int minutes2 = ( int )m_noOfChannels/9000;
+		SetActiveWindow(m_listDlg->GetHwnd());
+		int minutes = (int)m_noOfChannels / 4000;
+		int minutes2 = (int)m_noOfChannels / 9000;
 
 		TCHAR text[256];
-		mir_sntprintf( text, SIZEOF(text), TranslateT("This command is not recommended on a network of this size!\r\nIt will probably cause high CPU usage and/or high bandwidth\r\nusage for around %u to %u minute(s).\r\n\r\nDo you want to continue?"), minutes2, minutes);
-		if ( m_noOfChannels < 4000 || ( m_noOfChannels >= 4000 && MessageBox( NULL, text, TranslateT("IRC warning") , MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2) == IDYES)) {
-			ListView_DeleteAllItems( GetDlgItem( m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW ));
-			PostIrcMessage( _T("/lusers" ));
+		mir_sntprintf(text, SIZEOF(text), TranslateT("This command is not recommended on a network of this size!\r\nIt will probably cause high CPU usage and/or high bandwidth\r\nusage for around %u to %u minute(s).\r\n\r\nDo you want to continue?"), minutes2, minutes);
+		if (m_noOfChannels < 4000 || (m_noOfChannels >= 4000 && MessageBox(NULL, text, TranslateT("IRC warning"), MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) == IDYES)) {
+			ListView_DeleteAllItems(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW));
+			PostIrcMessage(_T("/lusers"));
 			return false;
 		}
-		m_listDlg->m_status.SetText( TranslateT("Aborted"));
+		m_listDlg->m_status.SetText(TranslateT("Aborted"));
 		return true;
 	}
 
 	if (command == _T("/me")) {
-		if ( one.IsEmpty())
+		if (one.IsEmpty())
 			return true;
 
 		TCHAR szTemp[4000];
 		mir_sntprintf(szTemp, SIZEOF(szTemp), _T("\001ACTION %s\001"), GetWordAddress(text.c_str(), 1));
-		PostIrcMessageWnd( window, hContact, szTemp );
+		PostIrcMessageWnd(window, hContact, szTemp);
 		return true;
 	}
 
 	if (command == _T("/ame")) {
-		if ( one.IsEmpty())
+		if (one.IsEmpty())
 			return true;
 
 		CMString S = _T("/ME ") + DoIdentifiers(GetWordAddress(text.c_str(), 1), window);
-		ReplaceString( S, _T("%"), _T("%%"));
-		DoEvent( GC_EVENT_SENDMESSAGE, NULL, NULL, S.c_str(), NULL, NULL, NULL, FALSE, FALSE);
+		ReplaceString(S, _T("%"), _T("%%"));
+		DoEvent(GC_EVENT_SENDMESSAGE, NULL, NULL, S.c_str(), NULL, NULL, NULL, FALSE, FALSE);
 		return true;
 	}
 
 	if (command == _T("/amsg")) {
-		if ( one.IsEmpty())
+		if (one.IsEmpty())
 			return true;
 
-		CMString S = DoIdentifiers( GetWordAddress(text.c_str(), 1), window );
-		ReplaceString( S, _T("%"), _T("%%"));
-		DoEvent( GC_EVENT_SENDMESSAGE, NULL, NULL, S.c_str(), NULL, NULL, NULL, FALSE, FALSE);
+		CMString S = DoIdentifiers(GetWordAddress(text.c_str(), 1), window);
+		ReplaceString(S, _T("%"), _T("%%"));
+		DoEvent(GC_EVENT_SENDMESSAGE, NULL, NULL, S.c_str(), NULL, NULL, NULL, FALSE, FALSE);
 		return true;
 	}
 
 	if (command == _T("/msg")) {
-		if ( one.IsEmpty() || two.IsEmpty())
+		if (one.IsEmpty() || two.IsEmpty())
 			return true;
 
 		TCHAR szTemp[4000];
@@ -547,17 +551,17 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 	}
 
 	if (command == _T("/query")) {
-		if ( one.IsEmpty() || IsChannel(one.c_str()))
+		if (one.IsEmpty() || IsChannel(one.c_str()))
 			return true;
 
-		CONTACT user = { (TCHAR*)one.c_str(), NULL, NULL, false, false, false};
+		CONTACT user = { (TCHAR*)one.c_str(), NULL, NULL, false, false, false };
 		HANDLE hContact2 = CList_AddContact(&user, false, false);
-		if ( hContact2 ) {
-			if ( getByte( hContact, "AdvancedMode", 0 ) == 0 )
+		if (hContact2) {
+			if (getByte(hContact, "AdvancedMode", 0) == 0)
 				DoUserhostWithReason(1, (_T("S") + one).c_str(), true, one.c_str());
 			else {
 				DBVARIANT dbv1;
-				if ( !getTString( hContact, "UWildcard", &dbv1 )) {
+				if (!getTString(hContact, "UWildcard", &dbv1)) {
 					CMString S = _T("S");
 					S += dbv1.ptszVal;
 					DoUserhostWithReason(2, S.c_str(), true, dbv1.ptszVal);
@@ -567,41 +571,42 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 					CMString S = _T("S");
 					S += one;
 					DoUserhostWithReason(2, S.c_str(), true, one.c_str());
-			}	}
+				}
+			}
 
 			CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact2, 0);
 		}
 
-		if ( !two.IsEmpty()) {
+		if (!two.IsEmpty()) {
 			TCHAR szTemp[4000];
-			mir_sntprintf( szTemp, SIZEOF(szTemp), _T("/PRIVMSG %s"), GetWordAddress(text.c_str(), 1));
-			PostIrcMessageWnd( window, hContact, szTemp );
+			mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/PRIVMSG %s"), GetWordAddress(text.c_str(), 1));
+			PostIrcMessageWnd(window, hContact, szTemp);
 		}
 		return true;
 	}
 
 	if (command == _T("/ctcp")) {
-		if ( one.IsEmpty() || two.IsEmpty())
+		if (one.IsEmpty() || two.IsEmpty())
 			return true;
 
 		TCHAR szTemp[1000];
 		unsigned long ulAdr = 0;
-		if ( m_manualHost )
-			ulAdr = ConvertIPToInteger( m_mySpecifiedHostIP );
+		if (m_manualHost)
+			ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
 		else
-			ulAdr = ConvertIPToInteger( m_IPFromServer ? m_myHost : m_myLocalHost );
+			ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
 
-		 // if it is not dcc or if it is dcc and a local ip exist
-		if ( lstrcmpi( two.c_str(), _T("dcc")) != 0 || ulAdr ) {
-			if ( lstrcmpi( two.c_str(), _T("ping")) == 0 )
-				mir_sntprintf( szTemp, SIZEOF(szTemp), _T("/PRIVMSG %s \001%s %u\001"), one.c_str(), two.c_str(), time(0));
+		// if it is not dcc or if it is dcc and a local ip exist
+		if (lstrcmpi(two.c_str(), _T("dcc")) != 0 || ulAdr) {
+			if (lstrcmpi(two.c_str(), _T("ping")) == 0)
+				mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/PRIVMSG %s \001%s %u\001"), one.c_str(), two.c_str(), time(0));
 			else
-				mir_sntprintf( szTemp, SIZEOF(szTemp), _T("/PRIVMSG %s \001%s\001"), one.c_str(), GetWordAddress(text.c_str(), 2));
-			PostIrcMessageWnd( window, hContact, szTemp );
+				mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/PRIVMSG %s \001%s\001"), one.c_str(), GetWordAddress(text.c_str(), 2));
+			PostIrcMessageWnd(window, hContact, szTemp);
 		}
 
-		if ( lstrcmpi(two.c_str(), _T("dcc")) != 0 ) {
-			mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("CTCP %s request sent to %s"), two.c_str(), one.c_str());
+		if (lstrcmpi(two.c_str(), _T("dcc")) != 0) {
+			mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("CTCP %s request sent to %s"), two.c_str(), one.c_str());
 			DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 		}
 
@@ -609,74 +614,76 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 	}
 
 	if (command == _T("/dcc")) {
-		if ( one.IsEmpty() || two.IsEmpty())
+		if (one.IsEmpty() || two.IsEmpty())
 			return true;
 
-		if ( lstrcmpi( one.c_str(), _T("send")) == 0 ) {
+		if (lstrcmpi(one.c_str(), _T("send")) == 0) {
 			TCHAR szTemp[1000];
 			unsigned long ulAdr = 0;
 
-			if ( m_manualHost )
-				ulAdr = ConvertIPToInteger( m_mySpecifiedHostIP );
+			if (m_manualHost)
+				ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
 			else
-				ulAdr = ConvertIPToInteger( m_IPFromServer ? m_myHost : m_myLocalHost );
+				ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
 
-			if ( ulAdr ) {
+			if (ulAdr) {
 				CONTACT user = { (TCHAR*)two.c_str(), NULL, NULL, false, false, true };
-				HANDLE hContact = CList_AddContact( &user, false, false );
-				if ( hContact ) {
+				HANDLE hContact = CList_AddContact(&user, false, false);
+				if (hContact) {
 					CMString s;
 
-					if ( getByte( hContact, "AdvancedMode", 0 ) == 0 )
-						DoUserhostWithReason( 1, (_T("S") + two).c_str(), true, two.c_str());
+					if (getByte(hContact, "AdvancedMode", 0) == 0)
+						DoUserhostWithReason(1, (_T("S") + two).c_str(), true, two.c_str());
 					else {
 						DBVARIANT dbv1;
 						CMString S = _T("S");
-						if ( !getTString( hContact, "UWildcard", &dbv1 )) {
+						if (!getTString(hContact, "UWildcard", &dbv1)) {
 							S += dbv1.ptszVal;
-							DoUserhostWithReason(2, S.c_str(), true, dbv1.ptszVal );
-							db_free( &dbv1 );
+							DoUserhostWithReason(2, S.c_str(), true, dbv1.ptszVal);
+							db_free(&dbv1);
 						}
 						else {
 							S += two;
-							DoUserhostWithReason( 2, S.c_str(), true, two.c_str());
-					}	}
+							DoUserhostWithReason(2, S.c_str(), true, two.c_str());
+						}
+					}
 
-					if ( three.IsEmpty())
+					if (three.IsEmpty())
 						CallService(MS_FILE_SENDFILE, (WPARAM)hContact, 0);
 					else {
 						CMString temp = GetWordAddress(text.c_str(), 3);
 						TCHAR* pp[2];
-						TCHAR* p = ( TCHAR* )temp.c_str();
+						TCHAR* p = (TCHAR*)temp.c_str();
 						pp[0] = p;
 						pp[1] = NULL;
 						CallService(MS_FILE_SENDSPECIFICFILES, (WPARAM)hContact, (LPARAM)pp);
-				}	}
+					}
+				}
 			}
 			else {
-				mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Unable to automatically resolve external IP"));
+				mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Unable to automatically resolve external IP"));
 				DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 			}
 			return true;
 		}
 
-		if ( lstrcmpi( one.c_str(), _T("chat")) == 0 ) {
+		if (lstrcmpi(one.c_str(), _T("chat")) == 0) {
 			TCHAR szTemp[1000];
 
 			unsigned long ulAdr = 0;
-			if ( m_manualHost )
-				ulAdr = ConvertIPToInteger( m_mySpecifiedHostIP );
+			if (m_manualHost)
+				ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
 			else
-				ulAdr = ConvertIPToInteger( m_IPFromServer ? m_myHost : m_myLocalHost );
+				ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
 
-			if ( ulAdr ) {
+			if (ulAdr) {
 				CMString contact = two;  contact += _T(DCCSTRING);
-				CONTACT user = { (TCHAR*)contact.c_str(), NULL, NULL, false, false, true};
-				HANDLE hContact = CList_AddContact( &user, false, false );
+				CONTACT user = { (TCHAR*)contact.c_str(), NULL, NULL, false, false, true };
+				HANDLE hContact = CList_AddContact(&user, false, false);
 				setByte(hContact, "DCC", 1);
 
 				int iPort = 0;
-				if ( hContact ) {
+				if (hContact) {
 					DCCINFO* dci = new DCCINFO;
 					dci->hContact = hContact;
 					dci->sContactName = two;
@@ -685,26 +692,27 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 
 					CDccSession* dcc = new CDccSession(this, dci);
 					CDccSession* olddcc = FindDCCSession(hContact);
-					if ( olddcc )
+					if (olddcc)
 						olddcc->Disconnect();
 					AddDCCSession(hContact, dcc);
 					iPort = dcc->Connect();
 				}
 
-				if ( iPort != 0 ) {
-					PostIrcMessage( _T("/CTCP %s DCC CHAT chat %u %u"), two.c_str(), ulAdr, iPort );
-					mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("DCC CHAT request sent to %s"), two.c_str(), one.c_str());
-					DoEvent( GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
+				if (iPort != 0) {
+					PostIrcMessage(_T("/CTCP %s DCC CHAT chat %u %u"), two.c_str(), ulAdr, iPort);
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC CHAT request sent to %s"), two.c_str(), one.c_str());
+					DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 				}
 				else {
-					mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Unable to bind port"));
-					DoEvent( GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
+					mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Unable to bind port"));
+					DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 				}
 			}
 			else {
-				mir_sntprintf( szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Unable to automatically resolve external IP"));
-				DoEvent( GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
-		}	}
+				mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("DCC ERROR: Unable to automatically resolve external IP"));
+				DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
+			}
+		}
 		return true;
 	}
 	return false;
@@ -714,166 +722,170 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
 
 struct DoInputRequestParam
 {
-	DoInputRequestParam( CIrcProto* _pro, const TCHAR* _str ) :
-		ppro( _pro ),
-		str( mir_tstrdup( _str ))
+	DoInputRequestParam(CIrcProto* _pro, const TCHAR* _str) :
+	ppro(_pro),
+	str(mir_tstrdup(_str))
 	{}
 
 	CIrcProto *ppro;
 	TCHAR* str;
 };
 
-static void __stdcall DoInputRequestAliasApcStub( void* _par )
+static void __stdcall DoInputRequestAliasApcStub(void* _par)
 {
-	DoInputRequestParam* param = ( DoInputRequestParam* )_par;
+	DoInputRequestParam* param = (DoInputRequestParam*)_par;
 	CIrcProto *ppro = param->ppro;
 	TCHAR* str = param->str;
 
 	TCHAR* infotext = NULL;
 	TCHAR* title = NULL;
 	TCHAR* defaulttext = NULL;
-	CMString command = ( TCHAR* )str;
-	TCHAR* p = _tcsstr(( TCHAR* )str, _T("%question"));
-	if ( p[9] == '=' && p[10] == '\"' ) {
+	CMString command = (TCHAR*)str;
+	TCHAR* p = _tcsstr((TCHAR*)str, _T("%question"));
+	if (p[9] == '=' && p[10] == '\"') {
 		infotext = &p[11];
-		p = _tcschr( infotext, '\"' );
-		if ( p ) {
+		p = _tcschr(infotext, '\"');
+		if (p) {
 			*p = '\0';
 			p++;
-			if ( *p == ',' && p[1] == '\"' ) {
+			if (*p == ',' && p[1] == '\"') {
 				p++; p++;
 				title = p;
-				p = _tcschr( title, '\"' );
-				if ( p ) {
+				p = _tcschr(title, '\"');
+				if (p) {
 					*p = '\0';
 					p++;
-					if ( *p == ',' && p[1] == '\"' ) {
+					if (*p == ',' && p[1] == '\"') {
 						p++; p++;
 						defaulttext = p;
-						p = _tcschr( defaulttext, '\"' );
-						if ( p )
+						p = _tcschr(defaulttext, '\"');
+						if (p)
 							*p = '\0';
-	}	}	}	}	}
+					}
+				}
+			}
+		}
+	}
 
-	CQuestionDlg* dlg = new CQuestionDlg( ppro );
+	CQuestionDlg* dlg = new CQuestionDlg(ppro);
 	dlg->Show();
 	HWND question_hWnd = dlg->GetHwnd();
 
-	if ( title )
-		SetDlgItemText( question_hWnd, IDC_CAPTION, title);
+	if (title)
+		SetDlgItemText(question_hWnd, IDC_CAPTION, title);
 	else
-		SetDlgItemText( question_hWnd, IDC_CAPTION, TranslateT("Input command"));
+		SetDlgItemText(question_hWnd, IDC_CAPTION, TranslateT("Input command"));
 
-	if ( infotext )
-		SetWindowText( GetDlgItem( question_hWnd, IDC_TEXT), infotext );
+	if (infotext)
+		SetWindowText(GetDlgItem(question_hWnd, IDC_TEXT), infotext);
 	else
-		SetWindowText( GetDlgItem( question_hWnd, IDC_TEXT), TranslateT("Please enter the reply"));
+		SetWindowText(GetDlgItem(question_hWnd, IDC_TEXT), TranslateT("Please enter the reply"));
 
-	if ( defaulttext )
-		SetWindowText( GetDlgItem( question_hWnd, IDC_EDIT), defaulttext );
+	if (defaulttext)
+		SetWindowText(GetDlgItem(question_hWnd, IDC_EDIT), defaulttext);
 
-	SetDlgItemText( question_hWnd, IDC_HIDDENEDIT, command.c_str());
+	SetDlgItemText(question_hWnd, IDC_HIDDENEDIT, command.c_str());
 	dlg->Activate();
 
-	mir_free( str );
+	mir_free(str);
 	delete param;
 }
 
-bool CIrcProto::PostIrcMessage( const TCHAR* fmt, ... )
+bool CIrcProto::PostIrcMessage(const TCHAR* fmt, ...)
 {
-	if ( !fmt || lstrlen(fmt) < 1 || lstrlen(fmt) > 4000 )
+	if (!fmt || lstrlen(fmt) < 1 || lstrlen(fmt) > 4000)
 		return 0;
 
 	va_list marker;
-	va_start( marker, fmt );
-	static TCHAR szBuf[4*1024];
-	mir_vsntprintf( szBuf, SIZEOF(szBuf), fmt, marker );
-	va_end( marker );
+	va_start(marker, fmt);
+	static TCHAR szBuf[4 * 1024];
+	mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
+	va_end(marker);
 
 	return PostIrcMessageWnd(NULL, NULL, szBuf);
 }
 
-bool CIrcProto::PostIrcMessageWnd( TCHAR* window, HANDLE hContact, const TCHAR* szBuf )
+bool CIrcProto::PostIrcMessageWnd(TCHAR* window, HANDLE hContact, const TCHAR* szBuf)
 {
 	DBVARIANT dbv;
 	TCHAR windowname[256];
 	BYTE bDCC = 0;
 
-	if ( hContact )
-		bDCC = getByte( hContact, "DCC", 0 );
+	if (hContact)
+		bDCC = getByte(hContact, "DCC", 0);
 
-	if ( !IsConnected() && !bDCC || !szBuf || lstrlen(szBuf) < 1 )
+	if (!IsConnected() && !bDCC || !szBuf || lstrlen(szBuf) < 1)
 		return 0;
 
-	if ( hContact && !getTString( hContact, "Nick", &dbv )) {
-		lstrcpyn( windowname, dbv.ptszVal, 255);
+	if (hContact && !getTString(hContact, "Nick", &dbv)) {
+		lstrcpyn(windowname, dbv.ptszVal, 255);
 		db_free(&dbv);
 	}
-	else if ( window )
-		lstrcpyn( windowname, window, 255 );
+	else if (window)
+		lstrcpyn(windowname, window, 255);
 	else
-		lstrcpyn( windowname, SERVERWINDOW, 255 );
+		lstrcpyn(windowname, SERVERWINDOW, 255);
 
-	if ( lstrcmpi( window, SERVERWINDOW) != 0 ) {
-		TCHAR* p1 = _tcschr( windowname, ' ' );
-		if ( p1 )
+	if (lstrcmpi(window, SERVERWINDOW) != 0) {
+		TCHAR* p1 = _tcschr(windowname, ' ');
+		if (p1)
 			*p1 = '\0';
 	}
 
 	// remove unecessary linebreaks, and do the aliases
 	CMString Message = szBuf;
-	AddCR( Message );
-	RemoveLinebreaks( Message );
-	if ( !hContact && IsConnected()) {
-		Message = DoAlias( Message.c_str(), windowname );
+	AddCR(Message);
+	RemoveLinebreaks(Message);
+	if (!hContact && IsConnected()) {
+		Message = DoAlias(Message.c_str(), windowname);
 
-		if ( Message.Find( _T("%question")) != -1 ) {
-			CallFunctionAsync( DoInputRequestAliasApcStub, new DoInputRequestParam( this, Message ));
+		if (Message.Find(_T("%question")) != -1) {
+			CallFunctionAsync(DoInputRequestAliasApcStub, new DoInputRequestParam(this, Message));
 			return 1;
 		}
 
-		ReplaceString( Message, _T("%newl"), _T("\r\n"));
-		RemoveLinebreaks( Message );
+		ReplaceString(Message, _T("%newl"), _T("\r\n"));
+		RemoveLinebreaks(Message);
 	}
 
-	if ( Message.IsEmpty())
+	if (Message.IsEmpty())
 		return 0;
 
 	CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, windowname, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
-	int codepage = ( wi ) ? wi->codepage : getCodepage();
+	int codepage = (wi) ? wi->codepage : getCodepage();
 
 	// process the message
-	while ( !Message.IsEmpty()) {
+	while (!Message.IsEmpty()) {
 		// split the text into lines, and do an automatic textsplit on long lies as well
 		bool flag = false;
 		CMString DoThis = _T("");
-		int index = Message.Find( _T("\r\n"), 0 );
-		if ( index == -1 )
+		int index = Message.Find(_T("\r\n"), 0);
+		if (index == -1)
 			index = Message.GetLength();
 
-		if ( index > 464 )
+		if (index > 464)
 			index = 432;
 		DoThis = Message.Mid(0, index);
 		Message.Delete(0, index);
-		if ( Message.Find( _T("\r\n"), 0 ) == 0 )
-			Message.Delete( 0, 2 );
+		if (Message.Find(_T("\r\n"), 0) == 0)
+			Message.Delete(0, 2);
 
 		//do this if it's a /raw
-		if ( IsConnected() && ( GetWord(DoThis.c_str(), 0) == _T("/raw") || GetWord(DoThis.c_str(), 0) == _T("/quote"))) {
-			if ( GetWord( DoThis.c_str(), 1 ).IsEmpty())
+		if (IsConnected() && (GetWord(DoThis.c_str(), 0) == _T("/raw") || GetWord(DoThis.c_str(), 0) == _T("/quote"))) {
+			if (GetWord(DoThis.c_str(), 1).IsEmpty())
 				continue;
 
-			CMString S = GetWordAddress( DoThis.c_str(), 1 );
-			SendIrcMessage( S.c_str(), true, codepage );
+			CMString S = GetWordAddress(DoThis.c_str(), 1);
+			SendIrcMessage(S.c_str(), true, codepage);
 			continue;
 		}
 
 		// Do this if the message is not a command
-		if (  (GetWord( DoThis.c_str(), 0)[0] != '/') ||													// not a command
-			  ( (GetWord( DoThis.c_str(), 0)[0] == '/') && (GetWord( DoThis.c_str(), 0)[1] == '/')) ||		// or double backslash at the beginning
-			  hContact ) {
+		if ((GetWord(DoThis.c_str(), 0)[0] != '/') ||													// not a command
+			((GetWord(DoThis.c_str(), 0)[0] == '/') && (GetWord(DoThis.c_str(), 0)[1] == '/')) ||		// or double backslash at the beginning
+			hContact) {
 			CMString S = _T("/PRIVMSG ");
-			if ( lstrcmpi(window, SERVERWINDOW) == 0 && !m_info.sServerName.IsEmpty())
+			if (lstrcmpi(window, SERVERWINDOW) == 0 && !m_info.sServerName.IsEmpty())
 				S += m_info.sServerName + _T(" ") + DoThis;
 			else
 				S += CMString(windowname) + _T(" ") + DoThis;
@@ -883,36 +895,37 @@ bool CIrcProto::PostIrcMessageWnd( TCHAR* window, HANDLE hContact, const TCHAR*
 		}
 
 		// and here we send it unless the command was a hardcoded one that should not be sent
-		if ( DoHardcodedCommand( DoThis, windowname, hContact ))
+		if (DoHardcodedCommand(DoThis, windowname, hContact))
 			continue;
 
-		if ( !IsConnected() && !bDCC )
+		if (!IsConnected() && !bDCC)
 			continue;
 
-		if ( !flag && IsConnected())
+		if (!flag && IsConnected())
 			DoThis = DoIdentifiers(DoThis, windowname);
 
-		if ( hContact ) {
-			if ( flag && bDCC ) {
-				CDccSession* dcc = FindDCCSession( hContact );
-				if ( dcc ) {
-					FormatMsg( DoThis );
+		if (hContact) {
+			if (flag && bDCC) {
+				CDccSession* dcc = FindDCCSession(hContact);
+				if (dcc) {
+					FormatMsg(DoThis);
 					CMString mess = GetWordAddress(DoThis.c_str(), 2);
-					if ( mess[0] == ':' )
-						mess.Delete(0,1);
+					if (mess[0] == ':')
+						mess.Delete(0, 1);
 					mess += '\n';
-					dcc->SendStuff( mess.c_str());
+					dcc->SendStuff(mess.c_str());
 				}
 			}
-			else if ( IsConnected()) {
-				FormatMsg( DoThis );
-				SendIrcMessage( DoThis.c_str(), false, codepage );
+			else if (IsConnected()) {
+				FormatMsg(DoThis);
+				SendIrcMessage(DoThis.c_str(), false, codepage);
 			}
 		}
 		else {
-			FormatMsg( DoThis );
-			SendIrcMessage( DoThis.c_str(), true, codepage );
-	}	}
+			FormatMsg(DoThis);
+			SendIrcMessage(DoThis.c_str(), true, codepage);
+		}
+	}
 
 	return 1;
 }
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp
index abb59fa2e6..f1daa53f6a 100644
--- a/protocols/IRCG/src/irclib.cpp
+++ b/protocols/IRCG/src/irclib.cpp
@@ -58,8 +58,8 @@ CIrcMessage::CIrcMessage(const CIrcMessage& m) :
 	prefix.sUser = m.prefix.sUser;
 	prefix.sHost = m.prefix.sHost;
 
-	for ( int i=0; i < m.parameters.getCount(); i++ )
-		parameters.insert( new CMString( m.parameters[i] ));
+	for (int i = 0; i < m.parameters.getCount(); i++)
+		parameters.insert(new CMString(m.parameters[i]));
 }
 
 CIrcMessage::~CIrcMessage()
@@ -77,7 +77,7 @@ void CIrcMessage::Reset()
 
 CIrcMessage& CIrcMessage::operator = (const CIrcMessage& m)
 {
-	if ( &m != this ) {
+	if (&m != this) {
 		sCommand = m.sCommand;
 		parameters = m.parameters;
 		prefix.sNick = m.prefix.sNick;
@@ -102,89 +102,93 @@ void CIrcMessage::ParseIrcCommand(const TCHAR* lpszCmdLine)
 	const TCHAR* p2 = lpszCmdLine;
 
 	// prefix exists ?
-	if ( *p1 == ':' ) {
+	if (*p1 == ':') {
 		// break prefix into its components (nick!user@host)
 		p2 = ++p1;
-		while( *p2 && !_tcschr( _T(" !"), *p2 ))
+		while (*p2 && !_tcschr(_T(" !"), *p2))
 			++p2;
 		prefix.sNick.SetString(p1, p2 - p1);
-		if ( *p2 != '!' )
+		if (*p2 != '!')
 			goto end_of_prefix;
 		p1 = ++p2;
-		while( *p2 && !_tcschr( _T(" @"), *p2 ))
+		while (*p2 && !_tcschr(_T(" @"), *p2))
 			++p2;
 		prefix.sUser.SetString(p1, p2 - p1);
-		if ( *p2 != '@' )
+		if (*p2 != '@')
 			goto end_of_prefix;
 		p1 = ++p2;
-		while( *p2 && *p2 != ' ' )
+		while (*p2 && *p2 != ' ')
 			++p2;
 		prefix.sHost.SetString(p1, p2 - p1);
-end_of_prefix :
-		while( *p2 && *p2 == ' ' )
+end_of_prefix:
+		while (*p2 && *p2 == ' ')
 			++p2;
 		p1 = p2;
 	}
 
 	// get command
 	p2 = p1;
-	while( *p2 && *p2 != ' ' )
+	while (*p2 && *p2 != ' ')
 		++p2;
 
 	sCommand.SetString(p1, p2 - p1);
 	sCommand.MakeUpper();
-	while( *p2 && *p2 == ' ' )
+	while (*p2 && *p2 == ' ')
 		++p2;
 	p1 = p2;
 
 	// get parameters
-	while( *p1 ) {
-		if ( *p1 == ':' ) {
+	while (*p1) {
+		if (*p1 == ':') {
 			++p1;
 
 			// seek end-of-message
-			while( *p2 )
+			while (*p2)
 				++p2;
-			parameters.insert( new CMString(p1, p2 - p1));
+			parameters.insert(new CMString(p1, p2 - p1));
 			break;
 		}
 		else {
 			// seek end of parameter
-			while( *p2 && *p2 != ' ' )
+			while (*p2 && *p2 != ' ')
 				++p2;
-			parameters.insert( new CMString(p1, p2 - p1));
+			parameters.insert(new CMString(p1, p2 - p1));
 			// see next parameter
-			while( *p2 && *p2 == ' ' )
+			while (*p2 && *p2 == ' ')
 				++p2;
 			p1 = p2;
-}	}	}
+		}
+	}
+}
 
 ////////////////////////////////////////////////////////////////////
 
 int CIrcProto::getCodepage() const
 {
-	return ( con != NULL ) ? codepage : CP_ACP;
+	return (con != NULL) ? codepage : CP_ACP;
 }
 
-void CIrcProto::SendIrcMessage( const TCHAR* msg, bool bNotify, int codepage )
+void CIrcProto::SendIrcMessage(const TCHAR* msg, bool bNotify, int codepage)
 {
-	if ( codepage == -1 )
+	if (codepage == -1)
 		codepage = getCodepage();
 
-	if ( this ) {
-		char* str = mir_t2a_cp( msg, codepage );
-		rtrim( str );
-		int cbLen = (int)strlen( str );
-		str = ( char* )mir_realloc( str, cbLen+3 );
-		strcat( str, "\r\n" );
-		NLSend(( const BYTE* )str, cbLen+2 );
-		mir_free( str );
-		
-		if ( bNotify ) {
-			CIrcMessage ircMsg( this, msg, codepage );
-			if ( !ircMsg.sCommand.IsEmpty() && ircMsg.sCommand != _T("QUIT"))
-				Notify( &ircMsg );
-}	}	}
+	if (this) {
+		char* str = mir_t2a_cp(msg, codepage);
+		rtrim(str);
+		int cbLen = (int)strlen(str);
+		str = (char*)mir_realloc(str, cbLen + 3);
+		strcat(str, "\r\n");
+		NLSend((const BYTE*)str, cbLen + 2);
+		mir_free(str);
+
+		if (bNotify) {
+			CIrcMessage ircMsg(this, msg, codepage);
+			if (!ircMsg.sCommand.IsEmpty() && ircMsg.sCommand != _T("QUIT"))
+				Notify(&ircMsg);
+		}
+	}
+}
 
 bool CIrcProto::Connect(const CIrcSessionInfo& info)
 {
@@ -205,15 +209,16 @@ bool CIrcProto::Connect(const CIrcSessionInfo& info)
 
 	FindLocalIP(con); // get the local ip used for filetransfers etc
 
-	if ( info.m_iSSL > 0 ) {
-		if ( !CallService(MS_NETLIB_STARTSSL, (WPARAM)con, 0) && info.m_iSSL == 2) {
-			Netlib_CloseHandle( con );
+	if (info.m_iSSL > 0) {
+		if (!CallService(MS_NETLIB_STARTSSL, (WPARAM)con, 0) && info.m_iSSL == 2) {
+			Netlib_CloseHandle(con);
 			con = NULL;
 			m_info.Reset();
 			return false;
-	}	}
+		}
+	}
 
-	if ( Miranda_Terminated()) {
+	if (Miranda_Terminated()) {
 		Disconnect();
 		return false;
 	}
@@ -221,22 +226,22 @@ bool CIrcProto::Connect(const CIrcSessionInfo& info)
 	m_info = info;
 
 	// start receiving messages from host
-	ForkThread( &CIrcProto::ThreadProc, NULL );
-	Sleep( 100 );
-	if ( info.sPassword.GetLength())
-		NLSend( "PASS %s\r\n", info.sPassword.c_str());
-	NLSend( _T("NICK %s\r\n"), info.sNick.c_str());
+	ForkThread(&CIrcProto::ThreadProc, NULL);
+	Sleep(100);
+	if (info.sPassword.GetLength())
+		NLSend("PASS %s\r\n", info.sPassword.c_str());
+	NLSend(_T("NICK %s\r\n"), info.sNick.c_str());
 
 	CMString m_userID = GetWord(info.sUserID.c_str(), 0);
 	TCHAR szHostName[MAX_PATH];
-	DWORD cbHostName = SIZEOF( szHostName );
+	DWORD cbHostName = SIZEOF(szHostName);
 	GetComputerName(szHostName, &cbHostName);
 	CMString HostName = GetWord(szHostName, 0);
-	if ( m_userID.IsEmpty())
+	if (m_userID.IsEmpty())
 		m_userID = _T("Miranda");
-	if ( HostName.IsEmpty())
-		HostName= _T("host");
-	NLSend( _T("USER %s %s %s :%s\r\n"), m_userID.c_str(), HostName.c_str(), _T("server"), info.sFullName.c_str());
+	if (HostName.IsEmpty())
+		HostName = _T("host");
+	NLSend(_T("USER %s %s %s :%s\r\n"), m_userID.c_str(), HostName.c_str(), _T("server"), info.sFullName.c_str());
 
 	return con != NULL;
 }
@@ -245,19 +250,19 @@ void CIrcProto::Disconnect(void)
 {
 	static const DWORD dwServerTimeout = 5 * 1000;
 
-	if ( con == NULL )
+	if (con == NULL)
 		return;
 
 	KillIdent();
 
-	if ( m_quitMessage && m_quitMessage[0] )
-		NLSend( _T("QUIT :%s\r\n"), m_quitMessage);
+	if (m_quitMessage && m_quitMessage[0])
+		NLSend(_T("QUIT :%s\r\n"), m_quitMessage);
 	else
-		NLSend( "QUIT \r\n" );
+		NLSend("QUIT \r\n");
 
 	Sleep(50);
 
-	if ( con )
+	if (con)
 		Netlib_Shutdown(con);
 
 	m_info.Reset();
@@ -269,60 +274,60 @@ void CIrcProto::Notify(const CIrcMessage* pmsg)
 	OnIrcMessage(pmsg);
 }
 
-int CIrcProto::NLSend( const unsigned char* buf, int cbBuf)
+int CIrcProto::NLSend(const unsigned char* buf, int cbBuf)
 {
-	if ( m_bMbotInstalled && m_scriptingEnabled ) {
+	if (m_bMbotInstalled && m_scriptingEnabled) {
 		int iVal = NULL;
 		char * pszTemp = 0;
-		pszTemp = ( char* ) mir_alloc( lstrlenA((const char *) buf ) + 1);
-		lstrcpynA(pszTemp, (const char *)buf, lstrlenA ((const char *)buf) + 1);
+		pszTemp = (char*)mir_alloc(lstrlenA((const char *)buf) + 1);
+		lstrcpynA(pszTemp, (const char *)buf, lstrlenA((const char *)buf) + 1);
 
-		if ( Scripting_TriggerMSPRawOut(&pszTemp) && pszTemp ) {
+		if (Scripting_TriggerMSPRawOut(&pszTemp) && pszTemp) {
 			if (con)
 				iVal = Netlib_Send(con, (const char*)pszTemp, lstrlenA(pszTemp), MSG_DUMPASTEXT);
 		}
-		if ( pszTemp )
-			mir_free( pszTemp );
+		if (pszTemp)
+			mir_free(pszTemp);
 
 		return iVal;
 	}
-	
+
 	if (con)
 		return Netlib_Send(con, (const char*)buf, cbBuf, MSG_DUMPASTEXT);
 
 	return 0;
 }
 
-int CIrcProto::NLSend( const TCHAR* fmt, ...)
+int CIrcProto::NLSend(const TCHAR* fmt, ...)
 {
 	va_list marker;
 	va_start(marker, fmt);
 
-	TCHAR szBuf[1024*4];
+	TCHAR szBuf[1024 * 4];
 	mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
 	va_end(marker);
 
-	char* buf = mir_t2a_cp( szBuf, getCodepage());
+	char* buf = mir_t2a_cp(szBuf, getCodepage());
 	int result = NLSend((unsigned char*)buf, (int)strlen(buf));
-	mir_free( buf );
+	mir_free(buf);
 	return result;
 }
 
-int CIrcProto::NLSend( const char* fmt, ...)
+int CIrcProto::NLSend(const char* fmt, ...)
 {
 	va_list marker;
 	va_start(marker, fmt);
 
-	char szBuf[1024*4];
+	char szBuf[1024 * 4];
 	int cbLen = mir_vsnprintf(szBuf, SIZEOF(szBuf), fmt, marker);
 	va_end(marker);
 
-	return NLSend((unsigned char*)szBuf, cbLen );
+	return NLSend((unsigned char*)szBuf, cbLen);
 }
 
-int CIrcProto::NLSendNoScript( const unsigned char* buf, int cbBuf)
+int CIrcProto::NLSendNoScript(const unsigned char* buf, int cbBuf)
 {
-	if ( con )
+	if (con)
 		return Netlib_Send(con, (const char*)buf, cbBuf, MSG_DUMPASTEXT);
 
 	return 0;
@@ -330,101 +335,102 @@ int CIrcProto::NLSendNoScript( const unsigned char* buf, int cbBuf)
 
 int CIrcProto::NLReceive(unsigned char* buf, int cbBuf)
 {
-	return Netlib_Recv( con, (char*)buf, cbBuf, MSG_DUMPASTEXT );
+	return Netlib_Recv(con, (char*)buf, cbBuf, MSG_DUMPASTEXT);
 }
 
 void CIrcProto::KillIdent()
 {
-	if ( hBindPort ) {
+	if (hBindPort) {
 		HANDLE hPort = hBindPort;
 		hBindPort = NULL;
-		Netlib_CloseHandle( hPort );
+		Netlib_CloseHandle(hPort);
 	}
 }
 
 void CIrcProto::InsertIncomingEvent(TCHAR* pszRaw)
 {
-	CIrcMessage msg( this, pszRaw, true);
-	Notify( &msg );
+	CIrcMessage msg(this, pszRaw, true);
+	Notify(&msg);
 	return;
 }
 
-void CIrcProto::createMessageFromPchar( const char* p )
+void CIrcProto::createMessageFromPchar(const char* p)
 {
 	TCHAR* ptszMsg;
-	if ( codepage != CP_UTF8 && m_utfAutodetect ) {
-		if ( mir_utf8decodecp( NEWSTR_ALLOCA(p), codepage, &ptszMsg ) == NULL )
-				ptszMsg = mir_a2t_cp( p, codepage );
+	if (codepage != CP_UTF8 && m_utfAutodetect) {
+		if (mir_utf8decodecp(NEWSTR_ALLOCA(p), codepage, &ptszMsg) == NULL)
+			ptszMsg = mir_a2t_cp(p, codepage);
 	}
-	else ptszMsg = mir_a2t_cp( p, codepage );
-	CIrcMessage msg( this, ptszMsg, codepage, true );
-	Notify( &msg );
-	mir_free( ptszMsg );
+	else ptszMsg = mir_a2t_cp(p, codepage);
+	CIrcMessage msg(this, ptszMsg, codepage, true);
+	Notify(&msg);
+	mir_free(ptszMsg);
 }
 
 void CIrcProto::DoReceive()
 {
-	char chBuf[1024*4+1];
+	char chBuf[1024 * 4 + 1];
 	int cbInBuf = 0;
-	
-	if ( m_info.bIdentServer && m_info.iIdentServerPort != NULL ) {
-		NETLIBBIND nb = {0};
+
+	if (m_info.bIdentServer && m_info.iIdentServerPort != NULL) {
+		NETLIBBIND nb = { 0 };
 		nb.cbSize = sizeof(NETLIBBIND);
 		nb.pfnNewConnectionV2 = DoIdent;
 		nb.pExtra = this;
 		nb.wPort = m_info.iIdentServerPort;
 		hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nb);
-		if ( !hBindPort || nb.wPort != m_info.iIdentServerPort ) {
+		if (!hBindPort || nb.wPort != m_info.iIdentServerPort) {
 			debugLogA("Error: unable to bind local port %u", m_info.iIdentServerPort);
 			KillIdent();
-	}	}
+		}
+	}
 
-	while( con ) {
+	while (con) {
 		int nLinesProcessed = 0;
 
-		int cbRead = NLReceive((unsigned char*)chBuf+cbInBuf, sizeof(chBuf)-cbInBuf-1);
-		if ( cbRead <= 0 )
+		int cbRead = NLReceive((unsigned char*)chBuf + cbInBuf, sizeof(chBuf)-cbInBuf - 1);
+		if (cbRead <= 0)
 			break;
 
 		cbInBuf += cbRead;
 		chBuf[cbInBuf] = '\0';
 
 		char* pStart = chBuf;
-		while( *pStart ) {
+		while (*pStart) {
 			char* pEnd;
 
 			// seek end-of-line
-			for(pEnd=pStart; *pEnd && *pEnd != '\r' && *pEnd != '\n'; ++pEnd)
+			for (pEnd = pStart; *pEnd && *pEnd != '\r' && *pEnd != '\n'; ++pEnd)
 				;
-			if ( *pEnd == '\0' )
+			if (*pEnd == '\0')
 				break; // uncomplete message. stop parsing.
 
 			++nLinesProcessed;
 
 			// replace end-of-line with NULLs and skip
-			while( *pEnd == '\r' || *pEnd == '\n' )
+			while (*pEnd == '\r' || *pEnd == '\n')
 				*pEnd++ = '\0';
 
 			// process single message by monitor objects
-			if ( *pStart ) {
-				if ( m_bMbotInstalled && m_scriptingEnabled ) {
-					char* pszTemp = mir_strdup( pStart ); 
+			if (*pStart) {
+				if (m_bMbotInstalled && m_scriptingEnabled) {
+					char* pszTemp = mir_strdup(pStart);
 
-					if ( Scripting_TriggerMSPRawIn( &pszTemp ) && pszTemp ) {
+					if (Scripting_TriggerMSPRawIn(&pszTemp) && pszTemp) {
 						char* p1 = pszTemp;
 						// replace end-of-line with NULLs
-						while( *p1 != '\0' ) {
-							if ( *p1 == '\r' || *p1 == '\n')
+						while (*p1 != '\0') {
+							if (*p1 == '\r' || *p1 == '\n')
 								*p1 = '\0';
 							p1++;
 						}
 
-						createMessageFromPchar( pszTemp );
+						createMessageFromPchar(pszTemp);
 					}
 
-					mir_free( pszTemp );
+					mir_free(pszTemp);
 				}
-				else createMessageFromPchar( pStart );
+				else createMessageFromPchar(pStart);
 			}
 
 			cbInBuf -= pEnd - pStart;
@@ -432,11 +438,11 @@ void CIrcProto::DoReceive()
 		}
 
 		// discard processed messages
-		if ( nLinesProcessed != 0 )
-			memmove(chBuf, pStart, cbInBuf+1);
+		if (nLinesProcessed != 0)
+			memmove(chBuf, pStart, cbInBuf + 1);
 	}
 
-	if ( con ) {
+	if (con) {
 		Netlib_CloseHandle(con);
 		con = NULL;
 	}
@@ -445,9 +451,9 @@ void CIrcProto::DoReceive()
 	Notify(NULL);
 }
 
-void __cdecl CIrcProto::ThreadProc( void* )
+void __cdecl CIrcProto::ThreadProc(void*)
 {
-	DoReceive(); 
+	DoReceive();
 	m_info.Reset();
 }
 
@@ -456,10 +462,10 @@ void CIrcProto::AddDCCSession(HANDLE, CDccSession* dcc)
 	EnterCriticalSection(&m_dcc);
 
 	CDccSession* p = m_dcc_chats.find(dcc);
-	if ( p )
-		m_dcc_chats.remove( p );
+	if (p)
+		m_dcc_chats.remove(p);
 
-	m_dcc_chats.insert( dcc );
+	m_dcc_chats.insert(dcc);
 
 	LeaveCriticalSection(&m_dcc);
 }
@@ -468,7 +474,7 @@ void CIrcProto::AddDCCSession(DCCINFO*, CDccSession* dcc)
 {
 	EnterCriticalSection(&m_dcc);
 
-	m_dcc_xfers.insert( dcc );
+	m_dcc_xfers.insert(dcc);
 
 	LeaveCriticalSection(&m_dcc);
 }
@@ -477,11 +483,11 @@ void CIrcProto::RemoveDCCSession(HANDLE hContact)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_chats.getCount(); i++ )
-		if ( m_dcc_chats[i]->di->hContact == hContact ) {
-			m_dcc_chats.remove( i );
-			break;
-		}
+	for (int i = 0; i < m_dcc_chats.getCount(); i++)
+	if (m_dcc_chats[i]->di->hContact == hContact) {
+		m_dcc_chats.remove(i);
+		break;
+	}
 
 	LeaveCriticalSection(&m_dcc);
 }
@@ -490,11 +496,11 @@ void CIrcProto::RemoveDCCSession(DCCINFO* pdci)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_xfers.getCount(); i++ )
-		if ( m_dcc_xfers[i]->di == pdci ) {
-			m_dcc_xfers.remove( i );
-			break;
-		}
+	for (int i = 0; i < m_dcc_xfers.getCount(); i++)
+	if (m_dcc_xfers[i]->di == pdci) {
+		m_dcc_xfers.remove(i);
+		break;
+	}
 
 	LeaveCriticalSection(&m_dcc);
 }
@@ -503,11 +509,11 @@ CDccSession* CIrcProto::FindDCCSession(HANDLE hContact)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_chats.getCount(); i++ )
-		if ( m_dcc_chats[i]->di->hContact == hContact ) {
-			LeaveCriticalSection(&m_dcc);
-			return m_dcc_chats[ i ];
-		}
+	for (int i = 0; i < m_dcc_chats.getCount(); i++)
+	if (m_dcc_chats[i]->di->hContact == hContact) {
+		LeaveCriticalSection(&m_dcc);
+		return m_dcc_chats[i];
+	}
 
 	LeaveCriticalSection(&m_dcc);
 	return 0;
@@ -517,11 +523,11 @@ CDccSession* CIrcProto::FindDCCSession(DCCINFO* pdci)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_xfers.getCount(); i++ )
-		if ( m_dcc_xfers[i]->di == pdci ) {
-			LeaveCriticalSection(&m_dcc);
-			return m_dcc_xfers[ i ];
-		}
+	for (int i = 0; i < m_dcc_xfers.getCount(); i++)
+	if (m_dcc_xfers[i]->di == pdci) {
+		LeaveCriticalSection(&m_dcc);
+		return m_dcc_xfers[i];
+	}
 
 	LeaveCriticalSection(&m_dcc);
 	return 0;
@@ -531,9 +537,9 @@ CDccSession* CIrcProto::FindDCCSendByPort(int iPort)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_xfers.getCount(); i++ ) {
+	for (int i = 0; i < m_dcc_xfers.getCount(); i++) {
 		CDccSession* p = m_dcc_xfers[i];
-		if ( p->di->iType == DCC_SEND && p->di->bSender && iPort == p->di->iPort ) {
+		if (p->di->iType == DCC_SEND && p->di->bSender && iPort == p->di->iPort) {
 			LeaveCriticalSection(&m_dcc);
 			return p;
 		}
@@ -547,11 +553,11 @@ CDccSession* CIrcProto::FindDCCRecvByPortAndName(int iPort, const TCHAR* szName)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_xfers.getCount(); i++ ) {
+	for (int i = 0; i < m_dcc_xfers.getCount(); i++) {
 		CDccSession* p = m_dcc_xfers[i];
 		DBVARIANT dbv;
-		if ( !getTString(p->di->hContact, "Nick", &dbv)) {
-			if ( p->di->iType == DCC_SEND && !p->di->bSender && !lstrcmpi( szName, dbv.ptszVal) && iPort == p->di->iPort ) {
+		if (!getTString(p->di->hContact, "Nick", &dbv)) {
+			if (p->di->iType == DCC_SEND && !p->di->bSender && !lstrcmpi(szName, dbv.ptszVal) && iPort == p->di->iPort) {
 				db_free(&dbv);
 				LeaveCriticalSection(&m_dcc);
 				return p;
@@ -568,10 +574,10 @@ CDccSession* CIrcProto::FindPassiveDCCSend(int iToken)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_xfers.getCount(); i++ ) {
-		if ( m_dcc_xfers[ i ]->iToken == iToken ) {
+	for (int i = 0; i < m_dcc_xfers.getCount(); i++) {
+		if (m_dcc_xfers[i]->iToken == iToken) {
 			LeaveCriticalSection(&m_dcc);
-			return m_dcc_xfers[ i ];
+			return m_dcc_xfers[i];
 		}
 	}
 
@@ -583,9 +589,9 @@ CDccSession* CIrcProto::FindPassiveDCCRecv(CMString sName, CMString sToken)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_xfers.getCount(); i++ ) {
+	for (int i = 0; i < m_dcc_xfers.getCount(); i++) {
 		CDccSession* p = m_dcc_xfers[i];
-		if ( sToken == p->di->sToken && sName == p->di->sContactName ) {
+		if (sToken == p->di->sToken && sName == p->di->sContactName) {
 			LeaveCriticalSection(&m_dcc);
 			return p;
 		}
@@ -598,9 +604,9 @@ void CIrcProto::DisconnectAllDCCSessions(bool Shutdown)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_chats.getCount(); i++ )
-		if ( m_disconnectDCCChats || Shutdown )
-			m_dcc_chats[i]->Disconnect();
+	for (int i = 0; i < m_dcc_chats.getCount(); i++)
+	if (m_disconnectDCCChats || Shutdown)
+		m_dcc_chats[i]->Disconnect();
 
 	LeaveCriticalSection(&m_dcc);
 }
@@ -609,15 +615,15 @@ void CIrcProto::CheckDCCTimeout(void)
 {
 	EnterCriticalSection(&m_dcc);
 
-	for ( int i=0; i < m_dcc_chats.getCount(); i++ ) {
+	for (int i = 0; i < m_dcc_chats.getCount(); i++) {
 		CDccSession* p = m_dcc_chats[i];
-		if ( time(0) > p->tLastActivity + DCCCHATTIMEOUT )
+		if (time(0) > p->tLastActivity + DCCCHATTIMEOUT)
 			p->Disconnect();
 	}
 
-	for ( int j=0; j < m_dcc_xfers.getCount(); j++ ) {
+	for (int j = 0; j < m_dcc_xfers.getCount(); j++) {
 		CDccSession* p = m_dcc_xfers[j];
-		if ( time(0) > p->tLastActivity + DCCSENDTIMEOUT )
+		if (time(0) > p->tLastActivity + DCCSENDTIMEOUT)
 			p->Disconnect();
 	}
 
@@ -626,17 +632,17 @@ void CIrcProto::CheckDCCTimeout(void)
 
 ////////////////////////////////////////////////////////////////////
 
-CIrcIgnoreItem::CIrcIgnoreItem( const TCHAR* _mask, const TCHAR* _flags, const TCHAR* _network ) :
-	mask( _mask ),
-	flags( _flags ),
-	network( _network )
+CIrcIgnoreItem::CIrcIgnoreItem(const TCHAR* _mask, const TCHAR* _flags, const TCHAR* _network) :
+	mask(_mask),
+	flags(_flags),
+	network(_network)
 {
 }
 
-CIrcIgnoreItem::CIrcIgnoreItem( int codepage, const char* _mask, const char* _flags, const char* _network ) :
-	mask( (TCHAR *)_A2T( _mask, codepage )),
-	flags( (TCHAR *)_A2T( _flags, codepage )),
-	network( (TCHAR *)_A2T( _network, codepage ))
+CIrcIgnoreItem::CIrcIgnoreItem(int codepage, const char* _mask, const char* _flags, const char* _network) :
+	mask((TCHAR*)_A2T(_mask, codepage)),
+	flags((TCHAR*)_A2T(_flags, codepage)),
+	network((TCHAR*)_A2T(_network, codepage))
 {
 }
 
@@ -690,32 +696,31 @@ void CIrcSessionInfo::Reset()
 
 void CIrcProto::OnIrcMessage(const CIrcMessage* pmsg)
 {
-	if ( pmsg != NULL ) {
-		PfnIrcMessageHandler pfn = FindMethod( pmsg->sCommand.c_str());
-		if ( pfn ) {
+	if (pmsg != NULL) {
+		PfnIrcMessageHandler pfn = FindMethod(pmsg->sCommand.c_str());
+		if (pfn) {
 			// call member function. if it returns 'false',
 			// call the default handling
-			__try
-			{
-				if ( !(this->*pfn)( pmsg ))
-					OnIrcDefault( pmsg );
+			__try {
+				if (!(this->*pfn)(pmsg))
+					OnIrcDefault(pmsg);
 			}
-			__except( EXCEPTION_EXECUTE_HANDLER ) // dedicated to Sava :)
+			__except (EXCEPTION_EXECUTE_HANDLER) // dedicated to Sava :)
 			{
-				debugLogA( "IRC handler feels sick: %S", pmsg->sCommand.c_str());
+				debugLogA("IRC handler feels sick: %S", pmsg->sCommand.c_str());
 			}
 		}
 		else // handler not found. call default handler
-			OnIrcDefault( pmsg );
+			OnIrcDefault(pmsg);
 	}
 	else OnIrcDisconnected();
 }
 
 PfnIrcMessageHandler CIrcProto::FindMethod(const TCHAR* lpszName)
 {
-	CIrcHandler temp( lpszName, NULL );
-	CIrcHandler* p = m_handlers.find( &temp );
-	return ( p == NULL ) ? NULL : p->m_handler;
+	CIrcHandler temp(lpszName, NULL);
+	CIrcHandler* p = m_handlers.find(&temp);
+	return (p == NULL) ? NULL : p->m_handler;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -733,15 +738,15 @@ char* ConvertIntegerToIP(unsigned long int_ip_addr)
 	in.S_un.S_un_b.s_b3 = intemp.S_un.S_un_b.s_b2;
 	in.S_un.S_un_b.s_b4 = intemp.S_un.S_un_b.s_b1;
 
-	return inet_ntoa( in );
+	return inet_ntoa(in);
 }
 
-unsigned long ConvertIPToInteger( char* IP )
+unsigned long ConvertIPToInteger(char* IP)
 {
 	IN_ADDR in;
 	IN_ADDR intemp;
 
-	if ( IP == 0 || lstrlenA(IP) == 0)
+	if (IP == 0 || lstrlenA(IP) == 0)
 		return 0;
 
 	intemp.S_un.S_addr = inet_addr(IP);
@@ -756,8 +761,8 @@ unsigned long ConvertIPToInteger( char* IP )
 ////////////////////////////////////////////////////////////////////
 
 // initialize basic stuff needed for the dcc objects, also start a timer for checking the status of connections (timeouts)
-CDccSession::CDccSession( CIrcProto* _pro, DCCINFO* pdci ) :
-	m_proto( _pro ),
+CDccSession::CDccSession(CIrcProto* _pro, DCCINFO* pdci) :
+	m_proto(_pro),
 	NewFileName(0),
 	dwWhatNeedsDoing(0),
 	tLastPercentageUpdate(0),
@@ -775,67 +780,68 @@ CDccSession::CDccSession( CIrcProto* _pro, DCCINFO* pdci ) :
 	ZeroMemory(&pfts, sizeof(PROTOFILETRANSFERSTATUS));
 	pfts.cbSize = sizeof(PROTOFILETRANSFERSTATUS);
 
-	if(di->iType == DCC_SEND && di->bSender == false)
+	if (di->iType == DCC_SEND && di->bSender == false)
 		hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
 
-	if(nDcc == 0)
-		m_proto->SetChatTimer(m_proto->DCCTimer, 20*1000, DCCTimerProc);
+	if (nDcc == 0)
+		m_proto->SetChatTimer(m_proto->DCCTimer, 20 * 1000, DCCTimerProc);
 
 	nDcc++; // increase the count of existing objects
 
 	iGlobalToken++;
-	if(iGlobalToken == 1000)
+	if (iGlobalToken == 1000)
 		iGlobalToken = 1;
 	iToken = iGlobalToken;
 
-	iPacketSize = m_proto->getWord( "PacketSize", 4096 );
+	iPacketSize = m_proto->getWord("PacketSize", 4096);
 
-	if ( di->dwAdr )
+	if (di->dwAdr)
 		m_proto->setDword(di->hContact, "IP", di->dwAdr); // mtooltip stuff
 }
 
 CDccSession::~CDccSession() // destroy all that needs destroying
 {
-	if ( di->iType == DCC_SEND ) {
+	if (di->iType == DCC_SEND) {
 		// ack SUCCESS or FAILURE
-		if (dwTotal == di->dwSize )
+		if (dwTotal == di->dwSize)
 			ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (void *)di, 0);
 		else
 			ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (void *)di, 0);
 	}
 
-	if ( di->iType == DCC_CHAT ) {
+	if (di->iType == DCC_CHAT) {
 		CDccSession* dcc = m_proto->FindDCCSession(di->hContact);
-		if ( dcc && this == dcc ) {
+		if (dcc && this == dcc) {
 			m_proto->RemoveDCCSession(di->hContact); // objects automatically remove themselves from the list of objects
 			m_proto->setWord(di->hContact, "Status", ID_STATUS_OFFLINE);
-	}	}
+		}
+	}
 
-	if ( di->iType == DCC_SEND )
-		m_proto->RemoveDCCSession( di ); 
+	if (di->iType == DCC_SEND)
+		m_proto->RemoveDCCSession(di);
 
-	if ( hEvent != NULL ) {
-		SetEvent( hEvent );
-		CloseHandle( hEvent );
+	if (hEvent != NULL) {
+		SetEvent(hEvent);
+		CloseHandle(hEvent);
 		hEvent = NULL;
 	}
 
 	delete di;
 	nDcc--;
 
-	if ( nDcc < 0 )
+	if (nDcc < 0)
 		nDcc = 0;
 
-	if ( nDcc == 0 )
-		m_proto->KillChatTimer( m_proto->DCCTimer ); // destroy the timer when no dcc objects remain
+	if (nDcc == 0)
+		m_proto->KillChatTimer(m_proto->DCCTimer); // destroy the timer when no dcc objects remain
 }
 
-int CDccSession::NLSend(const unsigned char* buf, int cbBuf) 
+int CDccSession::NLSend(const unsigned char* buf, int cbBuf)
 {
 	tLastActivity = time(0);
 
 	if (con)
-		return Netlib_Send(con, (const char*)buf, cbBuf, di->iType == DCC_CHAT?MSG_DUMPASTEXT:MSG_NODUMP);
+		return Netlib_Send(con, (const char*)buf, cbBuf, di->iType == DCC_CHAT ? MSG_DUMPASTEXT : MSG_NODUMP);
 
 	return 0;
 }
@@ -844,8 +850,8 @@ int CDccSession::NLReceive(const unsigned char* buf, int cbBuf)
 {
 	int n = 0;
 
-	if(con)
-		n = Netlib_Recv(con, (char*)buf, cbBuf, di->iType == DCC_CHAT?MSG_DUMPASTEXT:MSG_NODUMP);
+	if (con)
+		n = Netlib_Recv(con, (char*)buf, cbBuf, di->iType == DCC_CHAT ? MSG_DUMPASTEXT : MSG_NODUMP);
 
 	tLastActivity = time(0);
 	return n;
@@ -853,29 +859,29 @@ int CDccSession::NLReceive(const unsigned char* buf, int cbBuf)
 
 int CDccSession::SendStuff(const TCHAR* fmt)
 {
-	String buf = _T2A( fmt, m_proto->getCodepage());
-	return NLSend(( const unsigned char* )buf.c_str(), buf.GetLength());
+	String buf = _T2A(fmt, m_proto->getCodepage());
+	return NLSend((const unsigned char*)buf.c_str(), buf.GetLength());
 }
 
 // called when the user wants to connect/create a new connection given the parameters in the constructor.
 int CDccSession::Connect()
 {
-	if ( !di->bSender || di->bReverse ) {
-		if ( !con )
-			mir_forkthread( ConnectProc, this ); // spawn a new thread for time consuming activities, ie when connecting to a remote computer
+	if (!di->bSender || di->bReverse) {
+		if (!con)
+			mir_forkthread(ConnectProc, this); // spawn a new thread for time consuming activities, ie when connecting to a remote computer
 		return true;
 	}
 
-	if ( !con )
+	if (!con)
 		return SetupConnection(); // no need to spawn thread for setting up a listening port locally
 
-	return false; 
+	return false;
 }
 
-void __cdecl CDccSession::ConnectProc( void *pparam )
+void __cdecl CDccSession::ConnectProc(void *pparam)
 {
 	CDccSession* pThis = (CDccSession*)pparam;
-	if ( !pThis->con )
+	if (!pThis->con)
 		pThis->SetupConnection();
 }
 
@@ -891,38 +897,38 @@ void CDccSession::SetupPassive(DWORD adress, DWORD port)
 int CDccSession::SetupConnection()
 {
 	// if it is a dcc chat connection make sure it is "offline" to begin with, since no connection exists still
-	if ( di->iType == DCC_CHAT )
+	if (di->iType == DCC_CHAT)
 		m_proto->setWord(di->hContact, "Status", ID_STATUS_OFFLINE);
 
 	// Set up stuff needed for the filetransfer dialog (if it is a filetransfer)
-	if ( di->iType == DCC_SEND ) {
-		file[0] = ( TCHAR* )di->sFileAndPath.c_str();
+	if (di->iType == DCC_SEND) {
+		file[0] = (TCHAR*)di->sFileAndPath.c_str();
 		file[1] = 0;
 
-		pfts.tszCurrentFile = ( TCHAR* )di->sFileAndPath.c_str();
-		pfts.tszWorkingDir =	( TCHAR* )di->sPath.c_str();
+		pfts.tszCurrentFile = (TCHAR*)di->sFileAndPath.c_str();
+		pfts.tszWorkingDir = (TCHAR*)di->sPath.c_str();
 		pfts.hContact = di->hContact;
 		pfts.flags = PFTS_TCHAR + ((di->bSender) ? PFTS_SENDING : PFTS_RECEIVING);
-		pfts.totalFiles =	1;
+		pfts.totalFiles = 1;
 		pfts.currentFileNumber = 0;
-		pfts.totalBytes =	di->dwSize;
+		pfts.totalBytes = di->dwSize;
 		pfts.currentFileSize = pfts.totalBytes;
 		pfts.ptszFiles = file;
 		pfts.totalProgress = 0;
-		pfts.currentFileProgress =	0;
+		pfts.currentFileProgress = 0;
 		pfts.currentFileTime = (unsigned long)time(0);
 	}
 
 	// create a listening socket for outgoing chat/send requests. The remote computer connects to this computer. Used for both chat and filetransfer.
-	if ( di->bSender && !di->bReverse ) {
-		NETLIBBIND nb = {0};
+	if (di->bSender && !di->bReverse) {
+		NETLIBBIND nb = { 0 };
 		nb.cbSize = sizeof(NETLIBBIND);
 		nb.pfnNewConnectionV2 = DoIncomingDcc; // this is the (helper) function to be called once an incoming connection is made. The 'real' function that is called is IncomingConnection()
-		nb.pExtra = (void *)this; 
+		nb.pExtra = (void *)this;
 		nb.wPort = 0;
 		hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&nb);
 
-		if ( hBindPort == NULL ) {
+		if (hBindPort == NULL) {
 			delete this; // dcc objects destroy themselves when the connection has been closed or failed for some reasson.
 			return 0;
 		}
@@ -933,16 +939,16 @@ int CDccSession::SetupConnection()
 
 	// If a remote computer initiates a chat session this is used to connect to the remote computer (user already accepted at this point). 
 	// also used for connecting to a remote computer for remote file transfers
-	if ( di->iType == DCC_CHAT && !di->bSender || di->iType == DCC_SEND && di->bSender && di->bReverse ) {
+	if (di->iType == DCC_CHAT && !di->bSender || di->iType == DCC_SEND && di->bSender && di->bReverse) {
 		NETLIBOPENCONNECTION ncon = { 0 };
 		ncon.cbSize = sizeof(ncon);
-		ncon.szHost = ConvertIntegerToIP(di->dwAdr); 
-		ncon.wPort = (WORD) di->iPort;
+		ncon.szHost = ConvertIntegerToIP(di->dwAdr);
+		ncon.wPort = (WORD)di->iPort;
 		con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&ncon);
 	}
 
 	// If a remote computer initiates a filetransfer this is used to connect to that computer (the user has chosen to accept but it is possible the file exists/needs to be resumed etc still)
-	if ( di->iType == DCC_SEND && !di->bSender ) {
+	if (di->iType == DCC_SEND && !di->bSender) {
 
 		// this following code is for miranda to be able to show the resume/overwrite etc dialog if the file that we are receiving already exists. 
 		// It must be done before we create the connection or else the other party will begin sending packets while the user is still deciding if 
@@ -952,56 +958,57 @@ int CDccSession::SetupConnection()
 		// dwWhatNeedsDoing will be set using InterlockedExchange() (from other parts of the code depending on action) before SetEvent() is called.
 		// If the user has chosen rename then InterlockedExchange() will be used for setting NewFileName to a string containing the new name.
 		// Furthermore dwResumePos will be set using InterlockedExchange() to indicate what the file position to start from is.
-		if ( ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, (void *)di, (LPARAM)&pfts)) { 
-			WaitForSingleObject( hEvent, INFINITE );
-			switch( dwWhatNeedsDoing ) {
+		if (ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, (void *)di, (LPARAM)&pfts)) {
+			WaitForSingleObject(hEvent, INFINITE);
+			switch (dwWhatNeedsDoing) {
 			case FILERESUME_RENAME:
 				// If the user has chosen to rename the file we need to change variables accordingly. NewFileName has been set using
 				// InterlockedExchange()
-				if ( NewFileName) { // the user has chosen to rename the new incoming file.
+				if (NewFileName) { // the user has chosen to rename the new incoming file.
 					di->sFileAndPath = NewFileName;
 
-					int i = di->sFileAndPath.ReverseFind( '\\' );
-					if ( i != -1 ) {
-						di->sPath = di->sFileAndPath.Mid(0, i+1);
-						di->sFile = di->sFileAndPath.Mid(i+1, di->sFileAndPath.GetLength());
+					int i = di->sFileAndPath.ReverseFind('\\');
+					if (i != -1) {
+						di->sPath = di->sFileAndPath.Mid(0, i + 1);
+						di->sFile = di->sFileAndPath.Mid(i + 1, di->sFileAndPath.GetLength());
 					}
 
-					pfts.tszCurrentFile = ( TCHAR* )di->sFileAndPath.c_str();
-					pfts.tszWorkingDir =	( TCHAR* )di->sPath.c_str();
+					pfts.tszCurrentFile = (TCHAR*)di->sFileAndPath.c_str();
+					pfts.tszWorkingDir = (TCHAR*)di->sPath.c_str();
 					pfts.totalBytes = di->dwSize;
 					pfts.currentFileSize = pfts.totalBytes;
-					
+
 					delete[] NewFileName;
 					NewFileName = NULL;
 				}
 				break;
 
-			case FILERESUME_OVERWRITE:	
-			case FILERESUME_RESUME	:	
+			case FILERESUME_OVERWRITE:
+			case FILERESUME_RESUME:
 				// no action needed at this point, just break out of the switch statement
 				break;
 
-			case FILERESUME_CANCEL	:
-				return FALSE; 
+			case FILERESUME_CANCEL:
+				return FALSE;
 
-			case FILERESUME_SKIP	:
+			case FILERESUME_SKIP:
 			default:
 				delete this; // per usual dcc objects destroy themselves when they fail or when connection is closed
-				return FALSE; 
-		}	}			
+				return FALSE;
+			}
+		}
 
 		// hack for passive filetransfers
-		if ( di->iType == DCC_SEND && !di->bSender && di->bReverse ) {
-			NETLIBBIND nb = {0};
+		if (di->iType == DCC_SEND && !di->bSender && di->bReverse) {
+			NETLIBBIND nb = { 0 };
 			nb.cbSize = sizeof(NETLIBBIND);
 			nb.pfnNewConnectionV2 = DoIncomingDcc; // this is the (helper) function to be called once an incoming connection is made. The 'real' function that is called is IncomingConnection()
-			nb.pExtra = (void *)this; 
+			nb.pExtra = (void *)this;
 			nb.wPort = 0;
 			hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&nb);
 
-			if ( hBindPort == NULL ) {
-				m_proto->DoEvent(GC_EVENT_INFORMATION, 0, m_proto->m_info.sNick.c_str(), LPGENT("DCC ERROR: Unable to bind local port for passive filetransfer"), NULL, NULL, NULL, true, false); 
+			if (hBindPort == NULL) {
+				m_proto->DoEvent(GC_EVENT_INFORMATION, 0, m_proto->m_info.sNick.c_str(), LPGENT("DCC ERROR: Unable to bind local port for passive filetransfer"), NULL, NULL, NULL, true, false);
 				delete this; // dcc objects destroy themselves when the connection has been closed or failed for some reasson.
 				return 0;
 			}
@@ -1011,46 +1018,46 @@ int CDccSession::SetupConnection()
 			CMString sFileWithQuotes = di->sFile;
 
 			// if spaces in the filename surround with quotes
-			if ( sFileWithQuotes.Find( ' ', 0 ) != -1 ) {
-				sFileWithQuotes.Insert( 0, _T("\""));
-				sFileWithQuotes.Insert( sFileWithQuotes.GetLength(), _T("\""));
+			if (sFileWithQuotes.Find(' ', 0) != -1) {
+				sFileWithQuotes.Insert(0, _T("\""));
+				sFileWithQuotes.Insert(sFileWithQuotes.GetLength(), _T("\""));
 			}
 
 			// send out DCC RECV command for passive filetransfers
 			unsigned long ulAdr = 0;
-			if ( m_proto->m_manualHost )
-				ulAdr = ConvertIPToInteger( m_proto->m_mySpecifiedHostIP );				
+			if (m_proto->m_manualHost)
+				ulAdr = ConvertIPToInteger(m_proto->m_mySpecifiedHostIP);
 			else
-				ulAdr = m_proto->m_IPFromServer ? ConvertIPToInteger( m_proto->m_myHost ) : nb.dwExternalIP;
+				ulAdr = m_proto->m_IPFromServer ? ConvertIPToInteger(m_proto->m_myHost) : nb.dwExternalIP;
 
-			if ( di->iPort && ulAdr )
-				m_proto->PostIrcMessage( _T("/CTCP %s DCC SEND %s %u %u %I64u %s"), di->sContactName.c_str(), sFileWithQuotes.c_str(), ulAdr, di->iPort, di->dwSize, di->sToken.c_str());
+			if (di->iPort && ulAdr)
+				m_proto->PostIrcMessage(_T("/CTCP %s DCC SEND %s %u %u %I64u %s"), di->sContactName.c_str(), sFileWithQuotes.c_str(), ulAdr, di->iPort, di->dwSize, di->sToken.c_str());
 
-			return TRUE; 			
+			return TRUE;
 		}
 
 		// connect to the remote computer from which you are receiving the file (now all actions to take (resume/overwrite etc) have been decided
 		NETLIBOPENCONNECTION ncon = { 0 };
 		ncon.cbSize = sizeof(ncon);
 		ncon.szHost = ConvertIntegerToIP(di->dwAdr);
-		ncon.wPort = (WORD) di->iPort;
+		ncon.wPort = (WORD)di->iPort;
 
 		con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&ncon);
 	}
 
 	// if for some reason the plugin has failed to connect to the remote computer the object is destroyed.
-	if ( con == NULL ) {
+	if (con == NULL) {
 		delete this;
 		return FALSE; // failed to connect
 	}
 
 	// if it is a chat connection set the user to online now since we now know there is a connection
-	if ( di->iType == DCC_CHAT )
+	if (di->iType == DCC_CHAT)
 		m_proto->setWord(di->hContact, "Status", ID_STATUS_ONLINE);
 
 	// spawn a new thread to handle receiving/sending of data for the new chat/filetransfer connection to the remote computer
-	mir_forkthread( ThreadProc, this  );
-	
+	mir_forkthread(ThreadProc, this);
+
 	return con != NULL;
 }
 
@@ -1058,70 +1065,70 @@ int CDccSession::SetupConnection()
 int CDccSession::IncomingConnection(HANDLE hConnection, DWORD dwIP)
 {
 	con = hConnection;
-	if ( con == NULL ) {
+	if (con == NULL) {
 		delete this;
 		return false; // failed to connect
 	}
 
 	m_proto->setDword(di->hContact, "IP", dwIP); // mToolTip stuff
 
-	if ( di->iType == DCC_CHAT )
+	if (di->iType == DCC_CHAT)
 		m_proto->setWord(di->hContact, "Status", ID_STATUS_ONLINE); // set chat to online
 
 	// same as above, spawn a new thread to handle receiving/sending of data for the new incoming chat/filetransfer connection  
-	mir_forkthread(ThreadProc, this  );
+	mir_forkthread(ThreadProc, this);
 	return true;
 }
 
 // here we decide which function to use for communicating with the remote computer, depending on connection type
-void __cdecl CDccSession::ThreadProc(void *pparam) 
+void __cdecl CDccSession::ThreadProc(void *pparam)
 {
 	CDccSession* pThis = (CDccSession*)pparam;
 
 	// if it is an incoming connection on a listening port, then we should close the listenting port so only one can connect (the one you offered
 	// the connection to) can connect and not evil IRCopers with haxxored IRCDs
-	if ( pThis->hBindPort ) {
+	if (pThis->hBindPort) {
 		Netlib_CloseHandle(pThis->hBindPort);
 		pThis->hBindPort = NULL;
 	}
 
-	if ( pThis->di->iType == DCC_CHAT )
+	if (pThis->di->iType == DCC_CHAT)
 		pThis->DoChatReceive(); // dcc chat
 
-	else if ( !pThis->di->bSender )
+	else if (!pThis->di->bSender)
 		pThis->DoReceiveFile(); // receive a file
 
-	else if ( pThis->di->bSender )
+	else if (pThis->di->bSender)
 		pThis->DoSendFile(); // send a file
 }
 
 // this is done when the user is initiating a filetransfer to a remote computer
-void CDccSession::DoSendFile() 
+void CDccSession::DoSendFile()
 {
 	// initialize the filetransfer dialog
 	ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (void *)di, 0);
 	ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, (void *)di, 0);
 
-	WORD wPacketSize = m_proto->getWord( "DCCPacketSize", 1024*4);
+	WORD wPacketSize = m_proto->getWord("DCCPacketSize", 1024 * 4);
 
-	if ( wPacketSize < 256 )
+	if (wPacketSize < 256)
 		wPacketSize = 256;
 
-	if ( wPacketSize > 32 * 1024 )
+	if (wPacketSize > 32 * 1024)
 		wPacketSize = 32 * 1024;
 
-	BYTE* chBuf = new BYTE[wPacketSize+1];
+	BYTE* chBuf = new BYTE[wPacketSize + 1];
 
 	// is there a connection?
-	if ( con ) {
+	if (con) {
 		// open the file for reading
-		int hFile = _topen( di->sFileAndPath.c_str(), _O_RDONLY | _O_BINARY, _S_IREAD);
-		if (hFile >= 0) {	
+		int hFile = _topen(di->sFileAndPath.c_str(), _O_RDONLY | _O_BINARY, _S_IREAD);
+		if (hFile >= 0) {
 			unsigned __int64 dwLastAck = 0;
 
 			// if the user has chosen to resume a file, dwResumePos will contain a value (set using InterlockedExchange())
 			// and then the variables and the file pointer are changed accordingly.
-			if ( dwResumePos && dwWhatNeedsDoing == FILERESUME_RESUME ) {
+			if (dwResumePos && dwWhatNeedsDoing == FILERESUME_RESUME) {
 				_lseeki64(hFile, dwResumePos, SEEK_SET);
 				dwTotal = dwResumePos;
 				dwLastAck = dwResumePos;
@@ -1130,96 +1137,97 @@ void CDccSession::DoSendFile()
 			}
 
 			// initial ack to set the 'percentage-ready meter' to the correct value
-			ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM) &pfts);
-			
+			ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM)&pfts);
+
 			tLastActivity = time(0);
 
 			// create a packet receiver to handle receiving ack's from the remote computer.
 			HANDLE hPackrcver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)con, sizeof(DWORD));
 			NETLIBPACKETRECVER npr;
 			npr.cbSize = sizeof(NETLIBPACKETRECVER);
-			npr.dwTimeout = 60*1000;
-			npr.bufferSize = sizeof(DWORD); 
+			npr.dwTimeout = 60 * 1000;
+			npr.bufferSize = sizeof(DWORD);
 			npr.bytesUsed = 0;
 
 			// until the connection is dropped it will spin around in this while() loop
-			while ( con ) {
+			while (con) {
 				// read a packet
 				int iRead = _read(hFile, chBuf, wPacketSize);
-				if ( iRead <= 0 )
+				if (iRead <= 0)
 					break; // break out if everything has already been read
 
 				// send the package
 				int cbSent = NLSend((unsigned char*)chBuf, iRead);
-				if ( cbSent <= 0 )
+				if (cbSent <= 0)
 					break; // break out if connection is lost or a transmission error has occured
 
-				if ( !con )
+				if (!con)
 					break;
 
 				dwTotal += cbSent;
 
 				// block connection and receive ack's from remote computer (if applicable)
-				if ( m_proto->m_DCCMode == 0 ) {
+				if (m_proto->m_DCCMode == 0) {
 					DWORD dwRead = 0;
 					DWORD dwPacket = NULL;
 
-					do {					
+					do {
 						dwRead = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hPackrcver, (LPARAM)&npr);
-						npr.bytesUsed = sizeof(DWORD);          
+						npr.bytesUsed = sizeof(DWORD);
 
-						if ( dwRead <= 0)
+						if (dwRead <= 0)
 							break; // connection closed, or a timeout occurred.
 
-						dwPacket  = *(DWORD*)npr.buffer;
+						dwPacket = *(DWORD*)npr.buffer;
 						dwLastAck = ntohl(dwPacket);
 
 					}
-						while(con && dwTotal != dwLastAck);
+					while (con && dwTotal != dwLastAck);
 
-					if ( !con || dwRead <= 0 )
+					if (!con || dwRead <= 0)
 						goto DCC_STOP;
 				}
 
-				if ( m_proto->m_DCCMode == 1 ) {
+				if (m_proto->m_DCCMode == 1) {
 					DWORD dwRead = 0;
 					DWORD dwPacket = 0;
 
-					do {					
+					do {
 						dwRead = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hPackrcver, (LPARAM)&npr);
-						npr.bytesUsed = sizeof(DWORD);          
-						if ( dwRead <= 0)
+						npr.bytesUsed = sizeof(DWORD);
+						if (dwRead <= 0)
 							break; // connection closed, or a timeout occurred.
 
-						dwPacket =  *(DWORD*)npr.buffer;
+						dwPacket = *(DWORD*)npr.buffer;
 						dwLastAck = ntohl(dwPacket);
 					}
-						while(con && (di->dwSize != dwTotal
-						&& dwTotal - dwLastAck >= 100*1024
-						|| di->dwSize == dwTotal // get the last packets when the whole file has been sent
-						&& dwTotal != dwLastAck));
+					while (con && (di->dwSize != dwTotal
+					&& dwTotal - dwLastAck >= 100 * 1024
+					|| di->dwSize == dwTotal // get the last packets when the whole file has been sent
+					&& dwTotal != dwLastAck));
 
-					if ( !con || dwRead <= 0 )
+					if (!con || dwRead <= 0)
 						goto DCC_STOP;
-				}				
+				}
 
 				// update the filetransfer dialog's 'percentage-ready meter' once per second only to save cpu
-				if ( tLastPercentageUpdate < time(0)) {
+				if (tLastPercentageUpdate < time(0)) {
 					tLastPercentageUpdate = time(0);
 					pfts.totalProgress = dwTotal;
 					pfts.currentFileProgress = dwTotal;
-					ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM) &pfts);
+					ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM)&pfts);
 				}
 
 				// close the connection once the whole file has been sent an completely ack'ed
-				if ( dwLastAck >= di->dwSize ) {
+				if (dwLastAck >= di->dwSize) {
 					Netlib_CloseHandle(con);
 					con = NULL;
-			}	}
+				}
+			}
 
-DCC_STOP:
+		DCC_STOP:
 			// need to close the connection if it isn't allready
-			if ( con ) {
+			if (con) {
 				Netlib_CloseHandle(con);
 				con = NULL;
 			}
@@ -1228,43 +1236,44 @@ DCC_STOP:
 			tLastActivity = time(0);
 			pfts.totalProgress = dwTotal;
 			pfts.currentFileProgress = dwTotal;
-			ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM) &pfts);
+			ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM)&pfts);
 
 			_close(hFile);
 		}
-		else // file was not possible to open for reading
-		{
+		else { // file was not possible to open for reading
 			ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (void *)di, 0);
-			if ( con ) {
+			if (con) {
 				Netlib_CloseHandle(con);
 				con = NULL;
-	}	}	}
+			}
+		}
+	}
 
-	delete []chBuf;
+	delete[]chBuf;
 	delete this; // ... and hopefully all went right, cuz here the object is deleted in any case
 }
 
 // This is called when receiving a file from a remote computer.
-void CDccSession::DoReceiveFile() 
+void CDccSession::DoReceiveFile()
 {
 	// initialize the filetransfer dialog
-	ProtoBroadcastAck( m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (void *)di, 0);
+	ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (void *)di, 0);
 
-	BYTE chBuf[1024*32+1];
+	BYTE chBuf[1024 * 32 + 1];
 
 	// do some stupid thing so  the filetransfer dialog shows the right thing
 	ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, (void *)di, 0);
 
 	// open the file for writing (and reading in case it is a resume)
-	int hFile = _topen( di->sFileAndPath.c_str(), 
-		(dwWhatNeedsDoing == FILERESUME_RESUME ? _O_APPEND : _O_TRUNC | _O_CREAT) | _O_RDWR | _O_BINARY, 
+	int hFile = _topen(di->sFileAndPath.c_str(),
+		(dwWhatNeedsDoing == FILERESUME_RESUME ? _O_APPEND : _O_TRUNC | _O_CREAT) | _O_RDWR | _O_BINARY,
 		_S_IREAD | _S_IWRITE);
-	if ( hFile >= 0 ) {	
+	if (hFile >= 0) {
 		unsigned __int64 dwLastAck = 0;
 
 		// dwResumePos and dwWhatNeedsDoing has possibly been set using InterlockedExchange()
 		// if set it is a resume and we adjust variables and the file pointer accordingly.
-		if ( dwResumePos && dwWhatNeedsDoing == FILERESUME_RESUME ) {
+		if (dwResumePos && dwWhatNeedsDoing == FILERESUME_RESUME) {
 			_lseeki64(hFile, dwResumePos, SEEK_SET);
 			dwTotal = dwResumePos;
 			dwLastAck = dwResumePos;
@@ -1273,15 +1282,15 @@ void CDccSession::DoReceiveFile()
 		}
 
 		// send an initial ack for the percentage-ready meter
-		ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM) &pfts);
-		
+		ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM)&pfts);
+
 		// the while loop will spin around till the connection is dropped, locally or by the remote computer.
-		while ( con ) {
+		while (con) {
 			// read
 			int cbRead = NLReceive((unsigned char*)chBuf, sizeof(chBuf));
-			if ( cbRead <= 0 )
+			if (cbRead <= 0)
 				break;
-			
+
 			// write it to the file
 			_write(hFile, chBuf, cbRead);
 
@@ -1289,7 +1298,7 @@ void CDccSession::DoReceiveFile()
 
 			// this snippet sends out an ack for every 4 kb received in send ahead
 			// or every packet for normal mode
-			if ( !di->bTurbo ) {
+			if (!di->bTurbo) {
 				DWORD no = dwTotal;
 				no = htonl(no);
 				NLSend((unsigned char *)&no, sizeof(DWORD));
@@ -1299,31 +1308,33 @@ void CDccSession::DoReceiveFile()
 
 			// sets the 'last update time' to check for timed out connections, and also make sure we only
 			// ack the 'percentage-ready meter' only once a second to save CPU.
-			if ( tLastPercentageUpdate < time( 0 )) {
-				tLastPercentageUpdate = time (0);
+			if (tLastPercentageUpdate < time(0)) {
+				tLastPercentageUpdate = time(0);
 				pfts.totalProgress = dwTotal;
 				pfts.currentFileProgress = dwTotal;
-				ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM) &pfts);
-			}	
-			
+				ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM)&pfts);
+			}
+
 			// if file size is known and everything is received then disconnect 
-			if ( di->dwSize && di->dwSize == dwTotal ) {
+			if (di->dwSize && di->dwSize == dwTotal) {
 				Netlib_CloseHandle(con);
 				con = NULL;
-		}	}
+			}
+		}
 		// receiving loop broken locally or by remote computer, just some cleaning up left....
-		
+
 		pfts.totalProgress = dwTotal;
 		pfts.currentFileProgress = dwTotal;
-		ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM) &pfts);
+		ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (void *)di, (LPARAM)&pfts);
 		_close(hFile);
 	}
-	else  {
+	else {
 		ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (void *)di, 0);
-		if ( con ) { // file not possible to open for writing so we ack FAILURE and close the handle
+		if (con) { // file not possible to open for writing so we ack FAILURE and close the handle
 			Netlib_CloseHandle(con);
 			con = NULL;
-	}	}
+		}
+	}
 
 	delete this; // and finally the object is deleted
 }
@@ -1334,52 +1345,52 @@ void CDccSession::DoReceiveFile()
 
 void CDccSession::DoChatReceive()
 {
-	char chBuf[1024*4+1]; 
+	char chBuf[1024 * 4 + 1];
 	int cbInBuf = 0;
-	
+
 	// loop to spin around while there is a connection
-	while( con ) {
+	while (con) {
 		int cbRead;
 		int nLinesProcessed = 0;
-		
-		cbRead = NLReceive((unsigned char*)chBuf+cbInBuf, sizeof(chBuf)-cbInBuf-1);
-		if ( cbRead <= 0 )
+
+		cbRead = NLReceive((unsigned char*)chBuf + cbInBuf, sizeof(chBuf)-cbInBuf - 1);
+		if (cbRead <= 0)
 			break;
 
 		cbInBuf += cbRead;
 		chBuf[cbInBuf] = '\0';
-		
+
 		char* pStart = chBuf;
-		while( *pStart ) {
+		while (*pStart) {
 			char* pEnd;
-			
+
 			// seek end-of-line
-			for(pEnd=pStart; *pEnd && *pEnd != '\r' && *pEnd != '\n'; ++pEnd)
+			for (pEnd = pStart; *pEnd && *pEnd != '\r' && *pEnd != '\n'; ++pEnd)
 				;
-			if ( *pEnd == '\0' )
+			if (*pEnd == '\0')
 				break; // uncomplete message. stop parsing.
-			
+
 			++nLinesProcessed;
-			
+
 			// replace end-of-line with NULLs and skip
-			while( *pEnd == '\r' || *pEnd == '\n' )
+			while (*pEnd == '\r' || *pEnd == '\n')
 				*pEnd++ = '\0';
-			
-			if ( *pStart ) {
+
+			if (*pStart) {
 				// send it off to some messaging module
-				PROTORECVEVENT pre = {0};
+				PROTORECVEVENT pre = { 0 };
 				pre.timestamp = (DWORD)time(NULL);
 				pre.szMessage = pStart;
 				ProtoChainRecvMsg(di->hContact, &pre);
 			}
-			
+
 			cbInBuf -= pEnd - pStart;
 			pStart = pEnd;
 		}
-		
+
 		// discard processed messages
-		if ( nLinesProcessed != 0 )
-			memmove(chBuf, pStart, cbInBuf+1);
+		if (nLinesProcessed != 0)
+			memmove(chBuf, pStart, cbInBuf + 1);
 	}
 
 	delete this; // delete the object when the connection is dropped
@@ -1388,14 +1399,14 @@ void CDccSession::DoChatReceive()
 // disconnect the stuff
 int CDccSession::Disconnect()
 {
-	if ( hBindPort ) {
+	if (hBindPort) {
 		Netlib_CloseHandle(hBindPort);
 		hBindPort = NULL;
 	}
 
 	// if 'con' exists it is cuz a connection exists. 
 	// Terminating 'con' will cause any spawned threads to die and then the object will destroy itself.
-	if ( con ) {
+	if (con) {
 		Netlib_CloseHandle(con);
 		con = NULL;
 	}
@@ -1407,10 +1418,10 @@ int CDccSession::Disconnect()
 ////////////////////////////////////////////////////////////////////
 // check if the dcc chats should disconnect ( default 5 minute timeout )
 
-VOID CALLBACK DCCTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
+VOID CALLBACK DCCTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
 {
-	CIrcProto *ppro = GetTimerOwner( idEvent );
-	if ( ppro )
+	CIrcProto *ppro = GetTimerOwner(idEvent);
+	if (ppro)
 		ppro->CheckDCCTimeout();
 }
 
@@ -1423,55 +1434,52 @@ void DoIncomingDcc(HANDLE hConnection, DWORD dwRemoteIP, void * p1)
 
 // ident server
 
-void strdel( char* parBuffer, int len )
+void strdel(char* parBuffer, int len)
 {
-	char* p;
-	for ( p = parBuffer+len; *p != 0; p++ )
-		p[ -len ] = *p;
+	char *p;
+	for (p = parBuffer + len; *p != 0; p++)
+		p[-len] = *p;
 
-	p[ -len ] = '\0';
+	p[-len] = '\0';
 }
 
-void DoIdent(HANDLE hConnection, DWORD, void* extra )
+void DoIdent(HANDLE hConnection, DWORD, void* extra)
 {
-	CIrcProto *ppro = ( CIrcProto* )extra;
+	CIrcProto *ppro = (CIrcProto*)extra;
 
 	char szBuf[1024];
 	int cbTotal = 0;
 
-	for (;;) {
-		int cbRead = Netlib_Recv(hConnection, szBuf+cbTotal, sizeof(szBuf)-1-cbTotal, 0);
-		if ( cbRead == SOCKET_ERROR || cbRead == 0)
+	while (true) {
+		int cbRead = Netlib_Recv(hConnection, szBuf + cbTotal, sizeof(szBuf)-1 - cbTotal, 0);
+		if (cbRead == SOCKET_ERROR || cbRead == 0)
 			break;
 
 		cbTotal += cbRead;
 		szBuf[cbTotal] = '\0';
-		
+
 LBL_Parse:
 		char* EOLPos = strstr(szBuf, "\r\n");
 		if (EOLPos == NULL)
 			continue;
 
 		EOLPos[0] = EOLPos[1] = '\0';
-		rtrim( szBuf );
+		rtrim(szBuf);
 		ppro->debugLogA("Got Ident request: %s", szBuf);
 
 		unsigned int PeerPortNrRcvd = 0, LocalPortNrRcvd = 0;
-		int iParamCnt = sscanf( szBuf, "%d , %d", &LocalPortNrRcvd, &PeerPortNrRcvd );
+		int iParamCnt = sscanf(szBuf, "%d , %d", &LocalPortNrRcvd, &PeerPortNrRcvd);
 
 		int cbLen = 0;
-		char buf[1024*4];
+		char buf[1024 * 4];
 
 		if (iParamCnt != 2)
 			cbLen = mir_snprintf(buf, SIZEOF(buf), "%s : ERROR : UNKNOWN-ERROR\r\n", szBuf);
-		else 
-		{
-			for (int i = 0; i < g_Instances.getCount(); i++) 
-			{
-				if (PeerPortNrRcvd == g_Instances[i]->m_info.iPort && LocalPortNrRcvd == g_Instances[i]->m_myLocalPort) 
-				{
-					cbLen = mir_snprintf(buf, SIZEOF(buf), "%s : USERID : %S : %S\r\n", 
-						szBuf, g_Instances[i]->m_info.sIdentServerType.c_str() , g_Instances[i]->m_info.sUserID.c_str());
+		else {
+			for (int i = 0; i < g_Instances.getCount(); i++) {
+				if (PeerPortNrRcvd == g_Instances[i]->m_info.iPort && LocalPortNrRcvd == g_Instances[i]->m_myLocalPort) {
+					cbLen = mir_snprintf(buf, SIZEOF(buf), "%s : USERID : %S : %S\r\n",
+						szBuf, g_Instances[i]->m_info.sIdentServerType.c_str(), g_Instances[i]->m_info.sUserID.c_str());
 					break;
 				}
 			}
@@ -1480,12 +1488,12 @@ LBL_Parse:
 				cbLen = mir_snprintf(buf, SIZEOF(buf), "%s : ERROR : INVALID-PORT\r\n", szBuf);
 		}
 
-		if ( Netlib_Send(hConnection, (const char*)buf, cbLen, 0) > 0)
+		if (Netlib_Send(hConnection, (const char*)buf, cbLen, 0) > 0)
 			ppro->debugLogA("Sent Ident answer: %s", buf);
 		else
 			ppro->debugLogA("Sending Ident answer failed.");
-		
-		if ( ppro->m_identTimer )
+
+		if (ppro->m_identTimer)
 			break;
 
 		cbTotal -= EOLPos + 2 - szBuf;
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp
index 360d572843..06d2ae0397 100644
--- a/protocols/IRCG/src/ircproto.cpp
+++ b/protocols/IRCG/src/ircproto.cpp
@@ -41,30 +41,30 @@ CIrcProto::CIrcProto(const char* szModuleName, const TCHAR* tszUserName) :
 {
 	InitializeCriticalSection(&cs);
 	InitializeCriticalSection(&m_gchook);
-	m_evWndCreate = ::CreateEvent( NULL, FALSE, FALSE, NULL );
-
-	CreateProtoService( PS_GETMYAWAYMSG,   &CIrcProto::GetMyAwayMsg );
-
-	CreateProtoService( PS_CREATEACCMGRUI, &CIrcProto::SvcCreateAccMgrUI );
-	CreateProtoService( PS_JOINCHAT,       &CIrcProto::OnJoinChat );
-	CreateProtoService( PS_LEAVECHAT,      &CIrcProto::OnLeaveChat );
-
-	CreateProtoService( IRC_JOINCHANNEL,   &CIrcProto::OnJoinMenuCommand );
-	CreateProtoService( IRC_QUICKCONNECT,  &CIrcProto::OnQuickConnectMenuCommand);
-	CreateProtoService( IRC_CHANGENICK,    &CIrcProto::OnChangeNickMenuCommand );
-	CreateProtoService( IRC_SHOWLIST,      &CIrcProto::OnShowListMenuCommand );
-	CreateProtoService( IRC_SHOWSERVER,    &CIrcProto::OnShowServerMenuCommand );
-	CreateProtoService( IRC_UM_CHANSETTINGS, &CIrcProto::OnMenuChanSettings );
-	CreateProtoService( IRC_UM_WHOIS,      &CIrcProto::OnMenuWhois );
-	CreateProtoService( IRC_UM_DISCONNECT, &CIrcProto::OnMenuDisconnect );
-	CreateProtoService( IRC_UM_IGNORE,     &CIrcProto::OnMenuIgnore );
-
-	CreateProtoService( "/DblClickEvent",  &CIrcProto::OnDoubleclicked );
-	CreateProtoService( "/InsertRawIn",    &CIrcProto::Scripting_InsertRawIn );
-	CreateProtoService( "/InsertRawOut",   &CIrcProto::Scripting_InsertRawOut );
-	CreateProtoService( "/InsertGuiIn",    &CIrcProto::Scripting_InsertGuiIn );
-	CreateProtoService( "/InsertGuiOut",   &CIrcProto::Scripting_InsertGuiOut);
-	CreateProtoService( "/GetIrcData",     &CIrcProto::Scripting_GetIrcData);
+	m_evWndCreate = ::CreateEvent(NULL, FALSE, FALSE, NULL);
+
+	CreateProtoService(PS_GETMYAWAYMSG, &CIrcProto::GetMyAwayMsg);
+
+	CreateProtoService(PS_CREATEACCMGRUI, &CIrcProto::SvcCreateAccMgrUI);
+	CreateProtoService(PS_JOINCHAT, &CIrcProto::OnJoinChat);
+	CreateProtoService(PS_LEAVECHAT, &CIrcProto::OnLeaveChat);
+
+	CreateProtoService(IRC_JOINCHANNEL, &CIrcProto::OnJoinMenuCommand);
+	CreateProtoService(IRC_QUICKCONNECT, &CIrcProto::OnQuickConnectMenuCommand);
+	CreateProtoService(IRC_CHANGENICK, &CIrcProto::OnChangeNickMenuCommand);
+	CreateProtoService(IRC_SHOWLIST, &CIrcProto::OnShowListMenuCommand);
+	CreateProtoService(IRC_SHOWSERVER, &CIrcProto::OnShowServerMenuCommand);
+	CreateProtoService(IRC_UM_CHANSETTINGS, &CIrcProto::OnMenuChanSettings);
+	CreateProtoService(IRC_UM_WHOIS, &CIrcProto::OnMenuWhois);
+	CreateProtoService(IRC_UM_DISCONNECT, &CIrcProto::OnMenuDisconnect);
+	CreateProtoService(IRC_UM_IGNORE, &CIrcProto::OnMenuIgnore);
+
+	CreateProtoService("/DblClickEvent", &CIrcProto::OnDoubleclicked);
+	CreateProtoService("/InsertRawIn", &CIrcProto::Scripting_InsertRawIn);
+	CreateProtoService("/InsertRawOut", &CIrcProto::Scripting_InsertRawOut);
+	CreateProtoService("/InsertGuiIn", &CIrcProto::Scripting_InsertGuiIn);
+	CreateProtoService("/InsertGuiOut", &CIrcProto::Scripting_InsertGuiOut);
+	CreateProtoService("/GetIrcData", &CIrcProto::Scripting_GetIrcData);
 
 	codepage = CP_ACP;
 	InitializeCriticalSection(&m_resolve);
@@ -144,23 +144,23 @@ CIrcProto::CIrcProto(const char* szModuleName, const TCHAR* tszUserName) :
 
 CIrcProto::~CIrcProto()
 {
-	if ( con ) {
-		Netlib_CloseHandle( con );
+	if (con) {
+		Netlib_CloseHandle(con);
 		con = NULL;
 	}
 
 	Netlib_CloseHandle(m_hNetlibUser); m_hNetlibUser = NULL;
 	Netlib_CloseHandle(hNetlibDCC); hNetlibDCC = NULL;
 
-	DeleteCriticalSection( &cs );
-	DeleteCriticalSection( &m_gchook );
+	DeleteCriticalSection(&cs);
+	DeleteCriticalSection(&m_gchook);
 
 	if (hMenuRoot)
 		CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)hMenuRoot, 0);
 
-	mir_free( m_alias );
+	mir_free(m_alias);
 
-	CloseHandle( m_evWndCreate );
+	CloseHandle(m_evWndCreate);
 	DeleteCriticalSection(&m_resolve);
 	DeleteCriticalSection(&m_dcc);
 	KillChatTimer(OnlineNotifTimer);
@@ -172,47 +172,47 @@ CIrcProto::~CIrcProto()
 
 static COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
 
-static int sttCheckPerform( const char *szSetting, LPARAM lParam )
+static int sttCheckPerform(const char *szSetting, LPARAM lParam)
 {
-	if ( !_strnicmp( szSetting, "PERFORM:", 8 )) {
+	if (!_strnicmp(szSetting, "PERFORM:", 8)) {
 		String s = szSetting;
 		s.MakeUpper();
-		if ( s != szSetting ) {
-			OBJLIST<String>* p = ( OBJLIST<String>* )lParam;
-			p->insert( new String( szSetting ));
+		if (s != szSetting) {
+			OBJLIST<String>* p = (OBJLIST<String>*)lParam;
+			p->insert(new String(szSetting));
 		}
 	}
 	return 0;
 }
 
-int CIrcProto::OnModulesLoaded( WPARAM, LPARAM )
+int CIrcProto::OnModulesLoaded(WPARAM, LPARAM)
 {
-	NETLIBUSER nlu = {0};
+	NETLIBUSER nlu = { 0 };
 	TCHAR name[128];
 
-	db_unset( NULL, m_szModuleName, "JTemp" );
+	db_unset(NULL, m_szModuleName, "JTemp");
 
 	nlu.cbSize = sizeof(nlu);
-	nlu.flags = NUF_OUTGOING|NUF_INCOMING|NUF_HTTPCONNS|NUF_TCHAR;
+	nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR;
 	nlu.szSettingsModule = m_szModuleName;
-	mir_sntprintf( name, SIZEOF(name), TranslateT("%s server connection"), m_tszUserName);
+	mir_sntprintf(name, SIZEOF(name), TranslateT("%s server connection"), m_tszUserName);
 	nlu.ptszDescriptiveName = name;
 	m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
 
-	nlu.flags = NUF_OUTGOING|NUF_INCOMING|NUF_HTTPCONNS|NUF_TCHAR;
+	nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR;
 	char szTemp2[256];
 	mir_snprintf(szTemp2, sizeof(szTemp2), "%s DCC", m_szModuleName);
 	nlu.szSettingsModule = szTemp2;
-	mir_sntprintf( name, SIZEOF(name), TranslateT("%s client-to-client connections"), m_tszUserName);
+	mir_sntprintf(name, SIZEOF(name), TranslateT("%s client-to-client connections"), m_tszUserName);
 	nlu.ptszDescriptiveName = name;
 	hNetlibDCC = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
 
-	if ( ServiceExists("MBot/GetFcnTable")) {
+	if (ServiceExists("MBot/GetFcnTable")) {
 		CallService(MS_MBOT_REGISTERIRC, 0, (LPARAM)m_szModuleName);
 		m_bMbotInstalled = TRUE;
 	}
 
-	if ( ServiceExists( MS_GC_REGISTER )) {
+	if (ServiceExists(MS_GC_REGISTER)) {
 		GCREGISTER gcr = { sizeof(GCREGISTER) };
 		gcr.dwFlags = GC_CHANMGR | GC_BOLD | GC_ITALICS | GC_UNDERLINE | GC_COLOR | GC_BKGCOLOR;
 		gcr.nColors = 16;
@@ -228,49 +228,49 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM )
 		gcw.iType = GCW_SERVER;
 		gcw.ptszID = SERVERWINDOW;
 		gcw.pszModule = m_szModuleName;
-		gcw.ptszName = NEWTSTR_ALLOCA(( TCHAR* )_A2T( m_network ));
+		gcw.ptszName = NEWTSTR_ALLOCA((TCHAR*)_A2T(m_network));
 		CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
 
 		GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
 		GCEVENT gce = { sizeof(gce), &gcd };
-		if ( m_useServer && !m_hideServerWindow )
+		if (m_useServer && !m_hideServerWindow)
 			CallChatEvent(WINDOW_VISIBLE, (LPARAM)&gce);
 		else
 			CallChatEvent(WINDOW_HIDDEN, (LPARAM)&gce);
 		bChatInstalled = TRUE;
 	}
 	else {
-		if ( IDYES == MessageBox(0,TranslateT("The IRC protocol depends on another plugin called \'Chat\'\n\nDo you want to download it from the Miranda NG web site now?"),TranslateT("Information"),MB_YESNO|MB_ICONINFORMATION ))
+		if (IDYES == MessageBox(0, TranslateT("The IRC protocol depends on another plugin called \'Chat\'\n\nDo you want to download it from the Miranda NG web site now?"), TranslateT("Information"), MB_YESNO | MB_ICONINFORMATION))
 			CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://miranda-ng.org/");
 	}
 
 	TCHAR szTemp[MAX_PATH];
 	mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%miranda_path%%\\Plugins\\%S_perform.ini"), m_szModuleName);
-	TCHAR *szLoadFileName = Utils_ReplaceVarsT( szTemp );
-	char* pszPerformData = IrcLoadFile( szLoadFileName );
-	if ( pszPerformData != NULL ) {
+	TCHAR *szLoadFileName = Utils_ReplaceVarsT(szTemp);
+	char* pszPerformData = IrcLoadFile(szLoadFileName);
+	if (pszPerformData != NULL) {
 		char *p1 = pszPerformData, *p2 = pszPerformData;
-		while (( p1 = strstr( p2, "NETWORK: " )) != NULL ) {
+		while ((p1 = strstr(p2, "NETWORK: ")) != NULL) {
 			p1 += 9;
 			p2 = strchr(p1, '\n');
-			String sNetwork( p1, int( p2-p1-1 ));
+			String sNetwork(p1, int(p2 - p1 - 1));
 			sNetwork.MakeUpper();
 			p1 = p2;
-			p2 = strstr( ++p1, "\nNETWORK: " );
-			if ( !p2 )
-				p2 = p1 + lstrlenA( p1 )-1;
-			if ( p1 == p2 )
+			p2 = strstr(++p1, "\nNETWORK: ");
+			if (!p2)
+				p2 = p1 + lstrlenA(p1) - 1;
+			if (p1 == p2)
 				break;
 
 			*p2++ = 0;
-			setString(("PERFORM:" + sNetwork).c_str(), rtrim( p1 ));
+			setString(("PERFORM:" + sNetwork).c_str(), rtrim(p1));
 		}
 		delete[] pszPerformData;
-		::_tremove( szLoadFileName );
+		::_tremove(szLoadFileName);
 	}
-	mir_free( szLoadFileName );
+	mir_free(szLoadFileName);
 
-	if ( !getByte( "PerformConversionDone", 0 )) {
+	if (!getByte("PerformConversionDone", 0)) {
 		OBJLIST<String> performToConvert(10);
 		DBCONTACTENUMSETTINGS dbces = { 0 };
 		dbces.pfnEnumProc = sttCheckPerform;
@@ -281,34 +281,36 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM )
 		for (int i = 0; i < performToConvert.getCount(); i++) {
 			String s = performToConvert[i];
 			DBVARIANT dbv;
-			if ( !getTString( s, &dbv )) {
-				db_unset( NULL, m_szModuleName, s );
+			if (!getTString(s, &dbv)) {
+				db_unset(NULL, m_szModuleName, s);
 				s.MakeUpper();
-				setTString( s, dbv.ptszVal );
-				db_free( &dbv );
-		}	}
+				setTString(s, dbv.ptszVal);
+				db_free(&dbv);
+			}
+		}
 
-		setByte( "PerformConversionDone", 1 );
+		setByte("PerformConversionDone", 1);
 	}
 
 	InitIgnore();
 
-	HookProtoEvent( ME_USERINFO_INITIALISE, &CIrcProto::OnInitUserInfo );
-	HookProtoEvent( ME_OPT_INITIALISE, &CIrcProto::OnInitOptionsPages );
+	HookProtoEvent(ME_USERINFO_INITIALISE, &CIrcProto::OnInitUserInfo);
+	HookProtoEvent(ME_OPT_INITIALISE, &CIrcProto::OnInitOptionsPages);
 
 	if (m_nick[0]) {
-		TCHAR szBuf[ 40 ];
-		if ( lstrlen( m_alternativeNick ) == 0 ) {
-			mir_sntprintf( szBuf, SIZEOF(szBuf), _T("%s%u"), m_nick, rand()%9999);
+		TCHAR szBuf[40];
+		if (lstrlen(m_alternativeNick) == 0) {
+			mir_sntprintf(szBuf, SIZEOF(szBuf), _T("%s%u"), m_nick, rand() % 9999);
 			setTString("AlernativeNick", szBuf);
 			lstrcpyn(m_alternativeNick, szBuf, 30);
 		}
 
-		if ( lstrlen( m_name ) == 0 ) {
-			mir_sntprintf( szBuf, SIZEOF(szBuf), _T("Miranda%u"), rand()%9999);
+		if (lstrlen(m_name) == 0) {
+			mir_sntprintf(szBuf, SIZEOF(szBuf), _T("Miranda%u"), rand() % 9999);
 			setTString("Name", szBuf);
-			lstrcpyn( m_name, szBuf, 200 );
-	}	}
+			lstrcpyn(m_name, szBuf, 200);
+		}
+	}
 
 	return 0;
 }
@@ -316,38 +318,38 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM )
 ////////////////////////////////////////////////////////////////////////////////////////
 // AddToList - adds a contact to the contact list
 
-HANDLE __cdecl CIrcProto::AddToList( int, PROTOSEARCHRESULT* psr )
+HANDLE __cdecl CIrcProto::AddToList(int, PROTOSEARCHRESULT* psr)
 {
-	if ( m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_CONNECTING )
+	if (m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_CONNECTING)
 		return 0;
 
 	TCHAR *id = psr->id ? psr->id : psr->nick;
 	id = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)id) : mir_a2t((char*)id);
 
 	CONTACT user = { id, NULL, NULL, true, false, false };
-	HANDLE hContact = CList_AddContact( &user, true, false );
+	HANDLE hContact = CList_AddContact(&user, true, false);
 
-	if ( hContact ) {
+	if (hContact) {
 		DBVARIANT dbv1;
 		CMString S = _T("S");
 
-		if ( getByte( hContact, "AdvancedMode", 0 ) == 0 ) {
+		if (getByte(hContact, "AdvancedMode", 0) == 0) {
 			S += user.name;
-			DoUserhostWithReason( 1, S, true, user.name );
+			DoUserhostWithReason(1, S, true, user.name);
 		}
 		else {
-			if ( !getTString(hContact, "UWildcard", &dbv1 )) {
+			if (!getTString(hContact, "UWildcard", &dbv1)) {
 				S += dbv1.ptszVal;
 				DoUserhostWithReason(2, S, true, dbv1.ptszVal);
-				db_free( &dbv1 );
+				db_free(&dbv1);
 			}
 			else {
 				S += user.name;
-				DoUserhostWithReason( 2, S, true, user.name );
+				DoUserhostWithReason(2, S, true, user.name);
 			}
 		}
-		if (getByte( "MirVerAutoRequest", 1))
-			PostIrcMessage( _T("/PRIVMSG %s \001VERSION\001"), user.name);
+		if (getByte("MirVerAutoRequest", 1))
+			PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), user.name);
 	}
 
 	mir_free(id);
@@ -357,7 +359,7 @@ HANDLE __cdecl CIrcProto::AddToList( int, PROTOSEARCHRESULT* psr )
 ////////////////////////////////////////////////////////////////////////////////////////
 // AddToList - adds a contact to the contact list
 
-HANDLE __cdecl CIrcProto::AddToListByEvent( int, int, HANDLE )
+HANDLE __cdecl CIrcProto::AddToListByEvent(int, int, HANDLE)
 {
 	return NULL;
 }
@@ -365,7 +367,7 @@ HANDLE __cdecl CIrcProto::AddToListByEvent( int, int, HANDLE )
 ////////////////////////////////////////////////////////////////////////////////////////
 // AuthAllow - processes the successful authorization
 
-int __cdecl CIrcProto::Authorize( HANDLE )
+int __cdecl CIrcProto::Authorize(HANDLE)
 {
 	return 0;
 }
@@ -373,7 +375,7 @@ int __cdecl CIrcProto::Authorize( HANDLE )
 ////////////////////////////////////////////////////////////////////////////////////////
 // AuthDeny - handles the unsuccessful authorization
 
-int __cdecl CIrcProto::AuthDeny( HANDLE, const TCHAR* )
+int __cdecl CIrcProto::AuthDeny(HANDLE, const TCHAR*)
 {
 	return 0;
 }
@@ -381,7 +383,7 @@ int __cdecl CIrcProto::AuthDeny( HANDLE, const TCHAR* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // PSR_AUTH
 
-int __cdecl CIrcProto::AuthRecv( HANDLE, PROTORECVEVENT* )
+int __cdecl CIrcProto::AuthRecv(HANDLE, PROTORECVEVENT*)
 {
 	return 1;
 }
@@ -389,7 +391,7 @@ int __cdecl CIrcProto::AuthRecv( HANDLE, PROTORECVEVENT* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // PSS_AUTHREQUEST
 
-int __cdecl CIrcProto::AuthRequest( HANDLE, const TCHAR* )
+int __cdecl CIrcProto::AuthRequest(HANDLE, const TCHAR*)
 {
 	return 1;
 }
@@ -397,7 +399,7 @@ int __cdecl CIrcProto::AuthRequest( HANDLE, const TCHAR* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // ChangeInfo
 
-HANDLE __cdecl CIrcProto::ChangeInfo( int, void* )
+HANDLE __cdecl CIrcProto::ChangeInfo(int, void*)
 {
 	return NULL;
 }
@@ -405,11 +407,11 @@ HANDLE __cdecl CIrcProto::ChangeInfo( int, void* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // FileAllow - starts a file transfer
 
-HANDLE __cdecl CIrcProto::FileAllow( HANDLE, HANDLE hTransfer, const TCHAR* szPath )
+HANDLE __cdecl CIrcProto::FileAllow(HANDLE, HANDLE hTransfer, const TCHAR* szPath)
 {
-	DCCINFO* di = ( DCCINFO* )hTransfer;
+	DCCINFO* di = (DCCINFO*)hTransfer;
 
-	if ( !IsConnected()) {
+	if (!IsConnected()) {
 		delete di;
 		return (HANDLE)szPath;
 	}
@@ -417,8 +419,8 @@ HANDLE __cdecl CIrcProto::FileAllow( HANDLE, HANDLE hTransfer, const TCHAR* szPa
 	di->sPath = szPath;
 	di->sFileAndPath = di->sPath + di->sFile;
 
-	CDccSession* dcc = new CDccSession( this, di );
-	AddDCCSession( di, dcc );
+	CDccSession* dcc = new CDccSession(this, di);
+	AddDCCSession(di, dcc);
 	dcc->Connect();
 	return di;
 }
@@ -426,9 +428,9 @@ HANDLE __cdecl CIrcProto::FileAllow( HANDLE, HANDLE hTransfer, const TCHAR* szPa
 ////////////////////////////////////////////////////////////////////////////////////////
 // FileCancel - cancels a file transfer
 
-int __cdecl CIrcProto::FileCancel( HANDLE, HANDLE hTransfer )
+int __cdecl CIrcProto::FileCancel(HANDLE, HANDLE hTransfer)
 {
-	DCCINFO* di = ( DCCINFO* )hTransfer;
+	DCCINFO* di = (DCCINFO*)hTransfer;
 
 	CDccSession* dcc = FindDCCSession(di);
 	if (dcc) {
@@ -442,9 +444,9 @@ int __cdecl CIrcProto::FileCancel( HANDLE, HANDLE hTransfer )
 ////////////////////////////////////////////////////////////////////////////////////////
 // FileDeny - denies a file transfer
 
-int __cdecl CIrcProto::FileDeny( HANDLE, HANDLE hTransfer, const TCHAR* )
+int __cdecl CIrcProto::FileDeny(HANDLE, HANDLE hTransfer, const TCHAR*)
 {
-	DCCINFO* di = ( DCCINFO* )hTransfer;
+	DCCINFO* di = (DCCINFO*)hTransfer;
 	delete di;
 	return 0;
 }
@@ -452,9 +454,9 @@ int __cdecl CIrcProto::FileDeny( HANDLE, HANDLE hTransfer, const TCHAR* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // FileResume - processes file renaming etc
 
-int __cdecl CIrcProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename )
+int __cdecl CIrcProto::FileResume(HANDLE hTransfer, int* action, const TCHAR** szFilename)
 {
-	DCCINFO* di = ( DCCINFO* )hTransfer;
+	DCCINFO* di = (DCCINFO*)hTransfer;
 
 	long i = (long)*action;
 
@@ -476,15 +478,15 @@ int __cdecl CIrcProto::FileResume( HANDLE hTransfer, int* action, const TCHAR**
 			CMString sFileWithQuotes = di->sFile;
 
 			// if spaces in the filename surround witrh quotes
-			if (sFileWithQuotes.Find( ' ', 0 ) != -1 ) {
-				sFileWithQuotes.Insert( 0, _T("\""));
-				sFileWithQuotes.Insert( sFileWithQuotes.GetLength(), _T("\""));
+			if (sFileWithQuotes.Find(' ', 0) != -1) {
+				sFileWithQuotes.Insert(0, _T("\""));
+				sFileWithQuotes.Insert(sFileWithQuotes.GetLength(), _T("\""));
 			}
 
 			if (di->bReverse)
-				PostIrcMessage( _T("/PRIVMSG %s \001DCC RESUME %s 0 %I64u %s\001"), di->sContactName.c_str(), sFileWithQuotes.c_str(), dwPos, dcc->di->sToken.c_str());
+				PostIrcMessage(_T("/PRIVMSG %s \001DCC RESUME %s 0 %I64u %s\001"), di->sContactName.c_str(), sFileWithQuotes.c_str(), dwPos, dcc->di->sToken.c_str());
 			else
-				PostIrcMessage( _T("/PRIVMSG %s \001DCC RESUME %s %u %I64u\001"), di->sContactName.c_str(), sFileWithQuotes.c_str(), di->iPort, dwPos);
+				PostIrcMessage(_T("/PRIVMSG %s \001DCC RESUME %s %u %I64u\001"), di->sContactName.c_str(), sFileWithQuotes.c_str(), di->iPort, dwPos);
 
 			return 0;
 		}
@@ -498,9 +500,9 @@ int __cdecl CIrcProto::FileResume( HANDLE hTransfer, int* action, const TCHAR**
 ////////////////////////////////////////////////////////////////////////////////////////
 // GetCaps - return protocol capabilities bits
 
-DWORD_PTR __cdecl CIrcProto::GetCaps( int type, HANDLE )
+DWORD_PTR __cdecl CIrcProto::GetCaps(int type, HANDLE)
 {
-	switch( type ) {
+	switch (type) {
 	case PFLAGNUM_1:
 		return PF1_BASICSEARCH | PF1_MODEMSG | PF1_FILE | PF1_CHAT | PF1_CANRENAMEFILE | PF1_PEER2PEER | PF1_IM;
 
@@ -514,7 +516,7 @@ DWORD_PTR __cdecl CIrcProto::GetCaps( int type, HANDLE )
 		return PF4_NOAUTHDENYREASON | PF4_NOCUSTOMAUTH | PF4_IMSENDUTF;
 
 	case PFLAG_UNIQUEIDTEXT:
-		return (DWORD_PTR) Translate("Nickname");
+		return (DWORD_PTR)Translate("Nickname");
 
 	case PFLAG_MAXLENOFMESSAGE:
 		return 400;
@@ -529,7 +531,7 @@ DWORD_PTR __cdecl CIrcProto::GetCaps( int type, HANDLE )
 ////////////////////////////////////////////////////////////////////////////////////////
 // GetInfo - retrieves a contact info
 
-int __cdecl CIrcProto::GetInfo( HANDLE, int )
+int __cdecl CIrcProto::GetInfo(HANDLE, int)
 {
 	return 1;
 }
@@ -539,30 +541,31 @@ int __cdecl CIrcProto::GetInfo( HANDLE, int )
 
 struct AckBasicSearchParam
 {
-	PROTOCHAR buf[ 50 ];
+	PROTOCHAR buf[50];
 };
 
-void __cdecl CIrcProto::AckBasicSearch( void* param )
+void __cdecl CIrcProto::AckBasicSearch(void* param)
 {
 	PROTOSEARCHRESULT psr = { sizeof(psr) };
 	psr.flags = PSR_TCHAR;
-	psr.id = (( AckBasicSearchParam* )param )->buf;
-	psr.nick = (( AckBasicSearchParam* )param )->buf;
-	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);
-	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+	psr.id = ((AckBasicSearchParam*)param)->buf;
+	psr.nick = ((AckBasicSearchParam*)param)->buf;
+	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)& psr);
+	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
 	delete param;
 }
 
-HANDLE __cdecl CIrcProto::SearchBasic( const PROTOCHAR* szId )
+HANDLE __cdecl CIrcProto::SearchBasic(const PROTOCHAR* szId)
 {
-	if ( szId ) {
+	if (szId) {
 		if (m_iStatus != ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_CONNECTING &&
 			szId && szId[0] && !IsChannel(szId)) {
 			AckBasicSearchParam* param = new AckBasicSearchParam;
-			lstrcpyn( param->buf, szId, 50 );
-			ForkThread( &CIrcProto::AckBasicSearch, param );
-			return ( HANDLE )1;
-	}	}
+			lstrcpyn(param->buf, szId, 50);
+			ForkThread(&CIrcProto::AckBasicSearch, param);
+			return (HANDLE)1;
+		}
+	}
 
 	return 0;
 }
@@ -570,7 +573,7 @@ HANDLE __cdecl CIrcProto::SearchBasic( const PROTOCHAR* szId )
 ////////////////////////////////////////////////////////////////////////////////////////
 // SearchByEmail - searches the contact by its e-mail
 
-HANDLE __cdecl CIrcProto::SearchByEmail( const PROTOCHAR* )
+HANDLE __cdecl CIrcProto::SearchByEmail(const PROTOCHAR*)
 {
 	return NULL;
 }
@@ -578,17 +581,17 @@ HANDLE __cdecl CIrcProto::SearchByEmail( const PROTOCHAR* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // upsupported search functions
 
-HANDLE __cdecl CIrcProto::SearchByName( const PROTOCHAR*, const PROTOCHAR*, const PROTOCHAR* )
+HANDLE __cdecl CIrcProto::SearchByName(const PROTOCHAR*, const PROTOCHAR*, const PROTOCHAR*)
 {
 	return NULL;
 }
 
-HWND __cdecl CIrcProto::CreateExtendedSearchUI( HWND )
+HWND __cdecl CIrcProto::CreateExtendedSearchUI(HWND)
 {
 	return NULL;
 }
 
-HWND __cdecl CIrcProto::SearchAdvanced( HWND )
+HWND __cdecl CIrcProto::SearchAdvanced(HWND)
 {
 	return NULL;
 }
@@ -596,7 +599,7 @@ HWND __cdecl CIrcProto::SearchAdvanced( HWND )
 ////////////////////////////////////////////////////////////////////////////////////////
 // RecvContacts
 
-int __cdecl CIrcProto::RecvContacts( HANDLE, PROTORECVEVENT* )
+int __cdecl CIrcProto::RecvContacts(HANDLE, PROTORECVEVENT*)
 {
 	return 1;
 }
@@ -604,7 +607,7 @@ int __cdecl CIrcProto::RecvContacts( HANDLE, PROTORECVEVENT* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // RecvFile
 
-int __cdecl CIrcProto::RecvFile( HANDLE hContact, PROTORECVFILET* evt )
+int __cdecl CIrcProto::RecvFile(HANDLE hContact, PROTORECVFILET* evt)
 {
 	return Proto_RecvFile(hContact, evt);
 }
@@ -612,7 +615,7 @@ int __cdecl CIrcProto::RecvFile( HANDLE hContact, PROTORECVFILET* evt )
 ////////////////////////////////////////////////////////////////////////////////////////
 // RecvMsg
 
-int __cdecl CIrcProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* evt )
+int __cdecl CIrcProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* evt)
 {
 	return Proto_RecvMessage(hContact, evt);
 }
@@ -620,7 +623,7 @@ int __cdecl CIrcProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* evt )
 ////////////////////////////////////////////////////////////////////////////////////////
 // RecvUrl
 
-int __cdecl CIrcProto::RecvUrl( HANDLE, PROTORECVEVENT* )
+int __cdecl CIrcProto::RecvUrl(HANDLE, PROTORECVEVENT*)
 {
 	return 1;
 }
@@ -628,7 +631,7 @@ int __cdecl CIrcProto::RecvUrl( HANDLE, PROTORECVEVENT* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // SendContacts
 
-int __cdecl CIrcProto::SendContacts( HANDLE, int, int, HANDLE* )
+int __cdecl CIrcProto::SendContacts(HANDLE, int, int, HANDLE*)
 {
 	return 1;
 }
@@ -636,15 +639,15 @@ int __cdecl CIrcProto::SendContacts( HANDLE, int, int, HANDLE* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // SendFile - sends a file
 
-HANDLE __cdecl CIrcProto::SendFile( HANDLE hContact, const TCHAR*, TCHAR** ppszFiles )
+HANDLE __cdecl CIrcProto::SendFile(HANDLE hContact, const TCHAR*, TCHAR** ppszFiles)
 {
 	DCCINFO* dci = NULL;
 	int iPort = 0;
-	int index= 0;
+	int index = 0;
 	unsigned __int64 size = 0;
 
 	// do not send to channels :-P
-	if ( isChatRoom(hContact))
+	if (isChatRoom(hContact))
 		return 0;
 
 	// stop if it is an active type filetransfer and the user's IP is not known
@@ -652,14 +655,14 @@ HANDLE __cdecl CIrcProto::SendFile( HANDLE hContact, const TCHAR*, TCHAR** ppszF
 	if (m_manualHost)
 		ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
 	else
-		ulAdr = ConvertIPToInteger(m_IPFromServer?m_myHost:m_myLocalHost);
+		ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
 
 	if (!m_DCCPassive && !ulAdr) {
 		DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), TranslateT("DCC ERROR: Unable to automatically resolve external IP"), NULL, NULL, NULL, true, false);
 		return 0;
 	}
 
-	if ( ppszFiles[index] ) {
+	if (ppszFiles[index]) {
 
 		//get file size
 		while (ppszFiles[index]) {
@@ -677,34 +680,34 @@ HANDLE __cdecl CIrcProto::SendFile( HANDLE hContact, const TCHAR*, TCHAR** ppszF
 		}
 
 		DBVARIANT dbv;
-		if ( !getTString( hContact, "Nick", &dbv )) {
+		if (!getTString(hContact, "Nick", &dbv)) {
 			// set up a basic DCCINFO struct and pass it to a DCC object
 			dci = new DCCINFO;
 			dci->sFileAndPath = ppszFiles[index];
 
-			int i = dci->sFileAndPath.ReverseFind( '\\' );
+			int i = dci->sFileAndPath.ReverseFind('\\');
 			if (i != -1) {
-				dci->sPath = dci->sFileAndPath.Mid(0, i+1);
-				dci->sFile = dci->sFileAndPath.Mid(i+1, dci->sFileAndPath.GetLength());
+				dci->sPath = dci->sFileAndPath.Mid(0, i + 1);
+				dci->sFile = dci->sFileAndPath.Mid(i + 1, dci->sFileAndPath.GetLength());
 			}
 
 			CMString sFileWithQuotes = dci->sFile;
 
 			// if spaces in the filename surround witrh quotes
-			if ( sFileWithQuotes.Find( ' ', 0 ) != -1) {
-				sFileWithQuotes.Insert( 0, _T("\""));
-				sFileWithQuotes.Insert( sFileWithQuotes.GetLength(), _T("\""));
+			if (sFileWithQuotes.Find(' ', 0) != -1) {
+				sFileWithQuotes.Insert(0, _T("\""));
+				sFileWithQuotes.Insert(sFileWithQuotes.GetLength(), _T("\""));
 			}
 
 			dci->hContact = hContact;
 			dci->sContactName = dbv.ptszVal;
 			dci->iType = DCC_SEND;
-			dci->bReverse = m_DCCPassive?true:false;
+			dci->bReverse = m_DCCPassive ? true : false;
 			dci->bSender = true;
 			dci->dwSize = size;
 
 			// create new dcc object
-			CDccSession* dcc = new CDccSession(this,dci);
+			CDccSession* dcc = new CDccSession(this, dci);
 
 			// keep track of all objects created
 			AddDCCSession(dci, dcc);
@@ -716,7 +719,7 @@ HANDLE __cdecl CIrcProto::SendFile( HANDLE hContact, const TCHAR*, TCHAR** ppszF
 			// is it an reverse filetransfer (receiver acts as server)
 			if (dci->bReverse) {
 				TCHAR szTemp[256];
-				PostIrcMessage( _T("/CTCP %s DCC SEND %s 200 0 %I64u %u"),
+				PostIrcMessage(_T("/CTCP %s DCC SEND %s 200 0 %I64u %u"),
 					dci->sContactName.c_str(), sFileWithQuotes.c_str(), dci->dwSize, dcc->iToken);
 
 				mir_sntprintf(szTemp, SIZEOF(szTemp),
@@ -727,15 +730,15 @@ HANDLE __cdecl CIrcProto::SendFile( HANDLE hContact, const TCHAR*, TCHAR** ppszF
 				if (m_sendNotice) {
 					mir_sntprintf(szTemp, SIZEOF(szTemp),
 						_T("/NOTICE %s I am sending the file \'\002%s\002\' (%I64u kB) to you, please accept it. [Reverse transfer]"),
-						dci->sContactName.c_str(), sFileCorrect.c_str(), dci->dwSize/1024);
+						dci->sContactName.c_str(), sFileCorrect.c_str(), dci->dwSize / 1024);
 					PostIrcMessage(szTemp);
 				}
 			}
 			else { // ... normal filetransfer.
 				iPort = dcc->Connect();
-				if ( iPort ) {
+				if (iPort) {
 					TCHAR szTemp[256];
-					PostIrcMessage( _T("/CTCP %s DCC SEND %s %u %u %I64u"),
+					PostIrcMessage(_T("/CTCP %s DCC SEND %s %u %u %I64u"),
 						dci->sContactName.c_str(), sFileWithQuotes.c_str(), ulAdr, iPort, dci->dwSize);
 
 					mir_sntprintf(szTemp, SIZEOF(szTemp),
@@ -743,10 +746,10 @@ HANDLE __cdecl CIrcProto::SendFile( HANDLE hContact, const TCHAR*, TCHAR** ppszF
 						dci->sContactName.c_str(), sFileCorrect.c_str());
 					DoEvent(GC_EVENT_INFORMATION, 0, m_info.sNick.c_str(), szTemp, NULL, NULL, NULL, true, false);
 
-					if ( m_sendNotice ) {
+					if (m_sendNotice) {
 						mir_sntprintf(szTemp, SIZEOF(szTemp),
 							_T("/NOTICE %s I am sending the file \'\002%s\002\' (%I64u kB) to you, please accept it. [IP: %s]"),
-							dci->sContactName.c_str(), sFileCorrect.c_str(), dci->dwSize/1024, (TCHAR*)_A2T(ConvertIntegerToIP(ulAdr)));
+							dci->sContactName.c_str(), sFileCorrect.c_str(), dci->dwSize / 1024, (TCHAR*)_A2T(ConvertIntegerToIP(ulAdr)));
 						PostIrcMessage(szTemp);
 					}
 				}
@@ -756,15 +759,16 @@ HANDLE __cdecl CIrcProto::SendFile( HANDLE hContact, const TCHAR*, TCHAR** ppszF
 
 			// fix for sending multiple files
 			index++;
-			while( ppszFiles[index] ) {
-				if ( _taccess(ppszFiles[index], 0) == 0 ) {
-					PostIrcMessage( _T("/DCC SEND %s %S"), dci->sContactName.c_str(), ppszFiles[index]);
+			while (ppszFiles[index]) {
+				if (_taccess(ppszFiles[index], 0) == 0) {
+					PostIrcMessage(_T("/DCC SEND %s %S"), dci->sContactName.c_str(), ppszFiles[index]);
 				}
 				index++;
 			}
 
-			db_free( &dbv );
-	}	}
+			db_free(&dbv);
+		}
+	}
 
 	if (dci)
 		return dci;
@@ -786,18 +790,18 @@ struct TFakeAckParam
 
 void __cdecl CIrcProto::AckMessageFail(void *info)
 {
-	ProtoBroadcastAck( info, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)Translate("The protocol is not online"));
+	ProtoBroadcastAck(info, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)Translate("The protocol is not online"));
 }
 
 void __cdecl CIrcProto::AckMessageFailDcc(void *info)
 {
-	ProtoBroadcastAck( info, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)Translate("The dcc chat connection is not active"));
+	ProtoBroadcastAck(info, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)Translate("The dcc chat connection is not active"));
 }
 
 void __cdecl CIrcProto::AckMessageSuccess(void *info)
 {
 	TFakeAckParam *param = (TFakeAckParam*)info;
-	ProtoBroadcastAck( param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)param->msgid, 0);
+	ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)param->msgid, 0);
 	delete param;
 }
 
@@ -817,19 +821,19 @@ int __cdecl CIrcProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
 	int codepage = getCodepage();
 
 	TCHAR *result;
-	if ( flags & PREF_UNICODE ) {
-		const char* p = strchr( pszSrc, '\0' );
-		if ( p != pszSrc ) {
-			while ( *(++p) == '\0' )
+	if (flags & PREF_UNICODE) {
+		const char* p = strchr(pszSrc, '\0');
+		if (p != pszSrc) {
+			while (*(++p) == '\0')
 				;
-			result = mir_u2t_cp((wchar_t*)p, codepage );
+			result = mir_u2t_cp((wchar_t*)p, codepage);
 		}
-		else result = mir_a2t_cp( pszSrc, codepage );
+		else result = mir_a2t_cp(pszSrc, codepage);
 	}
 	else if (flags & PREF_UTF)
 		mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &result);
 	else
-		result = mir_a2t_cp( pszSrc, codepage );
+		result = mir_a2t_cp(pszSrc, codepage);
 
 	PostIrcMessageWnd(NULL, hContact, result);
 	mir_free(result);
@@ -842,7 +846,7 @@ int __cdecl CIrcProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
 ////////////////////////////////////////////////////////////////////////////////////////
 // SendUrl
 
-int __cdecl CIrcProto::SendUrl( HANDLE, int, const char* )
+int __cdecl CIrcProto::SendUrl(HANDLE, int, const char*)
 {
 	return 1;
 }
@@ -850,7 +854,7 @@ int __cdecl CIrcProto::SendUrl( HANDLE, int, const char* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // SetApparentMode - sets the visibility status
 
-int __cdecl CIrcProto::SetApparentMode( HANDLE, int )
+int __cdecl CIrcProto::SetApparentMode(HANDLE, int)
 {
 	return 0;
 }
@@ -858,19 +862,19 @@ int __cdecl CIrcProto::SetApparentMode( HANDLE, int )
 ////////////////////////////////////////////////////////////////////////////////////////
 // SetStatus - sets the protocol status
 
-int __cdecl CIrcProto::SetStatus( int iNewStatus )
+int __cdecl CIrcProto::SetStatus(int iNewStatus)
 {
-	return SetStatusInternal( iNewStatus, false );
+	return SetStatusInternal(iNewStatus, false);
 }
 
-int CIrcProto::SetStatusInternal( int iNewStatus, bool bIsInternal )
+int CIrcProto::SetStatusInternal(int iNewStatus, bool bIsInternal)
 {
-	if ( !bChatInstalled )
+	if (!bChatInstalled)
 		return 0;
 
-	if ( iNewStatus != ID_STATUS_OFFLINE && !m_network[0] ) {
+	if (iNewStatus != ID_STATUS_OFFLINE && !m_network[0]) {
 		if (m_nick[0] && !m_disableDefaultServer) {
-			CQuickDlg* dlg = new CQuickDlg( this );
+			CQuickDlg* dlg = new CQuickDlg(this);
 			dlg->GetProto()->m_quickComboSelection = dlg->GetProto()->m_serverComboSelection + 1;
 			dlg->Show();
 			HWND hwnd = dlg->GetHwnd();
@@ -884,44 +888,44 @@ int CIrcProto::SetStatusInternal( int iNewStatus, bool bIsInternal )
 		return 0;
 	}
 
-	if ( iNewStatus != ID_STATUS_OFFLINE && !m_nick[0] || !m_userID[0] || !m_name[0]) {
+	if (iNewStatus != ID_STATUS_OFFLINE && !m_nick[0] || !m_userID[0] || !m_name[0]) {
 		MIRANDASYSTRAYNOTIFY msn;
-		msn.cbSize = sizeof( MIRANDASYSTRAYNOTIFY );
+		msn.cbSize = sizeof(MIRANDASYSTRAYNOTIFY);
 		msn.szProto = m_szModuleName;
-		msn.tszInfoTitle = TranslateT( "IRC error" );
-		msn.tszInfo = TranslateT( "Connection cannot be established! You have not completed all necessary fields (Nickname, User ID and m_name)." );
+		msn.tszInfoTitle = TranslateT("IRC error");
+		msn.tszInfo = TranslateT("Connection cannot be established! You have not completed all necessary fields (Nickname, User ID and m_name).");
 		msn.dwInfoFlags = NIIF_ERROR | NIIF_INTERN_UNICODE;
 		msn.uTimeout = 15000;
 		CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&msn);
 		return 0;
 	}
 
-	if ( !bIsInternal )
+	if (!bIsInternal)
 		m_iDesiredStatus = iNewStatus;
 
-	if (( iNewStatus == ID_STATUS_ONLINE || iNewStatus == ID_STATUS_AWAY || iNewStatus == ID_STATUS_FREECHAT) && !IsConnected()) //go from offline to online
+	if ((iNewStatus == ID_STATUS_ONLINE || iNewStatus == ID_STATUS_AWAY || iNewStatus == ID_STATUS_FREECHAT) && !IsConnected()) //go from offline to online
 	{
 		if (!m_bConnectThreadRunning)
 			ConnectToServer();
 	}
-	else if (( iNewStatus == ID_STATUS_ONLINE || iNewStatus == ID_STATUS_FREECHAT) && IsConnected() && m_iStatus == ID_STATUS_AWAY) //go to online while connected
+	else if ((iNewStatus == ID_STATUS_ONLINE || iNewStatus == ID_STATUS_FREECHAT) && IsConnected() && m_iStatus == ID_STATUS_AWAY) //go to online while connected
 	{
 		m_statusMessage = _T("");
-		PostIrcMessage( _T("/AWAY"));
+		PostIrcMessage(_T("/AWAY"));
 		return 0;
 	}
-	else if ( iNewStatus == ID_STATUS_OFFLINE && IsConnected()) //go from online/away to offline
+	else if (iNewStatus == ID_STATUS_OFFLINE && IsConnected()) //go from online/away to offline
 		DisconnectFromServer();
-	else if ( iNewStatus == ID_STATUS_OFFLINE && !IsConnected()) //offline to offline
+	else if (iNewStatus == ID_STATUS_OFFLINE && !IsConnected()) //offline to offline
 	{
 		return 0;
 	}
-	else if ( iNewStatus == ID_STATUS_AWAY && IsConnected()) //go to away while connected
+	else if (iNewStatus == ID_STATUS_AWAY && IsConnected()) //go to away while connected
 	{
-		PostIrcMessage( _T("/AWAY %s"), m_statusMessage.Mid(0,450).c_str());
+		PostIrcMessage(_T("/AWAY %s"), m_statusMessage.Mid(0, 450).c_str());
 		return 0;
 	}
-	else if ( iNewStatus == ID_STATUS_ONLINE && IsConnected()) //already online
+	else if (iNewStatus == ID_STATUS_ONLINE && IsConnected()) //already online
 		return 0;
 	else
 		SetStatusInternal(ID_STATUS_AWAY, true);
@@ -932,25 +936,26 @@ int CIrcProto::SetStatusInternal( int iNewStatus, bool bIsInternal )
 ////////////////////////////////////////////////////////////////////////////////////////
 // GetAwayMsg - returns a contact's away message
 
-HANDLE __cdecl CIrcProto::GetAwayMsg( HANDLE hContact )
+HANDLE __cdecl CIrcProto::GetAwayMsg(HANDLE hContact)
 {
 	WhoisAwayReply = _T("");
 	DBVARIANT dbv;
 
 	// bypass chat contacts.
-	if ( !isChatRoom(hContact)) {
-		if ( hContact && !getTString( hContact, "Nick", &dbv)) {
-			int i = getWord( hContact, "Status", ID_STATUS_OFFLINE );
-			if ( i != ID_STATUS_AWAY) {
-				db_free( &dbv);
+	if (!isChatRoom(hContact)) {
+		if (hContact && !getTString(hContact, "Nick", &dbv)) {
+			int i = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+			if (i != ID_STATUS_AWAY) {
+				db_free(&dbv);
 				return 0;
 			}
 			CMString S = _T("WHOIS ");
 			S += dbv.ptszVal;
 			if (IsConnected())
-				SendIrcMessage( S.c_str(), false);
-			db_free( &dbv);
-	}	}
+				SendIrcMessage(S.c_str(), false);
+			db_free(&dbv);
+		}
+	}
 
 	return (HANDLE)1;
 }
@@ -958,7 +963,7 @@ HANDLE __cdecl CIrcProto::GetAwayMsg( HANDLE hContact )
 ////////////////////////////////////////////////////////////////////////////////////////
 // PSR_AWAYMSG
 
-int __cdecl CIrcProto::RecvAwayMsg( HANDLE, int, PROTORECVEVENT* )
+int __cdecl CIrcProto::RecvAwayMsg(HANDLE, int, PROTORECVEVENT*)
 {
 	return 1;
 }
@@ -966,25 +971,26 @@ int __cdecl CIrcProto::RecvAwayMsg( HANDLE, int, PROTORECVEVENT* )
 ////////////////////////////////////////////////////////////////////////////////////////
 // SetAwayMsg - sets the away status message
 
-int __cdecl CIrcProto::SetAwayMsg( int status, const TCHAR* msg )
+int __cdecl CIrcProto::SetAwayMsg(int status, const TCHAR* msg)
 {
-	switch( status ) {
+	switch (status) {
 	case ID_STATUS_ONLINE:     case ID_STATUS_INVISIBLE:   case ID_STATUS_FREECHAT:
 	case ID_STATUS_CONNECTING: case ID_STATUS_OFFLINE:
 		break;
 
 	default:
 		CMString newStatus = msg;
-		ReplaceString( newStatus, _T("\r\n"), _T(" "));
-		if ( m_statusMessage.IsEmpty() || msg == NULL || m_statusMessage != newStatus ) {
-			if ( msg == NULL || *msg == 0 )
+		ReplaceString(newStatus, _T("\r\n"), _T(" "));
+		if (m_statusMessage.IsEmpty() || msg == NULL || m_statusMessage != newStatus) {
+			if (msg == NULL || *msg == 0)
 				m_statusMessage = _T(STR_AWAYMESSAGE);
 			else
 				m_statusMessage = newStatus;
 
-			if ( m_iStatus == ID_STATUS_AWAY )
-				PostIrcMessage( _T("/AWAY %s"), m_statusMessage.Mid(0,450).c_str());
-	}	}
+			if (m_iStatus == ID_STATUS_AWAY)
+				PostIrcMessage(_T("/AWAY %s"), m_statusMessage.Mid(0, 450).c_str());
+		}
+	}
 
 	return 0;
 }
@@ -992,7 +998,7 @@ int __cdecl CIrcProto::SetAwayMsg( int status, const TCHAR* msg )
 /////////////////////////////////////////////////////////////////////////////////////////
 // UserIsTyping - sends a UTN notification
 
-int __cdecl CIrcProto::UserIsTyping( HANDLE, int )
+int __cdecl CIrcProto::UserIsTyping(HANDLE, int)
 {
 	return 0;
 }
@@ -1000,19 +1006,19 @@ int __cdecl CIrcProto::UserIsTyping( HANDLE, int )
 /////////////////////////////////////////////////////////////////////////////////////////
 // OnEvent - maintain protocol events
 
-int __cdecl CIrcProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam )
+int __cdecl CIrcProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
 {
-	switch( eventType ) {
-	case EV_PROTO_ONLOAD:    return OnModulesLoaded( 0, 0 );
-	case EV_PROTO_ONEXIT:    return OnPreShutdown( 0, 0 );
-	case EV_PROTO_ONOPTIONS: return OnInitOptionsPages( wParam, lParam );
+	switch (eventType) {
+	case EV_PROTO_ONLOAD:    return OnModulesLoaded(0, 0);
+	case EV_PROTO_ONEXIT:    return OnPreShutdown(0, 0);
+	case EV_PROTO_ONOPTIONS: return OnInitOptionsPages(wParam, lParam);
 
 	case EV_PROTO_ONMENU:
 		InitMainMenus();
 		break;
 
 	case EV_PROTO_ONRENAME:
-		if ( hMenuRoot ) {
+		if (hMenuRoot) {
 			CLISTMENUITEM mi = { sizeof(mi) };
 			mi.flags = CMIM_NAME | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
 			mi.ptszName = m_tszUserName;
diff --git a/protocols/IRCG/src/main.cpp b/protocols/IRCG/src/main.cpp
index dff017fdee..5dd5f1ec82 100644
--- a/protocols/IRCG/src/main.cpp
+++ b/protocols/IRCG/src/main.cpp
@@ -69,27 +69,27 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
 	return &pluginInfo;
 }
 
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
 
 /////////////////////////////////////////////////////////////////////////////////////////
 
-static CIrcProto* ircProtoInit( const char* pszProtoName, const TCHAR* tszUserName )
+static CIrcProto* ircProtoInit(const char* pszProtoName, const TCHAR* tszUserName)
 {
-	CIrcProto *ppro = new CIrcProto( pszProtoName, tszUserName );
-	g_Instances.insert( ppro );
+	CIrcProto *ppro = new CIrcProto(pszProtoName, tszUserName);
+	g_Instances.insert(ppro);
 	return ppro;
 }
 
-static int ircProtoUninit( CIrcProto *ppro )
+static int ircProtoUninit(CIrcProto *ppro)
 {
-	g_Instances.remove(( CIrcProto* )ppro);
+	g_Instances.remove((CIrcProto*)ppro);
 	delete ppro;
 	return 0;
 }
 
-extern "C" int __declspec(dllexport) Load(  )
+extern "C" int __declspec(dllexport) Load()
 {
-	mir_getLP( &pluginInfo );
+	mir_getLP(&pluginInfo);
 
 	InitIcons();
 	InitTimers();
@@ -100,8 +100,8 @@ extern "C" int __declspec(dllexport) Load(  )
 	PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
 	pd.szName = "IRC";
 	pd.type = PROTOTYPE_PROTOCOL;
-	pd.fnInit = ( pfnInitProto )ircProtoInit;
-	pd.fnUninit = ( pfnUninitProto )ircProtoUninit;
+	pd.fnInit = (pfnInitProto)ircProtoInit;
+	pd.fnUninit = (pfnUninitProto)ircProtoUninit;
 	CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
 	return 0;
 }
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp
index 07ebfe8cef..38b73b0617 100644
--- a/protocols/IRCG/src/options.cpp
+++ b/protocols/IRCG/src/options.cpp
@@ -26,88 +26,88 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 static const CIrcProto* pZero = NULL;
 
-void CIrcProto::ReadSettings( TDbSetting* sets, int count )
+void CIrcProto::ReadSettings(TDbSetting* sets, int count)
 {
-	BYTE* base = ( BYTE* )this;
+	BYTE* base = (BYTE*)this;
 
 	DBVARIANT dbv;
-	for ( int i=0; i < count; i++ ) {
+	for (int i = 0; i < count; i++) {
 		TDbSetting* p = &sets[i];
 		BYTE* ptr = base + p->offset;
-		switch( p->type ) {
+		switch (p->type) {
 		case DBVT_BYTE:
-			*( BYTE* )ptr = getByte( p->name, p->defValue );
+			*(BYTE*)ptr = getByte(p->name, p->defValue);
 			break;
 		case DBVT_WORD:
-			*( WORD* )ptr = getWord( p->name, p->defValue );
+			*(WORD*)ptr = getWord(p->name, p->defValue);
 			break;
 		case DBVT_DWORD:
-			*( DWORD* )ptr = getDword( p->name, p->defValue );
+			*(DWORD*)ptr = getDword(p->name, p->defValue);
 			break;
 		case DBVT_ASCIIZ:
-			if ( !getString( p->name, &dbv )) {
-				if ( p->size != -1 ) {
-					size_t len = min( p->size-1, strlen( dbv.pszVal ));
-					memcpy( ptr, dbv.pszVal, len );
+			if (!getString(p->name, &dbv)) {
+				if (p->size != -1) {
+					size_t len = min(p->size - 1, strlen(dbv.pszVal));
+					memcpy(ptr, dbv.pszVal, len);
 					ptr[len] = 0;
 				}
-				else *( char** )ptr = mir_strdup( dbv.pszVal );
-				db_free( &dbv );
+				else *(char**)ptr = mir_strdup(dbv.pszVal);
+				db_free(&dbv);
 			}
 			else {
-				if ( p->size != -1 )
+				if (p->size != -1)
 					*ptr = 0;
-				else 
-					*( char** )ptr = NULL;
+				else
+					*(char**)ptr = NULL;
 			}
 			break;
-			case DBVT_TCHAR:
-				if ( !getTString( p->name, &dbv )) {
-					if ( p->size != -1 ) {
-						size_t len = min( p->size-1, _tcslen( dbv.ptszVal ));
-						memcpy( ptr, dbv.pszVal, len*sizeof(TCHAR));
-						*( TCHAR* )&ptr[len*sizeof(TCHAR)] = 0;
-					}
-					else *( TCHAR** )ptr = mir_tstrdup( dbv.ptszVal );
-					db_free( &dbv );
+		case DBVT_TCHAR:
+			if (!getTString(p->name, &dbv)) {
+				if (p->size != -1) {
+					size_t len = min(p->size - 1, _tcslen(dbv.ptszVal));
+					memcpy(ptr, dbv.pszVal, len*sizeof(TCHAR));
+					*(TCHAR*)&ptr[len*sizeof(TCHAR)] = 0;
 				}
-				else {
-					if ( p->size != -1 ) {
-						if ( p->defStr == NULL )
-							*ptr = 0;
-						else 
-							lstrcpyn(( TCHAR* )ptr, p->defStr, (int)p->size );
-					}
-					else *( TCHAR** )ptr = mir_tstrdup( p->defStr );
+				else *(TCHAR**)ptr = mir_tstrdup(dbv.ptszVal);
+				db_free(&dbv);
+			}
+			else {
+				if (p->size != -1) {
+					if (p->defStr == NULL)
+						*ptr = 0;
+					else
+						lstrcpyn((TCHAR*)ptr, p->defStr, (int)p->size);
 				}
-				break;
+				else *(TCHAR**)ptr = mir_tstrdup(p->defStr);
+			}
+			break;
 }	}	}
 
 void CIrcProto::WriteSettings( TDbSetting* sets, int count )
 {
-	BYTE* base = ( BYTE* )this;
+	BYTE* base = (BYTE*)this;
 
-	for ( int i=0; i < count; i++ ) {
+	for (int i = 0; i < count; i++) {
 		TDbSetting* p = &sets[i];
 		BYTE* ptr = base + p->offset;
-		switch( p->type ) {
-			case DBVT_BYTE:   setByte( p->name, *( BYTE* )ptr );       break;
-			case DBVT_WORD:   setWord( p->name, *( WORD* )ptr );       break;
-			case DBVT_DWORD:  setDword( p->name, *( DWORD* )ptr );     break;
-
-			case DBVT_ASCIIZ:
-				if ( p->size == -1 )
-					setString( p->name, *(char**)ptr );
-				else
-					setString( p->name, (char*)ptr );
-				break;
+		switch (p->type) {
+		case DBVT_BYTE:   setByte(p->name, *(BYTE*)ptr);       break;
+		case DBVT_WORD:   setWord(p->name, *(WORD*)ptr);       break;
+		case DBVT_DWORD:  setDword(p->name, *(DWORD*)ptr);     break;
 
-			case DBVT_TCHAR:
-				if ( p->size == -1 )
-					setTString( p->name, *(TCHAR**)ptr );
-				else
-					setTString( p->name, (TCHAR*)ptr );
-				break;
+		case DBVT_ASCIIZ:
+			if (p->size == -1)
+				setString(p->name, *(char**)ptr);
+			else
+				setString(p->name, (char*)ptr);
+			break;
+
+		case DBVT_TCHAR:
+			if (p->size == -1)
+				setTString(p->name, *(TCHAR**)ptr);
+			else
+				setTString(p->name, (TCHAR*)ptr);
+			break;
 }	}	}
 
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -115,51 +115,51 @@ void CIrcProto::WriteSettings( TDbSetting* sets, int count )
 static int sttServerEnum( const char* szSetting, LPARAM )
 {
 	DBVARIANT dbv;
-	if ( db_get_s( NULL, SERVERSMODULE, szSetting, &dbv ))
+	if (db_get_s(NULL, SERVERSMODULE, szSetting, &dbv))
 		return 0;
 
 	SERVER_INFO* pData = new SERVER_INFO;
-	pData->m_name = mir_strdup( szSetting );
+	pData->m_name = mir_strdup(szSetting);
 
-	char* p1 = strchr( dbv.pszVal, ':' )+1;
+	char* p1 = strchr(dbv.pszVal, ':') + 1;
 	pData->m_iSSL = 0;
-	if ( !_strnicmp( p1, "SSL", 3 )) {
-		p1 +=3;
-		if ( *p1 == '1' )
+	if (!_strnicmp(p1, "SSL", 3)) {
+		p1 += 3;
+		if (*p1 == '1')
 			pData->m_iSSL = 1;
-		else if ( *p1 == '2' )
+		else if (*p1 == '2')
 			pData->m_iSSL = 2;
 		p1++;
 	}
 	char* p2 = strchr(p1, ':');
-	pData->m_address = ( char* )mir_alloc( p2-p1+1 );
-	lstrcpynA( pData->m_address, p1, p2-p1+1 );
+	pData->m_address = (char*)mir_alloc(p2 - p1 + 1);
+	lstrcpynA(pData->m_address, p1, p2 - p1 + 1);
 
-	p1 = p2+1;
-	while (*p2 !='G' && *p2 != '-')
+	p1 = p2 + 1;
+	while (*p2 != 'G' && *p2 != '-')
 		p2++;
 
-	char* buf = ( char* )alloca( p2-p1+1 );
-	lstrcpynA( buf, p1, p2-p1+1 );
-	pData->m_portStart = atoi( buf );
+	char* buf = (char*)alloca(p2 - p1 + 1);
+	lstrcpynA(buf, p1, p2 - p1 + 1);
+	pData->m_portStart = atoi(buf);
 
-	if ( *p2 == 'G' )
+	if (*p2 == 'G')
 		pData->m_portEnd = pData->m_portStart;
 	else {
-		p1 = p2+1;
+		p1 = p2 + 1;
 		p2 = strchr(p1, 'G');
-		buf = ( char* )alloca( p2-p1+1 );
-		lstrcpynA( buf, p1, p2-p1+1 );
-		pData->m_portEnd = atoi( buf );
+		buf = (char*)alloca(p2 - p1 + 1);
+		lstrcpynA(buf, p1, p2 - p1 + 1);
+		pData->m_portEnd = atoi(buf);
 	}
 
-   p1 = strchr(p2, ':')+1;
+	p1 = strchr(p2, ':') + 1;
 	p2 = strchr(p1, '\0');
-	pData->m_group = ( char* )mir_alloc( p2-p1+1 );
-	lstrcpynA( pData->m_group, p1, p2-p1+1 );
+	pData->m_group = (char*)mir_alloc(p2 - p1 + 1);
+	lstrcpynA(pData->m_group, p1, p2 - p1 + 1);
 
-	g_servers.insert( pData );
-	db_free( &dbv );
+	g_servers.insert(pData);
+	db_free(&dbv);
 	return 0;
 }
 
@@ -175,13 +175,14 @@ void RereadServers()
 
 /////////////////////////////////////////////////////////////////////////////////////////
 
-static void removeSpaces( TCHAR* p )
+static void removeSpaces(TCHAR* p)
 {
-	while ( *p ) {
-		if ( *p == ' ' )
-			memmove( p, p+1, sizeof(TCHAR)*lstrlen(p));
+	while (*p) {
+		if (*p == ' ')
+			memmove(p, p + 1, sizeof(TCHAR)*lstrlen(p));
 		p++;
-}	}
+	}
+}
 
 /////////////////////////////////////////////////////////////////////////////////////////
 // add icons to the skinning module
@@ -211,43 +212,42 @@ void InitIcons(void)
 	Icon_Register(hInst, "Protocols/IRC", iconList, SIZEOF(iconList), "IRC");
 }
 
-HICON LoadIconEx( int iconId, bool big )
+HICON LoadIconEx(int iconId, bool big)
 {
-	for ( int i=0; i < SIZEOF(iconList); i++ )
-		if ( iconList[i].defIconID == iconId )
+	for (int i = 0; i < SIZEOF(iconList); i++)
+		if (iconList[i].defIconID == iconId)
 			return Skin_GetIconByHandle(iconList[i].hIcolib, big);
 
 	return NULL;
 }
 
-HANDLE GetIconHandle( int iconId )
+HANDLE GetIconHandle(int iconId)
 {
-	for ( int i=0; i < SIZEOF(iconList); i++ )
-		if ( iconList[i].defIconID == iconId )
+	for (int i = 0; i < SIZEOF(iconList); i++)
+		if (iconList[i].defIconID == iconId)
 			return iconList[i].hIcolib;
 
 	return NULL;
 }
 
-void ReleaseIconEx( HICON hIcon )
+void ReleaseIconEx(HICON hIcon)
 {
 	if (hIcon)
 		Skin_ReleaseIcon(hIcon);
 }
 
-void WindowSetIcon( HWND hWnd, int iconId )
+void WindowSetIcon(HWND hWnd, int iconId)
 {
-	SendMessage(hWnd, WM_SETICON, ICON_BIG, ( LPARAM )LoadIconEx( iconId, true ));
-	SendMessage(hWnd, WM_SETICON, ICON_SMALL, ( LPARAM )LoadIconEx( iconId ));
+	SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(iconId, true));
+	SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx(iconId));
 }
 
-void WindowFreeIcon( HWND hWnd )
+void WindowFreeIcon(HWND hWnd)
 {
-	ReleaseIconEx(( HICON )SendMessage(hWnd, WM_SETICON, ICON_BIG, 0));
-	ReleaseIconEx(( HICON )SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0));
+	ReleaseIconEx((HICON)SendMessage(hWnd, WM_SETICON, ICON_BIG, 0));
+	ReleaseIconEx((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0));
 }
 
-
 /////////////////////////////////////////////////////////////////////////////////////////
 // code page handler
 
@@ -278,16 +278,16 @@ static BOOL CALLBACK sttLangAddCallback(CHAR *str)
 	UINT cp = atoi(str);
 	CPINFOEX cpinfo;
 	if (GetCPInfoEx(cp, 0, &cpinfo)) {
-		TCHAR* b = _tcschr( cpinfo.CodePageName, '(' );
-		if ( b ) {
-			TCHAR* e = _tcsrchr( cpinfo.CodePageName, ')' );
-			if ( e ) {
+		TCHAR* b = _tcschr(cpinfo.CodePageName, '(');
+		if (b) {
+			TCHAR* e = _tcsrchr(cpinfo.CodePageName, ')');
+			if (e) {
 				*e = 0;
-				sttCombo->AddString( b+1, cp );
+				sttCombo->AddString(b + 1, cp);
 			}
-			else sttCombo->AddString( cpinfo.CodePageName, cp );
+			else sttCombo->AddString(cpinfo.CodePageName, cp);
 		}
-		else sttCombo->AddString( cpinfo.CodePageName, cp );
+		else sttCombo->AddString(cpinfo.CodePageName, cp);
 	}
 
 	return TRUE;
@@ -325,23 +325,23 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
 	virtual void OnInitDialog()
 	{
 		int i = m_owner->m_serverCombo.GetCount();
-		for ( int index = 0; index < i; index++ ) {
-			SERVER_INFO* pData = ( SERVER_INFO* )m_owner->m_serverCombo.GetItemData( index );
-			if ( m_groupCombo.FindStringA( pData->m_group, -1, true ) == CB_ERR )
-				m_groupCombo.AddStringA( pData->m_group );
+		for (int index = 0; index < i; index++) {
+			SERVER_INFO* pData = (SERVER_INFO*)m_owner->m_serverCombo.GetItemData(index);
+			if (m_groupCombo.FindStringA(pData->m_group, -1, true) == CB_ERR)
+				m_groupCombo.AddStringA(pData->m_group);
 		}
 
 		if (m_action == 2) {
 			int j = m_owner->m_serverCombo.GetCurSel();
-			SERVER_INFO* pData = ( SERVER_INFO* )m_owner->m_serverCombo.GetItemData( j );
-			m_address.SetTextA( pData->m_address );
-			m_groupCombo.SetTextA( pData->m_group );
-			m_port.SetInt( pData->m_portStart );
-			m_port2.SetInt( pData->m_portEnd );
+			SERVER_INFO* pData = (SERVER_INFO*)m_owner->m_serverCombo.GetItemData(j);
+			m_address.SetTextA(pData->m_address);
+			m_groupCombo.SetTextA(pData->m_group);
+			m_port.SetInt(pData->m_portStart);
+			m_port2.SetInt(pData->m_portEnd);
 
 			char *p = strstr(pData->m_name, ": ");
 			if (p)
-				m_server.SetTextA( p+2 );
+				m_server.SetTextA(p + 2);
 
 			if (pData->m_iSSL == 0)
 				CheckDlgButton(m_hwnd, IDC_OFF, BST_CHECKED);
@@ -387,9 +387,9 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
 
 		SERVER_INFO *pData = new SERVER_INFO;
 		pData->m_iSSL = 0;
-		if(IsDlgButtonChecked( m_hwnd, IDC_ON))
+		if (IsDlgButtonChecked(m_hwnd, IDC_ON))
 			pData->m_iSSL = 2;
-		if(IsDlgButtonChecked( m_hwnd, IDC_AUTO))
+		if (IsDlgButtonChecked(m_hwnd, IDC_AUTO))
 			pData->m_iSSL = 1;
 
 		pData->m_portStart = m_port.GetInt();
@@ -399,13 +399,13 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
 		pData->m_name = m_server.GetTextA();
 
 		char temp[255];
-		mir_snprintf( temp, sizeof(temp), "%s: %s", pData->m_group, pData->m_name );
-		mir_free( pData->m_name );
-		pData->m_name = mir_strdup( temp );
+		mir_snprintf(temp, sizeof(temp), "%s: %s", pData->m_group, pData->m_name);
+		mir_free(pData->m_name);
+		pData->m_name = mir_strdup(temp);
 
-		int iItem = m_owner->m_serverCombo.AddStringA( pData->m_name, ( LPARAM )pData );
-		m_owner->m_serverCombo.SetCurSel( iItem );
-		m_owner->OnServerCombo( NULL );
+		int iItem = m_owner->m_serverCombo.AddStringA(pData->m_name, (LPARAM)pData);
+		m_owner->m_serverCombo.SetCurSel(iItem);
+		m_owner->OnServerCombo(NULL);
 
 		m_owner->m_serverlistModified = true;
 		Close();
@@ -507,7 +507,7 @@ void CConnectPrefsDlg::OnInitDialog()
 	//	Fill the servers combo box and create SERVER_INFO structures
 	for (int i = 0; i < g_servers.getCount(); i++) {
 		SERVER_INFO &si = g_servers[i];
-		m_serverCombo.AddStringA( si.m_name, LPARAM( &si ));
+		m_serverCombo.AddStringA(si.m_name, LPARAM(&si));
 	}
 
 	m_serverCombo.SetCurSel(m_proto->m_serverComboSelection);
@@ -608,7 +608,7 @@ void CConnectPrefsDlg::OnAddServer(CCtrlButton*)
 	dlg->Show();
 }
 
-void CConnectPrefsDlg::OnDeleteServer( CCtrlButton* )
+void CConnectPrefsDlg::OnDeleteServer(CCtrlButton*)
 {
 	int i = m_serverCombo.GetCurSel();
 	if (i == CB_ERR)
@@ -801,19 +801,19 @@ void CConnectPrefsDlg::OnApply()
 
 static TDbSetting CtcpSettings[] =
 {
-	{	FIELD_OFFSET(CIrcProto, m_userInfo ), "UserInfo", DBVT_TCHAR, SIZEOF(pZero->m_userInfo) },
-	{	FIELD_OFFSET(CIrcProto, m_DCCPacketSize ), "DccPacketSize", DBVT_WORD, 0, 4096 },
-	{	FIELD_OFFSET(CIrcProto, m_DCCPassive ), "DccPassive", DBVT_BYTE },
-	{	FIELD_OFFSET(CIrcProto, m_DCCMode ), "DCCMode", DBVT_BYTE },
-	{	FIELD_OFFSET(CIrcProto, m_manualHost ), "ManualHost", DBVT_BYTE },
-	{	FIELD_OFFSET(CIrcProto, m_IPFromServer ), "IPFromServer", DBVT_BYTE, 0, 1 },
-	{	FIELD_OFFSET(CIrcProto, m_disconnectDCCChats ), "DisconnectDCCChats", DBVT_BYTE },
-	{	FIELD_OFFSET(CIrcProto, m_mySpecifiedHost ), "SpecHost", DBVT_ASCIIZ, SIZEOF(pZero->m_mySpecifiedHost) },
-	{	FIELD_OFFSET(CIrcProto, m_DCCChatAccept ), "CtcpChatAccept", DBVT_BYTE, 0, 1 },
-	{	FIELD_OFFSET(CIrcProto, m_sendNotice ), "SendNotice", DBVT_BYTE, 0, 1 }
+	{ FIELD_OFFSET(CIrcProto, m_userInfo), "UserInfo", DBVT_TCHAR, SIZEOF(pZero->m_userInfo) },
+	{ FIELD_OFFSET(CIrcProto, m_DCCPacketSize), "DccPacketSize", DBVT_WORD, 0, 4096 },
+	{ FIELD_OFFSET(CIrcProto, m_DCCPassive), "DccPassive", DBVT_BYTE },
+	{ FIELD_OFFSET(CIrcProto, m_DCCMode), "DCCMode", DBVT_BYTE },
+	{ FIELD_OFFSET(CIrcProto, m_manualHost), "ManualHost", DBVT_BYTE },
+	{ FIELD_OFFSET(CIrcProto, m_IPFromServer), "IPFromServer", DBVT_BYTE, 0, 1 },
+	{ FIELD_OFFSET(CIrcProto, m_disconnectDCCChats), "DisconnectDCCChats", DBVT_BYTE },
+	{ FIELD_OFFSET(CIrcProto, m_mySpecifiedHost), "SpecHost", DBVT_ASCIIZ, SIZEOF(pZero->m_mySpecifiedHost) },
+	{ FIELD_OFFSET(CIrcProto, m_DCCChatAccept), "CtcpChatAccept", DBVT_BYTE, 0, 1 },
+	{ FIELD_OFFSET(CIrcProto, m_sendNotice), "SendNotice", DBVT_BYTE, 0, 1 }
 };
 
-CCtcpPrefsDlg::CCtcpPrefsDlg( CIrcProto* _pro ) :
+CCtcpPrefsDlg::CCtcpPrefsDlg(CIrcProto* _pro) :
 	CProtoDlgBase<CIrcProto>(_pro, IDD_PREFS_CTCP, NULL),
 	m_enableIP(this, IDC_ENABLEIP),
 	m_fromServer(this, IDC_FROMSERVER),
@@ -948,12 +948,12 @@ void CCtcpPrefsDlg::OnApply()
 
 static TDbSetting OtherSettings[] =
 {
-	{	FIELD_OFFSET(CIrcProto, m_quitMessage ), "QuitMessage", DBVT_TCHAR, SIZEOF(pZero->m_quitMessage) },
-	{	FIELD_OFFSET(CIrcProto, m_alias ), "Alias", DBVT_TCHAR, -1 },
-	{	FIELD_OFFSET(CIrcProto, m_codepage ), "Codepage", DBVT_DWORD, 0, CP_ACP },
-	{	FIELD_OFFSET(CIrcProto, m_utfAutodetect ), "UtfAutodetect", DBVT_BYTE },
-	{	FIELD_OFFSET(CIrcProto, m_perform ), "Perform", DBVT_BYTE },
-	{	FIELD_OFFSET(CIrcProto, m_scriptingEnabled ), "ScriptingEnabled", DBVT_BYTE }
+	{ FIELD_OFFSET(CIrcProto, m_quitMessage), "QuitMessage", DBVT_TCHAR, SIZEOF(pZero->m_quitMessage) },
+	{ FIELD_OFFSET(CIrcProto, m_alias), "Alias", DBVT_TCHAR, -1 },
+	{ FIELD_OFFSET(CIrcProto, m_codepage), "Codepage", DBVT_DWORD, 0, CP_ACP },
+	{ FIELD_OFFSET(CIrcProto, m_utfAutodetect), "UtfAutodetect", DBVT_BYTE },
+	{ FIELD_OFFSET(CIrcProto, m_perform), "Perform", DBVT_BYTE },
+	{ FIELD_OFFSET(CIrcProto, m_scriptingEnabled), "ScriptingEnabled", DBVT_BYTE }
 };
 
 static char* sttPerformEvents[] = {
diff --git a/protocols/IRCG/src/output.cpp b/protocols/IRCG/src/output.cpp
index 6a97f45baf..c67d884aaf 100644
--- a/protocols/IRCG/src/output.cpp
+++ b/protocols/IRCG/src/output.cpp
@@ -21,75 +21,75 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "irc.h"
 
-static CMString FormatOutput (const CIrcMessage* pmsg)
+static CMString FormatOutput(const CIrcMessage* pmsg)
 {
 	CMString sMessage;
 
-	if ( pmsg->m_bIncoming ) { // Is it an incoming message?
-		if ( pmsg->sCommand == _T("WALLOPS") && pmsg->parameters.getCount() > 0 ) {
+	if (pmsg->m_bIncoming) { // Is it an incoming message?
+		if (pmsg->sCommand == _T("WALLOPS") && pmsg->parameters.getCount() > 0) {
 			TCHAR temp[200]; *temp = '\0';
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("WallOps from %s: "), pmsg->prefix.sNick.c_str());
 			sMessage = temp;
-			for ( int i=0; i < (int)pmsg->parameters.getCount(); i++ ) {
+			for (int i = 0; i < (int)pmsg->parameters.getCount(); i++) {
 				sMessage += pmsg->parameters[i];
-				if (i != pmsg->parameters.getCount()-1)
+				if (i != pmsg->parameters.getCount() - 1)
 					sMessage += _T(" ");
 			}
 			goto THE_END;
 		}
-		
-		if ( pmsg->sCommand == _T("INVITE") && pmsg->parameters.getCount() > 1 ) {
+
+		if (pmsg->sCommand == _T("INVITE") && pmsg->parameters.getCount() > 1) {
 			TCHAR temp[256]; *temp = '\0';
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s invites you to %s"), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str());
 			sMessage = temp;
-			for ( int i=2; i < (int)pmsg->parameters.getCount(); i++ ) {
+			for (int i = 2; i < (int)pmsg->parameters.getCount(); i++) {
 				sMessage += _T(": ") + pmsg->parameters[i];
-				if ( i != pmsg->parameters.getCount()-1 )
+				if (i != pmsg->parameters.getCount() - 1)
 					sMessage += _T(" ");
 			}
 			goto THE_END;
 		}
-		
-		int index = StrToInt( pmsg->sCommand.c_str());
-		if ( index == 301 && pmsg->parameters.getCount() > 0 ) {
+
+		int index = StrToInt(pmsg->sCommand.c_str());
+		if (index == 301 && pmsg->parameters.getCount() > 0) {
 			TCHAR temp[500]; *temp = '\0';
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s is away"), pmsg->parameters[1].c_str());
 			sMessage = temp;
-			for ( int i=2; i < (int)pmsg->parameters.getCount(); i++ ) {
+			for (int i = 2; i < (int)pmsg->parameters.getCount(); i++) {
 				sMessage += _T(": ") + pmsg->parameters[i];
-				if ( i != pmsg->parameters.getCount()-1 )
+				if (i != pmsg->parameters.getCount() - 1)
 					sMessage += _T(" ");
 			}
 			goto THE_END;
 		}
-		
-		if (( index == 443 || index == 441 ) && pmsg->parameters.getCount() > 3 )
+
+		if ((index == 443 || index == 441) && pmsg->parameters.getCount() > 3)
 			return pmsg->parameters[1] + _T(" ") + pmsg->parameters[3] + _T(": ") + pmsg->parameters[2];
-		
-		if ( index == 303 ) {  // ISON command
+
+		if (index == 303) {  // ISON command
 			sMessage = TranslateT("These are online: ");
-			for ( int i=1; i < (int)pmsg->parameters.getCount(); i++ ) {
+			for (int i = 1; i < (int)pmsg->parameters.getCount(); i++) {
 				sMessage += pmsg->parameters[i];
-				if (i != pmsg->parameters.getCount()-1)
+				if (i != pmsg->parameters.getCount() - 1)
 					sMessage += _T(", ");
 			}
 			goto THE_END;
 		}
-		
-		if (( index > 400 || index < 500) && pmsg->parameters.getCount() > 2 && pmsg->sCommand[0] == '4' ) //all error messages
+
+		if ((index > 400 || index < 500) && pmsg->parameters.getCount() > 2 && pmsg->sCommand[0] == '4') //all error messages
 			return pmsg->parameters[2] + _T(": ") + pmsg->parameters[1];
 	}
-	else if ( pmsg->sCommand == _T("NOTICE") && pmsg->parameters.getCount() > 1 ) {
+	else if (pmsg->sCommand == _T("NOTICE") && pmsg->parameters.getCount() > 1) {
 		TCHAR temp[500]; *temp = '\0';
 
 		int l = pmsg->parameters[1].GetLength();
-		if ( l > 3 && pmsg->parameters[1][0] == 1 && pmsg->parameters[1][ l-1 ] == 1 ) {
+		if (l > 3 && pmsg->parameters[1][0] == 1 && pmsg->parameters[1][l - 1] == 1) {
 			// CTCP reply
 			CMString tempstr = pmsg->parameters[1];
-			tempstr.Delete(0,1);
-			tempstr.Delete(tempstr.GetLength()-1,1);
+			tempstr.Delete(0, 1);
+			tempstr.Delete(tempstr.GetLength() - 1, 1);
 			CMString type = GetWord(tempstr.c_str(), 0);
-			if ( lstrcmpi(type.c_str(), _T("ping")) == 0)
+			if (lstrcmpi(type.c_str(), _T("ping")) == 0)
 				mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP %s reply sent to %s"), type.c_str(), pmsg->parameters[0].c_str());
 			else
 				mir_sntprintf(temp, SIZEOF(temp), TranslateT("CTCP %s reply sent to %s: %s"), type.c_str(), pmsg->parameters[0].c_str(), GetWordAddress(tempstr.c_str(), 1));
@@ -98,29 +98,30 @@ static CMString FormatOutput (const CIrcMessage* pmsg)
 		else {
 			mir_sntprintf(temp, SIZEOF(temp), TranslateT("Notice to %s: "), pmsg->parameters[0].c_str());
 			sMessage = temp;
-			for ( int i=1; i < (int)pmsg->parameters.getCount(); i++ ) {
+			for (int i = 1; i < (int)pmsg->parameters.getCount(); i++) {
 				sMessage += pmsg->parameters[i];
-				if (i != pmsg->parameters.getCount()-1)
+				if (i != pmsg->parameters.getCount() - 1)
 					sMessage += _T(" ");
-		}	}
+			}
+		}
 		goto THE_END;
 	}
 
 	// Default Message handler.	
 
-	if ( pmsg->m_bIncoming ) {
-		if ( pmsg->parameters.getCount() < 2 && pmsg->parameters.getCount() > 0 )
+	if (pmsg->m_bIncoming) {
+		if (pmsg->parameters.getCount() < 2 && pmsg->parameters.getCount() > 0)
 			return pmsg->sCommand + _T(" : ") + pmsg->parameters[0];
-	
-		if ( pmsg->parameters.getCount() > 1 )
-			for ( int i=1; i < (int)pmsg->parameters.getCount(); i++ )
-				sMessage += pmsg->parameters[i] + _T(" ");
+
+		if (pmsg->parameters.getCount() > 1)
+		for (int i = 1; i < (int)pmsg->parameters.getCount(); i++)
+			sMessage += pmsg->parameters[i] + _T(" ");
 	}
 	else {
-		if ( pmsg->prefix.sNick.GetLength())
+		if (pmsg->prefix.sNick.GetLength())
 			sMessage = pmsg->prefix.sNick + _T(" ");
 		sMessage += pmsg->sCommand + _T(" ");
-		for ( int i=0; i < (int)pmsg->parameters.getCount(); i++ )
+		for (int i = 0; i < (int)pmsg->parameters.getCount(); i++)
 			sMessage += pmsg->parameters[i] + _T(" ");
 	}
 
@@ -128,30 +129,30 @@ THE_END:
 	return sMessage;
 }
 
-BOOL CIrcProto::ShowMessage (const CIrcMessage* pmsg)
+BOOL CIrcProto::ShowMessage(const CIrcMessage* pmsg)
 {
 	CMString mess = FormatOutput(pmsg);
 
-	if ( !pmsg->m_bIncoming )
-		ReplaceString( mess, _T("%%"), _T("%"));
+	if (!pmsg->m_bIncoming)
+		ReplaceString(mess, _T("%%"), _T("%"));
 
-	int iTemp = StrToInt( pmsg->sCommand.c_str());
+	int iTemp = StrToInt(pmsg->sCommand.c_str());
 
 	//To active window
-	if (( iTemp > 400 || iTemp < 500 ) && pmsg->sCommand[0] == '4' //all error messages	
+	if ((iTemp > 400 || iTemp < 500) && pmsg->sCommand[0] == '4' //all error messages	
 		|| pmsg->sCommand == _T("303")		//ISON command
 		|| pmsg->sCommand == _T("INVITE")
-		|| ( (pmsg->sCommand == _T("NOTICE")) && ( (pmsg->parameters.getCount() > 2) ? (_tcsstr(pmsg->parameters[1].c_str(), _T("\001"))==NULL) : false)) // CTCP answers should go to m_network Log window!
+		|| ((pmsg->sCommand == _T("NOTICE")) && ((pmsg->parameters.getCount() > 2) ? (_tcsstr(pmsg->parameters[1].c_str(), _T("\001")) == NULL) : false)) // CTCP answers should go to m_network Log window!
 		|| pmsg->sCommand == _T("515"))		//chanserv error
 	{
-		DoEvent(GC_EVENT_INFORMATION, NULL, pmsg->m_bIncoming?pmsg->prefix.sNick.c_str():m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming?false:true); 
+		DoEvent(GC_EVENT_INFORMATION, NULL, pmsg->m_bIncoming ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming ? false : true);
 		return TRUE;
 	}
 
-	if ( m_useServer ) {
-		DoEvent( GC_EVENT_INFORMATION, SERVERWINDOW, 
-			( pmsg->m_bIncoming ) ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(),
-			mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming ? false : true ); 
+	if (m_useServer) {
+		DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW,
+			(pmsg->m_bIncoming) ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(),
+			mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming ? false : true);
 		return true;
 	}
 	return false;
diff --git a/protocols/IRCG/src/scripting.cpp b/protocols/IRCG/src/scripting.cpp
index 5d3d13d59b..e472e2259f 100644
--- a/protocols/IRCG/src/scripting.cpp
+++ b/protocols/IRCG/src/scripting.cpp
@@ -23,12 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 INT_PTR __cdecl CIrcProto::Scripting_InsertRawIn(WPARAM, LPARAM lParam)
 {
-	char* pszRaw = ( char* ) lParam;
+	char* pszRaw = (char*)lParam;
 
-	if ( m_bMbotInstalled && m_scriptingEnabled && pszRaw && IsConnected()) {
-		TCHAR* p = mir_a2t( pszRaw );
-		InsertIncomingEvent( p );
-		mir_free( p );
+	if (m_bMbotInstalled && m_scriptingEnabled && pszRaw && IsConnected()) {
+		TCHAR* p = mir_a2t(pszRaw);
+		InsertIncomingEvent(p);
+		mir_free(p);
 		return 0;
 	}
 
@@ -37,10 +37,10 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertRawIn(WPARAM, LPARAM lParam)
  
 INT_PTR __cdecl CIrcProto::Scripting_InsertRawOut( WPARAM, LPARAM lParam )
 {
-	char* pszRaw = ( char* ) lParam;
-	if ( m_bMbotInstalled && m_scriptingEnabled && pszRaw && IsConnected()) {	
+	char* pszRaw = (char*)lParam;
+	if (m_bMbotInstalled && m_scriptingEnabled && pszRaw && IsConnected()) {
 		String S = pszRaw;
-		ReplaceString( S, "%", "%%%%");
+		ReplaceString(S, "%", "%%%%");
 		NLSendNoScript((const unsigned char *)S.c_str(), lstrlenA(S.c_str()));
 		return 0;
 	}
@@ -56,7 +56,7 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertGuiIn(WPARAM wParam,LPARAM lParam)
 //helper functions
 static void __stdcall OnHook(void * pi)
 {
-	GCHOOK* gch = ( GCHOOK* )pi;
+	GCHOOK* gch = (GCHOOK*)pi;
 	free(gch->ptszUID);
 	free(gch->ptszText);
 	free((void*)gch->pDest->ptszID);
@@ -66,51 +66,51 @@ static void __stdcall OnHook(void * pi)
 }
 
 static void __cdecl GuiOutThread(LPVOID di)
-{	
-	GCHOOK* gch = ( GCHOOK* )di;
-	CallFunctionAsync( OnHook, ( void* )gch );
+{
+	GCHOOK* gch = (GCHOOK*)di;
+	CallFunctionAsync(OnHook, (void*)gch);
 }
 
-INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut( WPARAM, LPARAM lParam )
+INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut(WPARAM, LPARAM lParam)
 {
-	GCHOOK* gch = ( GCHOOK* )lParam;
+	GCHOOK* gch = (GCHOOK*)lParam;
 
-	if ( m_bMbotInstalled && m_scriptingEnabled && gch ) {	
+	if (m_bMbotInstalled && m_scriptingEnabled && gch) {
 		GCHOOK* gchook = new GCHOOK;
 		gchook->pDest = new GCDEST;
 
 		gchook->dwData = gch->dwData;
 		gchook->pDest->iType = gch->pDest->iType;
-		if ( gch->ptszText )
-			gchook->ptszText = _tcsdup( gch->ptszText );
+		if (gch->ptszText)
+			gchook->ptszText = _tcsdup(gch->ptszText);
 		else gchook->ptszText = NULL;
 
-		if ( gch->ptszUID )
-			gchook->ptszUID = _tcsdup( gch->ptszUID );
+		if (gch->ptszUID)
+			gchook->ptszUID = _tcsdup(gch->ptszUID);
 		else
 			gchook->ptszUID = NULL;
 
-		if ( gch->pDest->ptszID ) {
-			CMString S = MakeWndID( gch->pDest->ptszID );
-			gchook->pDest->ptszID = _tcsdup( S.c_str());
+		if (gch->pDest->ptszID) {
+			CMString S = MakeWndID(gch->pDest->ptszID);
+			gchook->pDest->ptszID = _tcsdup(S.c_str());
 		}
 		else gchook->pDest->ptszID = NULL;
 
-		if ( gch->pDest->pszModule )
+		if (gch->pDest->pszModule)
 			gchook->pDest->pszModule = _strdup(gch->pDest->pszModule);
 		else gchook->pDest->pszModule = NULL;
 
-		mir_forkthread( GuiOutThread, gchook );
+		mir_forkthread(GuiOutThread, gchook);
 		return 0;
 	}
 
 	return 1;
 }
 
-BOOL CIrcProto::Scripting_TriggerMSPRawIn( char** pszRaw )
+BOOL CIrcProto::Scripting_TriggerMSPRawIn(char** pszRaw)
 {
 	int iVal = CallService(MS_MBOT_IRC_RAW_IN, (WPARAM)m_szModuleName, (LPARAM)pszRaw);
-	if ( iVal == 0 )
+	if (iVal == 0)
 		return TRUE;
 
 	return iVal > 0 ? FALSE : TRUE;
@@ -119,7 +119,7 @@ BOOL CIrcProto::Scripting_TriggerMSPRawIn( char** pszRaw )
 BOOL CIrcProto::Scripting_TriggerMSPRawOut(char ** pszRaw)
 {
 	int iVal = CallService(MS_MBOT_IRC_RAW_OUT, (WPARAM)m_szModuleName, (LPARAM)pszRaw);
-	if ( iVal == 0 )
+	if (iVal == 0)
 		return TRUE;
 
 	return iVal > 0 ? FALSE : TRUE;
@@ -127,7 +127,7 @@ BOOL CIrcProto::Scripting_TriggerMSPRawOut(char ** pszRaw)
 
 BOOL CIrcProto::Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT *gce)
 {
-	WPARAM_GUI_IN wgi = {0};
+	WPARAM_GUI_IN wgi = { 0 };
 
 	wgi.pszModule = m_szModuleName;
 	wgi.wParam = *wparam;
@@ -135,7 +135,7 @@ BOOL CIrcProto::Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT *gce)
 		gce->time = time(0);
 
 	int iVal = CallService(MS_MBOT_IRC_GUI_IN, (WPARAM)&wgi, (LPARAM)gce);
-	if ( iVal == 0 ) {
+	if (iVal == 0) {
 		*wparam = wgi.wParam;
 		return TRUE;
 	}
@@ -146,7 +146,7 @@ BOOL CIrcProto::Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT *gce)
 BOOL CIrcProto::Scripting_TriggerMSPGuiOut(GCHOOK* gch)
 {
 	int iVal = CallService(MS_MBOT_IRC_GUI_OUT, (WPARAM)m_szModuleName, (LPARAM)gch);
-	if ( iVal == 0 )
+	if (iVal == 0)
 		return TRUE;
 
 	return iVal > 0 ? FALSE : TRUE;
@@ -154,16 +154,16 @@ BOOL CIrcProto::Scripting_TriggerMSPGuiOut(GCHOOK* gch)
 
 INT_PTR __cdecl CIrcProto::Scripting_GetIrcData(WPARAM, LPARAM lparam)
 {
-	if ( m_bMbotInstalled && m_scriptingEnabled && lparam ) {
-		String sString = ( char* ) lparam, sRequest;
-		CMString sOutput, sChannel; 
+	if (m_bMbotInstalled && m_scriptingEnabled && lparam) {
+		String sString = (char*)lparam, sRequest;
+		CMString sOutput, sChannel;
 
 		int i = sString.Find("|");
-		if ( i != -1 ) {
+		if (i != -1) {
 			sRequest = sString.Mid(0, i);
-			TCHAR* p = mir_a2t(( char* )sString.Mid(i+1, sString.GetLength()).c_str());
+			TCHAR* p = mir_a2t((char*)sString.Mid(i + 1, sString.GetLength()).c_str());
 			sChannel = p;
-			mir_free( p );
+			mir_free(p);
 		}
 		else sRequest = sString;
 
@@ -182,16 +182,16 @@ INT_PTR __cdecl CIrcProto::Scripting_GetIrcData(WPARAM, LPARAM lparam)
 			sOutput = m_alternativeNick;
 
 		else if (sRequest == "myip")
-			return ( INT_PTR )mir_strdup( m_manualHost ? m_mySpecifiedHostIP : 
-										( m_IPFromServer ) ? m_myHost : m_myLocalHost);
+			return (INT_PTR)mir_strdup(m_manualHost ? m_mySpecifiedHostIP :
+			(m_IPFromServer) ? m_myHost : m_myLocalHost);
 
 		else if (sRequest == "usercount" && !sChannel.IsEmpty()) {
 			CMString S = MakeWndID(sChannel.c_str());
-			GC_INFO gci = {0};
+			GC_INFO gci = { 0 };
 			gci.Flags = BYID | COUNT;
 			gci.pszModule = m_szModuleName;
 			gci.pszID = S.c_str();
-			if ( !CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci )) {
+			if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) {
 				TCHAR szTemp[40];
 				mir_sntprintf(szTemp, 35, _T("%u"), gci.iCount);
 				sOutput = szTemp;
@@ -199,40 +199,42 @@ INT_PTR __cdecl CIrcProto::Scripting_GetIrcData(WPARAM, LPARAM lparam)
 		}
 		else if (sRequest == "userlist" && !sChannel.IsEmpty()) {
 			CMString S = MakeWndID(sChannel.c_str());
-			GC_INFO gci = {0};
-			gci.Flags = BYID|USERS;
+			GC_INFO gci = { 0 };
+			gci.Flags = BYID | USERS;
 			gci.pszModule = m_szModuleName;
 			gci.pszID = S.c_str();
-			if ( !CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci ))
-				return (INT_PTR)mir_strdup( gci.pszUsers );
+			if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci))
+				return (INT_PTR)mir_strdup(gci.pszUsers);
 		}
 		else if (sRequest == "channellist") {
 			CMString S = _T("");
-			int i = CallServiceSync( MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName);
-			if ( i >= 0 ) {
+			int i = CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName);
+			if (i >= 0) {
 				int j = 0;
 				while (j < i) {
 					GC_INFO gci = { 0 };
 					gci.Flags = BYINDEX | ID;
 					gci.pszModule = m_szModuleName;
 					gci.iItem = j;
-					if ( !CallServiceSync( MS_GC_GETINFO, 0, ( LPARAM )&gci )) {
-						if ( lstrcmpi( gci.pszID, SERVERWINDOW)) {
+					if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) {
+						if (lstrcmpi(gci.pszID, SERVERWINDOW)) {
 							CMString S1 = gci.pszID;
 							int k = S1.Find(_T(" "));
-							if ( k != -1 )
+							if (k != -1)
 								S1 = S1.Mid(0, k);
 							S += S1 + _T(" ");
-					}	}
+						}
+					}
 					j++;
-			}	}
-			
-			if ( !S.IsEmpty())
-				sOutput = ( TCHAR* )S.c_str();
+				}
+			}
+
+			if (!S.IsEmpty())
+				sOutput = (TCHAR*)S.c_str();
 		}
 		// send it to mbot
-		if ( !sOutput.IsEmpty())
-			return ( INT_PTR )mir_t2a( sOutput.c_str());
+		if (!sOutput.IsEmpty())
+			return (INT_PTR)mir_t2a(sOutput.c_str());
 	}
 	return 0;
 }
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index 42e6b10536..2fe0fd2c81 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -25,15 +25,15 @@ BOOL bChatInstalled = FALSE, m_bMbotInstalled = FALSE;
 
 void CIrcProto::InitMainMenus(void)
 {
-	char temp[ MAXMODULELABELLENGTH ];
+	char temp[MAXMODULELABELLENGTH];
 	char *d = temp + mir_snprintf(temp, SIZEOF(temp), m_szModuleName);
 
 	CLISTMENUITEM mi = { sizeof(mi) };
 	mi.pszService = temp;
 
-	if ( bChatInstalled ) {
-		HGENMENU hRoot = MO_GetProtoRootMenu( m_szModuleName );
-		if ( hRoot == NULL ) {
+	if (bChatInstalled) {
+		HGENMENU hRoot = MO_GetProtoRootMenu(m_szModuleName);
+		if (hRoot == NULL) {
 			// Root popupmenuitem
 			mi.ptszName = m_tszUserName;
 			mi.position = -1999901010;
@@ -51,7 +51,7 @@ void CIrcProto::InitMainMenus(void)
 		mi.flags = CMIF_CHILDPOPUP;
 		mi.pszName = LPGEN("&Quick connect");
 		mi.icolibItem = GetIconHandle(IDI_QUICK);
-		strcpy( d, IRC_QUICKCONNECT );
+		strcpy(d, IRC_QUICKCONNECT);
 		mi.position = 201001;
 		mi.hParentMenu = hRoot;
 		hMenuQuick = Menu_AddProtoMenuItem(&mi);
@@ -60,26 +60,26 @@ void CIrcProto::InitMainMenus(void)
 
 		mi.pszName = LPGEN("&Join channel");
 		mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_JOIN);//GetIconHandle(IDI_JOIN);
-		strcpy( d, IRC_JOINCHANNEL );
+		strcpy(d, IRC_JOINCHANNEL);
 		mi.position = 201002;
 		hMenuJoin = Menu_AddProtoMenuItem(&mi);
 
 		mi.pszName = LPGEN("&Change your nickname");
 		mi.icolibItem = GetIconHandle(IDI_RENAME);
-		strcpy( d, IRC_CHANGENICK );
+		strcpy(d, IRC_CHANGENICK);
 		mi.position = 201003;
 		hMenuNick = Menu_AddProtoMenuItem(&mi);
 
 		mi.pszName = LPGEN("Show the &list of available channels");
 		mi.icolibItem = GetIconHandle(IDI_LIST);
-		strcpy( d, IRC_SHOWLIST );
+		strcpy(d, IRC_SHOWLIST);
 		mi.position = 201004;
 		hMenuList = Menu_AddProtoMenuItem(&mi);
 
 		if (m_useServer) mi.flags &= ~CMIF_GRAYED;
 		mi.pszName = LPGEN("&Show the server window");
 		mi.icolibItem = GetIconHandle(IDI_SERVER);
-		strcpy( d, IRC_SHOWSERVER );
+		strcpy(d, IRC_SHOWSERVER);
 		mi.position = 201005;
 		hMenuServer = Menu_AddProtoMenuItem(&mi);
 	}
@@ -97,8 +97,8 @@ static CIrcProto* IrcGetInstanceByHContact(HANDLE hContact)
 		return NULL;
 
 	for (int i = 0; i < g_Instances.getCount(); i++)
-		if (!strcmp(szProto, g_Instances[i]->m_szModuleName))
-			return g_Instances[i];
+	if (!strcmp(szProto, g_Instances[i]->m_szModuleName))
+		return g_Instances[i];
 
 	return NULL;
 }
@@ -127,7 +127,7 @@ static INT_PTR IrcMenuIgnore(WPARAM wParam, LPARAM lParam)
 	return (ppro) ? ppro->OnMenuIgnore(wParam, lParam) : 0;
 }
 
-int IrcPrebuildContactMenu( WPARAM wParam, LPARAM lParam )
+int IrcPrebuildContactMenu(WPARAM wParam, LPARAM lParam)
 {
 	Menu_ShowItem(hUMenuChanSettings, false);
 	Menu_ShowItem(hUMenuWhois, false);
@@ -172,7 +172,7 @@ void InitContactMenus(void)
 	strcpy(d, IRC_UM_IGNORE);
 	mi.popupPosition = 500090002;
 	hUMenuIgnore = Menu_AddContactMenuItem(&mi);
-	hMenuIgnore = CreateServiceFunction( temp, IrcMenuIgnore );
+	hMenuIgnore = CreateServiceFunction(temp, IrcMenuIgnore);
 
 	HookEvent(ME_CLIST_PREBUILDCONTACTMENU, IrcPrebuildContactMenu);
 }
@@ -196,16 +196,16 @@ INT_PTR __cdecl CIrcProto::OnDoubleclicked(WPARAM, LPARAM lParam)
 
 	CLISTEVENT* pcle = (CLISTEVENT*)lParam;
 
-	if ( getByte((HANDLE) pcle->hContact, "DCC", 0) != 0) {
-		DCCINFO* pdci = ( DCCINFO* )pcle->lParam;
-		CMessageBoxDlg* dlg = new CMessageBoxDlg( this, pdci );
+	if (getByte((HANDLE)pcle->hContact, "DCC", 0) != 0) {
+		DCCINFO* pdci = (DCCINFO*)pcle->lParam;
+		CMessageBoxDlg* dlg = new CMessageBoxDlg(this, pdci);
 		dlg->Show();
 		HWND hWnd = dlg->GetHwnd();
 		TCHAR szTemp[500];
 		mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("%s (%s) is requesting a client-to-client chat connection."),
 			pdci->sContactName.c_str(), pdci->sHostmask.c_str());
-		SetDlgItemText( hWnd, IDC_TEXT, szTemp );
-		ShowWindow( hWnd, SW_SHOW );
+		SetDlgItemText(hWnd, IDC_TEXT, szTemp);
+		ShowWindow(hWnd, SW_SHOW);
 		return 1;
 	}
 	return 0;
@@ -213,32 +213,33 @@ INT_PTR __cdecl CIrcProto::OnDoubleclicked(WPARAM, LPARAM lParam)
 
 int __cdecl CIrcProto::OnContactDeleted(WPARAM wp, LPARAM)
 {
-	HANDLE hContact = ( HANDLE )wp;
-	if ( !hContact )
+	HANDLE hContact = (HANDLE)wp;
+	if (!hContact)
 		return 0;
 
 	DBVARIANT dbv;
-	if ( !getTString( hContact, "Nick", &dbv )) {
+	if (!getTString(hContact, "Nick", &dbv)) {
 		int type = getByte(hContact, "ChatRoom", 0);
-		if ( type != 0 ) {
+		if (type != 0) {
 			CMString S = _T("");
 			if (type == GCW_CHATROOM)
-				S = MakeWndID( dbv.ptszVal );
+				S = MakeWndID(dbv.ptszVal);
 			if (type == GCW_SERVER)
 				S = SERVERWINDOW;
 			GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
 			GCEVENT gce = { sizeof(gce), &gcd };
-			int i = CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
+			int i = CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
 			if (i && type == GCW_CHATROOM)
-				PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo);
+				PostIrcMessage(_T("/PART %s %s"), dbv.ptszVal, m_userInfo);
 		}
 		else {
-			BYTE bDCC = getByte(( HANDLE )wp, "DCC", 0) ;
-			if ( bDCC ) {
+			BYTE bDCC = getByte((HANDLE)wp, "DCC", 0);
+			if (bDCC) {
 				CDccSession* dcc = FindDCCSession((HANDLE)wp);
-				if ( dcc )
+				if (dcc)
 					dcc->Disconnect();
-		}	}
+			}
+		}
 
 		db_free(&dbv);
 	}
@@ -247,13 +248,13 @@ int __cdecl CIrcProto::OnContactDeleted(WPARAM wp, LPARAM)
 
 INT_PTR __cdecl CIrcProto::OnJoinChat(WPARAM wp, LPARAM)
 {
-	if (!wp )
+	if (!wp)
 		return 0;
 
 	DBVARIANT dbv;
-	if ( !getTString(( HANDLE )wp, "Nick", &dbv)) {
-		if ( getByte(( HANDLE )wp, "ChatRoom", 0) == GCW_CHATROOM)
-			PostIrcMessage( _T("/JOIN %s"), dbv.ptszVal);
+	if (!getTString((HANDLE)wp, "Nick", &dbv)) {
+		if (getByte((HANDLE)wp, "ChatRoom", 0) == GCW_CHATROOM)
+			PostIrcMessage(_T("/JOIN %s"), dbv.ptszVal);
 		db_free(&dbv);
 	}
 	return 0;
@@ -261,13 +262,13 @@ INT_PTR __cdecl CIrcProto::OnJoinChat(WPARAM wp, LPARAM)
 
 INT_PTR __cdecl CIrcProto::OnLeaveChat(WPARAM wp, LPARAM)
 {
-	if (!wp )
+	if (!wp)
 		return 0;
 
 	DBVARIANT dbv;
-	if ( !getTString(( HANDLE )wp, "Nick", &dbv)) {
-		if ( getByte(( HANDLE )wp, "ChatRoom", 0) == GCW_CHATROOM) {
-			PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo);
+	if (!getTString((HANDLE)wp, "Nick", &dbv)) {
+		if (getByte((HANDLE)wp, "ChatRoom", 0) == GCW_CHATROOM) {
+			PostIrcMessage(_T("/PART %s %s"), dbv.ptszVal, m_userInfo);
 
 			CMString S = MakeWndID(dbv.ptszVal);
 			GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
@@ -281,12 +282,12 @@ INT_PTR __cdecl CIrcProto::OnLeaveChat(WPARAM wp, LPARAM)
 
 INT_PTR __cdecl CIrcProto::OnMenuChanSettings(WPARAM wp, LPARAM)
 {
-	if (!wp )
+	if (!wp)
 		return 0;
 
-	HANDLE hContact = (HANDLE) wp;
+	HANDLE hContact = (HANDLE)wp;
 	DBVARIANT dbv;
-	if ( !getTString( hContact, "Nick", &dbv )) {
+	if (!getTString(hContact, "Nick", &dbv)) {
 		PostIrcMessageWnd(dbv.ptszVal, NULL, _T("/CHANNELMANAGER"));
 		db_free(&dbv);
 	}
@@ -295,13 +296,13 @@ INT_PTR __cdecl CIrcProto::OnMenuChanSettings(WPARAM wp, LPARAM)
 
 INT_PTR __cdecl CIrcProto::OnMenuWhois(WPARAM wp, LPARAM)
 {
-	if ( !wp )
+	if (!wp)
 		return 0;
 
 	DBVARIANT dbv;
 
-	if ( !getTString(( HANDLE )wp, "Nick", &dbv)) {
-		PostIrcMessage( _T("/WHOIS %s %s"), dbv.ptszVal, dbv.ptszVal);
+	if (!getTString((HANDLE)wp, "Nick", &dbv)) {
+		PostIrcMessage(_T("/WHOIS %s %s"), dbv.ptszVal, dbv.ptszVal);
 		db_free(&dbv);
 	}
 	return 0;
@@ -310,7 +311,7 @@ INT_PTR __cdecl CIrcProto::OnMenuWhois(WPARAM wp, LPARAM)
 INT_PTR __cdecl CIrcProto::OnMenuDisconnect(WPARAM wp, LPARAM)
 {
 	CDccSession* dcc = FindDCCSession((HANDLE)wp);
-	if ( dcc )
+	if (dcc)
 		dcc->Disconnect();
 	return 0;
 }
@@ -322,20 +323,20 @@ INT_PTR __cdecl CIrcProto::OnMenuIgnore(WPARAM wp, LPARAM)
 
 	HANDLE hContact = (HANDLE)wp;
 	DBVARIANT dbv;
-	if ( !getTString(hContact, "Nick", &dbv )) {
-		if ( !isChatRoom(hContact)) {
+	if (!getTString(hContact, "Nick", &dbv)) {
+		if (!isChatRoom(hContact)) {
 			char* host = NULL;
 			DBVARIANT dbv1;
-			if ( !getString(hContact, "Host", &dbv1))
+			if (!getString(hContact, "Host", &dbv1))
 				host = dbv1.pszVal;
 
-			if ( host ) {
+			if (host) {
 				String S;
 				if (m_ignoreChannelDefault)
 					S = "+qnidcm";
 				else
 					S = "+qnidc";
-				PostIrcMessage( _T("/IGNORE %%question=\"%s\",\"%s\",\"*!*@%S\" %s"),
+				PostIrcMessage(_T("/IGNORE %%question=\"%s\",\"%s\",\"*!*@%S\" %s"),
 					TranslateT("Please enter the hostmask (nick!user@host) \nNOTE! Contacts on your contact list are never ignored"),
 					TranslateT("Ignore"), host, S.c_str());
 				db_free(&dbv1);
@@ -348,39 +349,39 @@ INT_PTR __cdecl CIrcProto::OnMenuIgnore(WPARAM wp, LPARAM)
 
 INT_PTR __cdecl CIrcProto::OnJoinMenuCommand(WPARAM, LPARAM)
 {
-	if ( !m_joinDlg ) {
-		m_joinDlg = new CJoinDlg( this );
+	if (!m_joinDlg) {
+		m_joinDlg = new CJoinDlg(this);
 		m_joinDlg->Show();
 	}
 
-	SetDlgItemText( m_joinDlg->GetHwnd(), IDC_CAPTION, TranslateT("Join channel"));
-	SetWindowText( GetDlgItem( m_joinDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a channel to join"));
-	SendMessage( GetDlgItem( m_joinDlg->GetHwnd(), IDC_ENICK), EM_SETSEL, 0,MAKELPARAM(0,-1));
-	ShowWindow( m_joinDlg->GetHwnd(), SW_SHOW);
-	SetActiveWindow( m_joinDlg->GetHwnd());
+	SetDlgItemText(m_joinDlg->GetHwnd(), IDC_CAPTION, TranslateT("Join channel"));
+	SetWindowText(GetDlgItem(m_joinDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a channel to join"));
+	SendMessage(GetDlgItem(m_joinDlg->GetHwnd(), IDC_ENICK), EM_SETSEL, 0, MAKELPARAM(0, -1));
+	ShowWindow(m_joinDlg->GetHwnd(), SW_SHOW);
+	SetActiveWindow(m_joinDlg->GetHwnd());
 	return 0;
 }
 
 INT_PTR __cdecl CIrcProto::OnQuickConnectMenuCommand(WPARAM, LPARAM)
 {
-	if ( !m_quickDlg ) {
-		m_quickDlg = new CQuickDlg( this );
+	if (!m_quickDlg) {
+		m_quickDlg = new CQuickDlg(this);
 		m_quickDlg->Show();
 
-		SetWindowText( m_quickDlg->GetHwnd(), TranslateT( "Quick connect" ));
-		SetDlgItemText( m_quickDlg->GetHwnd(), IDC_TEXT, TranslateT( "Please select IRC network and enter the password if needed" ));
-		SetDlgItemText( m_quickDlg->GetHwnd(), IDC_CAPTION, TranslateT( "Quick connect" ));
-		WindowSetIcon( m_quickDlg->GetHwnd(), IDI_QUICK );
+		SetWindowText(m_quickDlg->GetHwnd(), TranslateT("Quick connect"));
+		SetDlgItemText(m_quickDlg->GetHwnd(), IDC_TEXT, TranslateT("Please select IRC network and enter the password if needed"));
+		SetDlgItemText(m_quickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Quick connect"));
+		WindowSetIcon(m_quickDlg->GetHwnd(), IDI_QUICK);
 	}
 
-	ShowWindow( m_quickDlg->GetHwnd(), SW_SHOW );
-	SetActiveWindow( m_quickDlg->GetHwnd());
+	ShowWindow(m_quickDlg->GetHwnd(), SW_SHOW);
+	SetActiveWindow(m_quickDlg->GetHwnd());
 	return 0;
 }
 
 INT_PTR __cdecl CIrcProto::OnShowListMenuCommand(WPARAM, LPARAM)
 {
-	PostIrcMessage( _T("/LIST"));
+	PostIrcMessage(_T("/LIST"));
 	return 0;
 }
 
@@ -388,27 +389,27 @@ INT_PTR __cdecl CIrcProto::OnShowServerMenuCommand(WPARAM, LPARAM)
 {
 	GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
 	GCEVENT gce = { sizeof(gce), &gcd };
-	CallChatEvent( WINDOW_VISIBLE, (LPARAM)&gce);
+	CallChatEvent(WINDOW_VISIBLE, (LPARAM)&gce);
 	return 0;
 }
 
 INT_PTR __cdecl CIrcProto::OnChangeNickMenuCommand(WPARAM, LPARAM)
 {
-	if ( !m_nickDlg ) {
-		m_nickDlg = new CNickDlg( this );
+	if (!m_nickDlg) {
+		m_nickDlg = new CNickDlg(this);
 		m_nickDlg->Show();
 	}
 
-	SetDlgItemText( m_nickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Change nickname"));
-	SetWindowText( GetDlgItem( m_nickDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a unique nickname"));
-	m_nickDlg->m_Enick.SetText( m_info.sNick.c_str());
-	m_nickDlg->m_Enick.SendMsg( CB_SETEDITSEL, 0, MAKELPARAM(0,-1));
-	ShowWindow( m_nickDlg->GetHwnd(), SW_SHOW);
-	SetActiveWindow( m_nickDlg->GetHwnd());
+	SetDlgItemText(m_nickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Change nickname"));
+	SetWindowText(GetDlgItem(m_nickDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a unique nickname"));
+	m_nickDlg->m_Enick.SetText(m_info.sNick.c_str());
+	m_nickDlg->m_Enick.SendMsg(CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
+	ShowWindow(m_nickDlg->GetHwnd(), SW_SHOW);
+	SetActiveWindow(m_nickDlg->GetHwnd());
 	return 0;
 }
 
-static void DoChatFormatting( TCHAR* pszText )
+static void DoChatFormatting(TCHAR* pszText)
 {
 	TCHAR* p1 = pszText;
 	int iFG = -1;
@@ -419,8 +420,8 @@ static void DoChatFormatting( TCHAR* pszText )
 		iRemoveChars = 0;
 		InsertThis[0] = 0;
 
-		if ( *p1 == '%' ) {
-			switch ( p1[1] ) {
+		if (*p1 == '%') {
+			switch (p1[1]) {
 			case 'B':
 			case 'b':
 				lstrcpy(InsertThis, _T("\002"));
@@ -437,17 +438,17 @@ static void DoChatFormatting( TCHAR* pszText )
 				iRemoveChars = 2;
 				break;
 			case 'c':
-				{
-					lstrcpy(InsertThis, _T("\003"));
-					iRemoveChars = 2;
+			{
+						  lstrcpy(InsertThis, _T("\003"));
+						  iRemoveChars = 2;
 
-					TCHAR szTemp[3];
-					lstrcpyn(szTemp, p1 + 2, 3);
-					iFG = _ttoi(szTemp);
-				}
+						  TCHAR szTemp[3];
+						  lstrcpyn(szTemp, p1 + 2, 3);
+						  iFG = _ttoi(szTemp);
+			}
 				break;
 			case 'C':
-				if ( p1[2] == '%' && p1[3] == 'F') {
+				if (p1[2] == '%' && p1[3] == 'F') {
 					lstrcpy(InsertThis, _T("\00399,99"));
 					iRemoveChars = 4;
 				}
@@ -460,7 +461,7 @@ static void DoChatFormatting( TCHAR* pszText )
 			case 'f':
 				if (p1 - 3 >= pszText && p1[-3] == '\003')
 					lstrcpy(InsertThis, _T(","));
-				else if ( iFG >= 0 )
+				else if (iFG >= 0)
 					mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\003%u,"), iFG);
 				else
 					lstrcpy(InsertThis, _T("\00399,"));
@@ -494,11 +495,12 @@ static void DoChatFormatting( TCHAR* pszText )
 				p1++;
 		}
 		else p1++;
-}	}
+	}
+}
 
-int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
+int __cdecl CIrcProto::GCEventHook(WPARAM wParam, LPARAM lParam)
 {
-	GCHOOK *gch= (GCHOOK*) lParam;
+	GCHOOK *gch = (GCHOOK*)lParam;
 	CMString S = _T("");
 
 	EnterCriticalSection(&m_gchook);
@@ -506,23 +508,23 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
 	// handle the hook
 	if (gch) {
 		if (!lstrcmpiA(gch->pDest->pszModule, m_szModuleName)) {
-			TCHAR *p1 = mir_tstrdup( gch->pDest->ptszID );
-			TCHAR *p2 = _tcsstr( p1, _T(" - "));
+			TCHAR *p1 = mir_tstrdup(gch->pDest->ptszID);
+			TCHAR *p2 = _tcsstr(p1, _T(" - "));
 			if (p2)
 				*p2 = '\0';
 
-			switch( gch->pDest->iType ) {
+			switch (gch->pDest->iType) {
 			case GC_SESSION_TERMINATE:
 				FreeWindowItemData(p1, (CHANNELINFO*)gch->dwData);
 				break;
 
 			case GC_USER_MESSAGE:
 				if (gch && gch->ptszText && *gch->ptszText) {
-					TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText)+1000];
+					TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText) + 1000];
 					lstrcpy(pszText, gch->ptszText);
 					DoChatFormatting(pszText);
 					PostIrcMessageWnd(p1, NULL, pszText);
-					delete []pszText;
+					delete[]pszText;
 				}
 				break;
 
@@ -531,15 +533,15 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
 				break;
 
 			case GC_USER_PRIVMESS:
-				{
-					TCHAR szTemp[4000];
-					mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/QUERY %s"), gch->ptszUID );
-					PostIrcMessageWnd(p1, NULL, szTemp);
-				}
+			{
+											TCHAR szTemp[4000];
+											mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/QUERY %s"), gch->ptszUID);
+											PostIrcMessageWnd(p1, NULL, szTemp);
+			}
 				break;
 
 			case GC_USER_LOGMENU:
-				switch( gch->dwData ) {
+				switch (gch->dwData) {
 				case 1:
 					OnChangeNickMenuCommand(NULL, NULL);
 					break;
@@ -548,7 +550,7 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
 					break;
 
 				case 3:
-					PostIrcMessage( _T("/PART %s %s"), p1, m_userInfo );
+					PostIrcMessage(_T("/PART %s %s"), p1, m_userInfo);
 					{
 						S = MakeWndID(p1);
 						GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
@@ -565,26 +567,26 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
 					break;
 					*/
 				case 6:		// nickserv Identify
-					PostIrcMessage( _T("/nickserv AUTH %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv AUTH %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter your authentification code"), TranslateT("Authentificate nick"));
 					break;
 				case 7:		// nickserv drop nick
 					if (MessageBox(0, TranslateT("Are you sure you want to unregister your current nick?"), TranslateT("Delete nick"),
 						MB_ICONERROR + MB_YESNO + MB_DEFBUTTON2) == IDYES)
-						PostIrcMessage( _T("/nickserv DROP"));
+						PostIrcMessage(_T("/nickserv DROP"));
 					break;
 				case 8:		// nickserv Identify
 					{
-						CQuestionDlg* dlg = new CQuestionDlg( this );
+						CQuestionDlg* dlg = new CQuestionDlg(this);
 						dlg->Show();
 						HWND question_hWnd = dlg->GetHwnd();
-						HWND hEditCtrl = GetDlgItem( question_hWnd, IDC_EDIT);
-						SetDlgItemText( question_hWnd, IDC_CAPTION, TranslateT("Identify nick"));
-						SetWindowText( GetDlgItem( question_hWnd, IDC_TEXT), TranslateT("Please enter your password"));
-						SetDlgItemText( question_hWnd, IDC_HIDDENEDIT, _T("/nickserv IDENTIFY %question=\"%s\",\"%s\""));
-						SetWindowLongPtr(GetDlgItem( question_hWnd, IDC_EDIT), GWL_STYLE,
-							(LONG)GetWindowLongPtr(GetDlgItem( question_hWnd, IDC_EDIT), GWL_STYLE) | ES_PASSWORD);
-						SendMessage(hEditCtrl, EM_SETPASSWORDCHAR,(WPARAM)_T('*'),0 );
+						HWND hEditCtrl = GetDlgItem(question_hWnd, IDC_EDIT);
+						SetDlgItemText(question_hWnd, IDC_CAPTION, TranslateT("Identify nick"));
+						SetWindowText(GetDlgItem(question_hWnd, IDC_TEXT), TranslateT("Please enter your password"));
+						SetDlgItemText(question_hWnd, IDC_HIDDENEDIT, _T("/nickserv IDENTIFY %question=\"%s\",\"%s\""));
+						SetWindowLongPtr(GetDlgItem(question_hWnd, IDC_EDIT), GWL_STYLE,
+							(LONG)GetWindowLongPtr(GetDlgItem(question_hWnd, IDC_EDIT), GWL_STYLE) | ES_PASSWORD);
+						SendMessage(hEditCtrl, EM_SETPASSWORDCHAR, (WPARAM)_T('*'), 0);
 						SetFocus(hEditCtrl);
 						dlg->Activate();
 					}
@@ -592,152 +594,152 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
 				case 9:		// nickserv remind password
 					{
 						DBVARIANT dbv;
-						if ( !getTString( "Nick", &dbv )) {
-							PostIrcMessage( _T("/nickserv SENDPASS %s"), dbv.ptszVal);
-							db_free( &dbv );
+						if (!getTString("Nick", &dbv)) {
+							PostIrcMessage(_T("/nickserv SENDPASS %s"), dbv.ptszVal);
+							db_free(&dbv);
 						}
 					}
 					break;
 				case 10:		// nickserv set new password
-					PostIrcMessage( _T("/nickserv SET PASSWORD %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv SET PASSWORD %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter your new password"), TranslateT("Set new password"));
 					break;
 				case 11:		// nickserv set language
-					PostIrcMessage( _T("/nickserv SET LANGUAGE %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv SET LANGUAGE %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter desired language ID (numeric value, depends on server)"), TranslateT("Change language of NickServ messages"));
 					break;
 				case 12:		// nickserv set homepage
-					PostIrcMessage( _T("/nickserv SET URL %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv SET URL %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter URL that will be linked to your nick"), TranslateT("Set URL, linked to nick"));
 					break;
 				case 13:		// nickserv set email
-					PostIrcMessage( _T("/nickserv SET EMAIL %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv SET EMAIL %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter your e-mail, that will be linked to your nick"), TranslateT("Set e-mail, linked to nick"));
 					break;
 				case 14:		// nickserv set info
-					PostIrcMessage( _T("/nickserv SET INFO %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv SET INFO %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter some information about your nick"), TranslateT("Set information for nick"));
 					break;
 				case 15:		// nickserv kill unauth off
-					PostIrcMessage( _T("/nickserv SET KILL OFF"));
+					PostIrcMessage(_T("/nickserv SET KILL OFF"));
 					break;
 				case 16:		// nickserv kill unauth on
-					PostIrcMessage( _T("/nickserv SET KILL ON"));
+					PostIrcMessage(_T("/nickserv SET KILL ON"));
 					break;
 				case 17:		// nickserv kill unauth quick
-					PostIrcMessage( _T("/nickserv SET KILL QUICK"));
+					PostIrcMessage(_T("/nickserv SET KILL QUICK"));
 					break;
 				case 18:		// nickserv hide nick from /LIST
-					PostIrcMessage( _T("/nickserv SET PRIVATE ON"));
+					PostIrcMessage(_T("/nickserv SET PRIVATE ON"));
 					break;
 				case 19:		// nickserv show nick to /LIST
-					PostIrcMessage( _T("/nickserv SET PRIVATE OFF"));
+					PostIrcMessage(_T("/nickserv SET PRIVATE OFF"));
 					break;
 				case 20:		// nickserv Hide e-mail from info
-					PostIrcMessage( _T("/nickserv SET HIDE EMAIL ON"));
+					PostIrcMessage(_T("/nickserv SET HIDE EMAIL ON"));
 					break;
 				case 21:		// nickserv Show e-mail in info
-					PostIrcMessage( _T("/nickserv SET HIDE EMAIL OFF"));
+					PostIrcMessage(_T("/nickserv SET HIDE EMAIL OFF"));
 					break;
 				case 22:		// nickserv Set security for nick
-					PostIrcMessage( _T("/nickserv SET SECURE ON"));
+					PostIrcMessage(_T("/nickserv SET SECURE ON"));
 					break;
 				case 23:		// nickserv Remove security for nick
-					PostIrcMessage( _T("/nickserv SET SECURE OFF"));
+					PostIrcMessage(_T("/nickserv SET SECURE OFF"));
 					break;
 				case 24:		// nickserv Link nick to current
-					PostIrcMessage( _T("/nickserv LINK %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv LINK %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter nick you want to link to your current nick"), TranslateT("Link another nick to current nick"));
 					break;
 				case 25:		// nickserv Unlink nick from current
-					PostIrcMessage( _T("/nickserv LINK %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv LINK %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter nick you want to unlink from your current nick"), TranslateT("Unlink another nick from current nick"));
 					break;
 				case 26:		// nickserv Set main nick
-					PostIrcMessage( _T("/nickserv LINK %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/nickserv LINK %%question=\"%s\",\"%s\""),
 						TranslateT("Please enter nick you want to set as your main nick"), TranslateT("Set main nick"));
 					break;
 				case 27:		// nickserv list all linked nicks
-					PostIrcMessage( _T("/nickserv LISTLINKS"));
+					PostIrcMessage(_T("/nickserv LISTLINKS"));
 					break;
 				case 28:		// nickserv list all channels owned
-					PostIrcMessage( _T("/nickserv LISTCHANS"));
+					PostIrcMessage(_T("/nickserv LISTCHANS"));
 					break;
 				}
 				break;
 
 			case GC_USER_NICKLISTMENU:
-				switch(gch->dwData) {
+				switch (gch->dwData) {
 				case 1:
-					PostIrcMessage( _T("/MODE %s +o %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s +o %s"), p1, gch->ptszUID);
 					break;
 				case 2:
-					PostIrcMessage( _T("/MODE %s -o %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s -o %s"), p1, gch->ptszUID);
 					break;
 				case 3:
-					PostIrcMessage( _T("/MODE %s +v %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s +v %s"), p1, gch->ptszUID);
 					break;
 				case 4:
-					PostIrcMessage( _T("/MODE %s -v %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s -v %s"), p1, gch->ptszUID);
 					break;
 				case 5:
-					PostIrcMessage( _T("/KICK %s %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/KICK %s %s"), p1, gch->ptszUID);
 					break;
 				case 6:
-					PostIrcMessage( _T("/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""),
+					PostIrcMessage(_T("/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""),
 						p1, gch->ptszUID, TranslateT("Please enter the reason"), TranslateT("Kick"), TranslateT("Jerk"));
 					break;
 				case 7:
-					DoUserhostWithReason(1, _T("B") + (CMString)p1, true, _T("%s"), gch->ptszUID );
+					DoUserhostWithReason(1, _T("B") + (CMString)p1, true, _T("%s"), gch->ptszUID);
 					break;
 				case 8:
-					DoUserhostWithReason(1, _T("K") + (CMString)p1, true, _T("%s"), gch->ptszUID );
+					DoUserhostWithReason(1, _T("K") + (CMString)p1, true, _T("%s"), gch->ptszUID);
 					break;
 				case 9:
-					DoUserhostWithReason(1, _T("L") + (CMString)p1, true, _T("%s"), gch->ptszUID );
+					DoUserhostWithReason(1, _T("L") + (CMString)p1, true, _T("%s"), gch->ptszUID);
 					break;
 				case 10:
-					PostIrcMessage( _T("/WHOIS %s %s"), gch->ptszUID, gch->ptszUID );
+					PostIrcMessage(_T("/WHOIS %s %s"), gch->ptszUID, gch->ptszUID);
 					break;
-					//	case 11:
-					//		DoUserhostWithReason(1, "I", true, "%s", gch->ptszUID );
-					//		break;
-					//	case 12:
-					//		DoUserhostWithReason(1, "J", true, "%s", gch->ptszUID );
-					//		break;
+				//	case 11:
+				//		DoUserhostWithReason(1, "I", true, "%s", gch->ptszUID );
+				//		break;
+				//	case 12:
+				//		DoUserhostWithReason(1, "J", true, "%s", gch->ptszUID );
+				//		break;
 				case 13:
-					PostIrcMessage( _T("/DCC CHAT %s"), gch->ptszUID );
+					PostIrcMessage(_T("/DCC CHAT %s"), gch->ptszUID);
 					break;
 				case 14:
-					PostIrcMessage( _T("/DCC SEND %s"), gch->ptszUID );
+					PostIrcMessage(_T("/DCC SEND %s"), gch->ptszUID);
 					break;
 				case 15:
-					DoUserhostWithReason(1, _T("I"), true, _T("%s"), gch->ptszUID );
+					DoUserhostWithReason(1, _T("I"), true, _T("%s"), gch->ptszUID);
 					break;
 				case 16:
-					PostIrcMessage( _T("/MODE %s +h %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s +h %s"), p1, gch->ptszUID);
 					break;
 				case 17:
-					PostIrcMessage( _T("/MODE %s -h %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s -h %s"), p1, gch->ptszUID);
 					break;
 				case 18:
-					PostIrcMessage( _T("/MODE %s +q %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s +q %s"), p1, gch->ptszUID);
 					break;
 				case 19:
-					PostIrcMessage( _T("/MODE %s -q %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s -q %s"), p1, gch->ptszUID);
 					break;
 				case 20:
-					PostIrcMessage( _T("/MODE %s +a %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s +a %s"), p1, gch->ptszUID);
 					break;
 				case 21:
-					PostIrcMessage( _T("/MODE %s -a %s"), p1, gch->ptszUID );
+					PostIrcMessage(_T("/MODE %s -a %s"), p1, gch->ptszUID);
 					break;
 				case 22:
-					PostIrcMessage( _T("/NOTICE %s %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/NOTICE %s %%question=\"%s\",\"%s\""),
 						gch->ptszUID, TranslateT("Please enter the notice text"), TranslateT("Send notice"));
 					break;
 				case 23:
-					PostIrcMessage( _T("/INVITE %s %%question=\"%s\",\"%s\""),
+					PostIrcMessage(_T("/INVITE %s %%question=\"%s\",\"%s\""),
 						gch->ptszUID, TranslateT("Please enter the channel name to invite to"), TranslateT("Invite to channel"));
 					break;
 				case 30:
@@ -756,31 +758,20 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
 					}
 					break;
 				case 31:	//slap
-					{
-						TCHAR tszTemp[4000];
-						mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/slap %s"), gch->ptszUID);
-						PostIrcMessageWnd(p1, NULL, tszTemp);
-					}
+					PostIrcMessageWnd(p1, NULL, CMString(FORMAT, _T("/slap %s"), gch->ptszUID));
 					break;
 				case 32:  //nickserv info
-					{
-						TCHAR tszTemp[4000];
-						mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv INFO %s ALL"), gch->ptszUID);
-						PostIrcMessageWnd(p1, NULL, tszTemp);
-					}
+					PostIrcMessageWnd(p1, NULL, CMString(FORMAT, _T("/nickserv INFO %s ALL"), gch->ptszUID));
 					break;
 				case 33:  //nickserv ghost
-					{
-						TCHAR tszTemp[4000];
-						mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv GHOST %s"), gch->ptszUID);
-						PostIrcMessageWnd(p1, NULL, tszTemp);
-					}
+					PostIrcMessageWnd(p1, NULL, CMString(FORMAT, _T("/nickserv GHOST %s"), gch->ptszUID));
 					break;
 				}
 				break;
 			}
-			mir_free( p1 );
-	}	}
+			mir_free(p1);
+		}
+	}
 
 	LeaveCriticalSection(&m_gchook);
 	return 0;
@@ -861,11 +852,11 @@ static gc_item nickItems[] = {
 
 int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
 {
-	GCMENUITEMS *gcmi= (GCMENUITEMS*) lParam;
-	if ( gcmi ) {
-		if ( !lstrcmpiA( gcmi->pszModule, m_szModuleName )) {
-			if ( gcmi->Type == MENU_ON_LOG ) {
-				if ( lstrcmpi( gcmi->pszID, SERVERWINDOW)) {
+	GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
+	if (gcmi) {
+		if (!lstrcmpiA(gcmi->pszModule, m_szModuleName)) {
+			if (gcmi->Type == MENU_ON_LOG) {
+				if (lstrcmpi(gcmi->pszID, SERVERWINDOW)) {
 					gcmi->nItems = SIZEOF(logItems);
 					gcmi->Item = logItems;
 				}
@@ -873,44 +864,46 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
 			}
 
 			if (gcmi->Type == MENU_ON_NICKLIST) {
-				CONTACT user ={ (TCHAR*)gcmi->pszUID, NULL, NULL, false, false, false};
+				CONTACT user = { (TCHAR*)gcmi->pszUID, NULL, NULL, false, false, false };
 				HANDLE hContact = CList_FindContact(&user);
 
 				gcmi->nItems = SIZEOF(nickItems);
 				gcmi->Item = nickItems;
 				BOOL bIsInList = (hContact && db_get_b(hContact, "CList", "NotOnList", 0) == 0);
-				gcmi->Item[gcmi->nItems-1].bDisabled = bIsInList;
+				gcmi->Item[gcmi->nItems - 1].bDisabled = bIsInList;
 
 				unsigned long ulAdr = 0;
 				if (m_manualHost)
 					ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
 				else
-					ulAdr = ConvertIPToInteger(m_IPFromServer?m_myHost:m_myLocalHost);
-				gcmi->Item[23].bDisabled = ulAdr == 0?TRUE:FALSE;		//DCC submenu
+					ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
+				gcmi->Item[23].bDisabled = ulAdr == 0 ? TRUE : FALSE;		//DCC submenu
 
 				TCHAR stzChanName[100];
-				const TCHAR* temp = _tcschr( gcmi->pszID, ' ' );
-				int len = min((( temp == NULL ) ? lstrlen( gcmi->pszID ) : ( int )( temp - gcmi->pszID + 1 )), SIZEOF(stzChanName)-1 );
-				lstrcpyn( stzChanName, gcmi->pszID, len );
-				stzChanName[ len ] = 0;
-				CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA,stzChanName, NULL, NULL, NULL, NULL, NULL, false, false, 0);
-				BOOL bServOwner  = strchr(sUserModes.c_str(), 'q') == NULL?FALSE:TRUE;
-				BOOL bServAdmin  = strchr(sUserModes.c_str(), 'a') == NULL?FALSE:TRUE;
-				BOOL bOwner  = bServOwner?((wi->OwnMode>>4)&01):FALSE;
-				BOOL bAdmin  = bServAdmin?((wi->OwnMode>>3)&01):FALSE;
-				BOOL bOp	 = strchr(sUserModes.c_str(), 'o') == NULL?FALSE:((wi->OwnMode>>2)&01);
-				BOOL bHalfop = strchr(sUserModes.c_str(), 'h') == NULL?FALSE:((wi->OwnMode>>1)&01);
+				const TCHAR* temp = _tcschr(gcmi->pszID, ' ');
+				int len = min(((temp == NULL) ? lstrlen(gcmi->pszID) : (int)(temp - gcmi->pszID + 1)), SIZEOF(stzChanName) - 1);
+				lstrcpyn(stzChanName, gcmi->pszID, len);
+				stzChanName[len] = 0;
+				CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, stzChanName, NULL, NULL, NULL, NULL, NULL, false, false, 0);
+				BOOL bServOwner = strchr(sUserModes.c_str(), 'q') == NULL ? FALSE : TRUE;
+				BOOL bServAdmin = strchr(sUserModes.c_str(), 'a') == NULL ? FALSE : TRUE;
+				BOOL bOwner = bServOwner ? ((wi->OwnMode >> 4) & 01) : FALSE;
+				BOOL bAdmin = bServAdmin ? ((wi->OwnMode >> 3) & 01) : FALSE;
+				BOOL bOp = strchr(sUserModes.c_str(), 'o') == NULL ? FALSE : ((wi->OwnMode >> 2) & 01);
+				BOOL bHalfop = strchr(sUserModes.c_str(), 'h') == NULL ? FALSE : ((wi->OwnMode >> 1) & 01);
 
 				BOOL bForceEnable = GetAsyncKeyState(VK_CONTROL);
 
-				gcmi->Item[6].bDisabled /* "Control" submenu */ = !(bForceEnable|| bHalfop || bOp || bAdmin || bOwner);
-				gcmi->Item[7].uType = gcmi->Item[8].uType  = /* +/- Owner */ bServOwner?MENU_POPUPITEM:0;
-				gcmi->Item[9].uType = gcmi->Item[10].uType = /* +/- Admin */ bServAdmin?MENU_POPUPITEM:0;
-				gcmi->Item[7].bDisabled  = gcmi->Item[8].bDisabled  = gcmi->Item[9].bDisabled  = gcmi->Item[10].bDisabled = /* +/- Owner/Admin */
+				gcmi->Item[6].bDisabled /* "Control" submenu */ = !(bForceEnable || bHalfop || bOp || bAdmin || bOwner);
+				gcmi->Item[7].uType = gcmi->Item[8].uType = /* +/- Owner */ bServOwner ? MENU_POPUPITEM : 0;
+				gcmi->Item[9].uType = gcmi->Item[10].uType = /* +/- Admin */ bServAdmin ? MENU_POPUPITEM : 0;
+				gcmi->Item[7].bDisabled = gcmi->Item[8].bDisabled = gcmi->Item[9].bDisabled = gcmi->Item[10].bDisabled = /* +/- Owner/Admin */
 					!(bForceEnable || bOwner);
 				gcmi->Item[11].bDisabled = gcmi->Item[12].bDisabled = gcmi->Item[13].bDisabled = gcmi->Item[14].bDisabled = /* +/- Op/hop */
 					!(bForceEnable || bOp || bAdmin || bOwner);
-	}	}	}
+			}
+		}
+	}
 
 	return 0;
 }
@@ -919,19 +912,19 @@ int __cdecl CIrcProto::OnPreShutdown(WPARAM, LPARAM)
 {
 	EnterCriticalSection(&cs);
 
-	if ( m_perform && IsConnected())
-		if ( DoPerform( "Event: Disconnect" ))
-			Sleep( 200 );
+	if (m_perform && IsConnected())
+	if (DoPerform("Event: Disconnect"))
+		Sleep(200);
 
-	DisconnectAllDCCSessions( true );
+	DisconnectAllDCCSessions(true);
 
-	if ( IsConnected())
+	if (IsConnected())
 		Disconnect();
-	if ( m_listDlg )
+	if (m_listDlg)
 		m_listDlg->Close();
-	if ( m_nickDlg )
+	if (m_nickDlg)
 		m_nickDlg->Close();
-	if ( m_joinDlg )
+	if (m_joinDlg)
 		m_joinDlg->Close();
 
 	LeaveCriticalSection(&cs);
@@ -954,11 +947,11 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
 			Menu_ShowItem(hUMenuChanSettings, true);
 
 		// context menu for contact
-		else if ( !getTString( hContact, "Default", &dbv )) {
+		else if (!getTString(hContact, "Default", &dbv)) {
 			Menu_ShowItem(hUMenuChanSettings, false);
 
 			// for DCC contact
-			BYTE bDcc = getByte( hContact, "DCC", 0) ;
+			BYTE bDcc = getByte(hContact, "DCC", 0);
 			if (bDcc)
 				Menu_ShowItem(hUMenuDisconnect, true);
 			else {
@@ -968,7 +961,7 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
 				bool bEnabled = true;
 				if (bIsOnline) {
 					DBVARIANT dbv3;
-					if ( !getString( hContact, "Host", &dbv3)) {
+					if (!getString(hContact, "Host", &dbv3)) {
 						if (dbv3.pszVal[0] == 0)
 							bEnabled = false;
 						db_free(&dbv3);
@@ -976,7 +969,7 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
 				}
 				Menu_ShowItem(hUMenuIgnore, bEnabled);
 			}
-			db_free( &dbv );
+			db_free(&dbv);
 		}
 	}
 
@@ -985,33 +978,34 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
 
 int __cdecl CIrcProto::OnDbSettingChanged(WPARAM wParam, LPARAM lParam)
 {
-	HANDLE hContact = ( HANDLE ) wParam;
-	if ( hContact == NULL || !IsConnected())
+	HANDLE hContact = (HANDLE)wParam;
+	if (hContact == NULL || !IsConnected())
 		return 0;
 
-	DBCONTACTWRITESETTING* cws = ( DBCONTACTWRITESETTING* )lParam;
-	if ( strcmp( cws->szModule, "CList" ))
+	DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam;
+	if (strcmp(cws->szModule, "CList"))
 		return 0;
 
-	if ( cws->value.type != DBVT_DELETED && !( cws->value.type==DBVT_BYTE && cws->value.bVal==0 ))
+	if (cws->value.type != DBVT_DELETED && !(cws->value.type == DBVT_BYTE && cws->value.bVal == 0))
 		return 0;
 
-	if ( !strcmp( cws->szSetting, "NotOnList" )) {
+	if (!strcmp(cws->szSetting, "NotOnList")) {
 		DBVARIANT dbv;
-		if ( !getTString( hContact, "Nick", &dbv )) {
-			if ( getByte( "MirVerAutoRequest", 1))
-				PostIrcMessage( _T("/PRIVMSG %s \001VERSION\001"), dbv.ptszVal );
-			db_free( &dbv );
-	}	}
+		if (!getTString(hContact, "Nick", &dbv)) {
+			if (getByte("MirVerAutoRequest", 1))
+				PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), dbv.ptszVal);
+			db_free(&dbv);
+		}
+	}
 	return 0;
 }
-void __cdecl CIrcProto::ConnectServerThread( void* )
+void __cdecl CIrcProto::ConnectServerThread(void*)
 {
-	InterlockedIncrement((long *) &m_bConnectThreadRunning);
-	InterlockedIncrement((long *) &m_bConnectRequested);
-	while ( !Miranda_Terminated() && m_bConnectRequested > 0 ) {
-		while(m_bConnectRequested > 0)
-			InterlockedDecrement((long *) &m_bConnectRequested);
+	InterlockedIncrement((long *)&m_bConnectThreadRunning);
+	InterlockedIncrement((long *)&m_bConnectRequested);
+	while (!Miranda_Terminated() && m_bConnectRequested > 0) {
+		while (m_bConnectRequested > 0)
+			InterlockedDecrement((long *)&m_bConnectRequested);
 		if (IsConnected()) {
 			Sleep(200);
 			Disconnect();
@@ -1021,29 +1015,30 @@ void __cdecl CIrcProto::ConnectServerThread( void* )
 		int Temp = m_iStatus;
 		m_iStatus = ID_STATUS_CONNECTING;
 		nickflag = true;
-		ProtoBroadcastAck(NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)Temp,ID_STATUS_CONNECTING);
+		ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_CONNECTING);
 		Sleep(100);
 		EnterCriticalSection(&cs);
 		Connect(si);
 		LeaveCriticalSection(&cs);
 		if (IsConnected()) {
-			if ( m_mySpecifiedHost[0] )
-				ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( m_mySpecifiedHost, IP_MANUAL ));
+			if (m_mySpecifiedHost[0])
+				ForkThread(&CIrcProto::ResolveIPThread, new IPRESOLVE(m_mySpecifiedHost, IP_MANUAL));
 
 			DoEvent(GC_EVENT_CHANGESESSIONAME, SERVERWINDOW, NULL, m_info.sNetwork.c_str(), NULL, NULL, NULL, FALSE, TRUE);
 		}
 		else {
 			Temp = m_iDesiredStatus;
 			m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
-			ProtoBroadcastAck( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK );
-			ProtoBroadcastAck(NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)Temp,ID_STATUS_OFFLINE);
+			ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
+			ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_OFFLINE);
 			Sleep(100);
-	}	}
+		}
+	}
 
 	InterlockedDecrement((long *)&m_bConnectThreadRunning);
 }
 
-void __cdecl CIrcProto::DisconnectServerThread( void* )
+void __cdecl CIrcProto::DisconnectServerThread(void*)
 {
 	mir_cslock lck(cs);
 	if (IsConnected())
@@ -1060,7 +1055,7 @@ void CIrcProto::ConnectToServer(void)
 	si.sUserID = m_userID;
 	si.sFullName = m_name;
 	si.sPassword = m_password;
-	si.bIdentServer =  ((m_ident) ? (true) : (false));
+	si.bIdentServer = ((m_ident) ? (true) : (false));
 	si.iIdentServerPort = StrToInt(m_identPort);
 	si.sIdentServerType = m_identSystem;
 	si.m_iSSL = m_iSSL;
@@ -1076,9 +1071,9 @@ void CIrcProto::ConnectToServer(void)
 	sChannelModes = "btnimklps";
 
 	if (!m_bConnectThreadRunning)
-		ForkThread( &CIrcProto::ConnectServerThread, 0 );
+		ForkThread(&CIrcProto::ConnectServerThread, 0);
 	else if (m_bConnectRequested < 1)
-		InterlockedIncrement((long *) &m_bConnectRequested);
+		InterlockedIncrement((long *)&m_bConnectRequested);
 
 	TCHAR szTemp[300];
 	mir_sntprintf(szTemp, SIZEOF(szTemp), _T("\0033%s \002%s\002 (%S: %u)"),
@@ -1088,21 +1083,21 @@ void CIrcProto::ConnectToServer(void)
 
 void CIrcProto::DisconnectFromServer(void)
 {
-	if ( m_perform && IsConnected())
-		DoPerform( "Event: Disconnect" );
+	if (m_perform && IsConnected())
+		DoPerform("Event: Disconnect");
 
 	GCDEST gcd = { m_szModuleName, 0, GC_EVENT_CONTROL };
 	GCEVENT gce = { sizeof(gce), &gcd };
-	CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
-	ForkThread( &CIrcProto::DisconnectServerThread, 0 );
+	CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
+	ForkThread(&CIrcProto::DisconnectServerThread, 0);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
 // GetMyAwayMsg - obtain the current away message
 
-INT_PTR __cdecl CIrcProto::GetMyAwayMsg(WPARAM wParam,LPARAM lParam)
+INT_PTR __cdecl CIrcProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
 {
-	if (( int )wParam != m_iStatus )
+	if ((int)wParam != m_iStatus)
 		return 0;
 
 	const TCHAR* p = m_statusMessage.c_str();
diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp
index 9cfcb82137..5d07573291 100644
--- a/protocols/IRCG/src/tools.cpp
+++ b/protocols/IRCG/src/tools.cpp
@@ -497,10 +497,9 @@ CMString CIrcProto::PrefixToStatus(int cPrefix)
 struct TimerPair
 {
 	TimerPair(CIrcProto* _pro, UINT_PTR _id) :
-	ppro(_pro),
-	idEvent(_id)
-	{
-	}
+		ppro(_pro),
+		idEvent(_id)
+		{}
 
 	UINT_PTR idEvent;
 	CIrcProto *ppro;
diff --git a/protocols/IRCG/src/userinfo.cpp b/protocols/IRCG/src/userinfo.cpp
index b693d06d9e..7ed1fc12a0 100644
--- a/protocols/IRCG/src/userinfo.cpp
+++ b/protocols/IRCG/src/userinfo.cpp
@@ -42,144 +42,144 @@ struct UserDetailsDlgProcParam
 
 INT_PTR CALLBACK UserDetailsDlgProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-	UserDetailsDlgProcParam* p = ( UserDetailsDlgProcParam* )GetWindowLongPtr( m_hwnd, GWLP_USERDATA );
+	UserDetailsDlgProcParam *p = (UserDetailsDlgProcParam*)GetWindowLongPtr(m_hwnd, GWLP_USERDATA);
 	switch (msg) {
 	case WM_INITDIALOG:
-		p = new UserDetailsDlgProcParam( NULL, ( HANDLE )lParam );
-		SetWindowLongPtr( m_hwnd, GWLP_USERDATA, ( LPARAM )p );
+		p = new UserDetailsDlgProcParam(NULL, (HANDLE)lParam);
+		SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LPARAM)p);
 		break;
 
 	case WM_NOTIFY:
-		if ((( LPNMHDR )lParam )->idFrom == 0 && (( LPNMHDR )lParam )->code == PSN_PARAMCHANGED ) {
-			p->ppro = ( CIrcProto* )(( PSHNOTIFY* )lParam )->lParam;
+		if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_PARAMCHANGED) {
+			p->ppro = (CIrcProto*)((PSHNOTIFY*)lParam)->lParam;
 
 			DBVARIANT dbv;
-			BYTE bAdvanced = p->ppro->getByte( p->hContact, "AdvancedMode", 0);
+			BYTE bAdvanced = p->ppro->getByte(p->hContact, "AdvancedMode", 0);
 
-			TranslateDialogDefault( m_hwnd);
+			TranslateDialogDefault(m_hwnd);
 
-			CheckDlgButton( m_hwnd, IDC_RADIO1, bAdvanced?BST_UNCHECKED:BST_CHECKED);
-			CheckDlgButton( m_hwnd, IDC_RADIO2, bAdvanced?BST_CHECKED:BST_UNCHECKED);
-			EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), bAdvanced);
+			CheckDlgButton(m_hwnd, IDC_RADIO1, bAdvanced ? BST_UNCHECKED : BST_CHECKED);
+			CheckDlgButton(m_hwnd, IDC_RADIO2, bAdvanced ? BST_CHECKED : BST_UNCHECKED);
+			EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), bAdvanced);
 
-			if ( !bAdvanced ) {
-				SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));
-				if ( !p->ppro->getTString( p->hContact, "Default", &dbv)) {
-					SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal);
+			if (!bAdvanced) {
+				SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));
+				if (!p->ppro->getTString(p->hContact, "Default", &dbv)) {
+					SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.ptszVal);
 					db_free(&dbv);
 				}
 			}
 			else {
-				SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
-				if ( !p->ppro->getTString( p->hContact, "UWildcard", &dbv)) {
-					SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal);
+				SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
+				if (!p->ppro->getTString(p->hContact, "UWildcard", &dbv)) {
+					SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.ptszVal);
 					db_free(&dbv);
-			}	}
+				}
+			}
 
-			if ( !p->ppro->getTString( p->hContact, "UUser", &dbv)) {
-				SetDlgItemText( m_hwnd, IDC_USER, dbv.ptszVal);
+			if (!p->ppro->getTString(p->hContact, "UUser", &dbv)) {
+				SetDlgItemText(m_hwnd, IDC_USER, dbv.ptszVal);
 				db_free(&dbv);
 			}
 
-			if ( !p->ppro->getTString( p->hContact, "UHost", &dbv)) {
-				SetDlgItemText( m_hwnd, IDC_HOST, dbv.ptszVal);
+			if (!p->ppro->getTString(p->hContact, "UHost", &dbv)) {
+				SetDlgItemText(m_hwnd, IDC_HOST, dbv.ptszVal);
 				db_free(&dbv);
 			}
-			ProtoBroadcastAck(p->ppro->m_szModuleName, p->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+			ProtoBroadcastAck(p->ppro->m_szModuleName, p->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
 		}
 		break;
 
 	case WM_COMMAND:
-		if (( LOWORD(wParam) == IDC_WILDCARD || LOWORD(wParam) == IDC_USER || LOWORD(wParam) == IDC_HOST ) &&
-			 ( HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
+		if ((LOWORD(wParam) == IDC_WILDCARD || LOWORD(wParam) == IDC_USER || LOWORD(wParam) == IDC_HOST) &&
+			(HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
 			return true;
 
-		EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), true);
-		EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON2), true);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON), true);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON2), true);
 
-		if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON ) {
+		if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON) {
 			TCHAR temp[500];
-			GetDlgItemText( m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
-			DBVARIANT dbv;
-
-			BYTE bAdvanced = IsDlgButtonChecked( m_hwnd, IDC_RADIO1)?0:1;
-			if ( bAdvanced ) {
-				if ( GetWindowTextLength(GetDlgItem( m_hwnd, IDC_WILDCARD)) == 0 ||
-					  GetWindowTextLength(GetDlgItem( m_hwnd, IDC_USER)) == 0 ||
-					  GetWindowTextLength(GetDlgItem( m_hwnd, IDC_HOST)) == 0)
-				{
-					MessageBox( NULL, TranslateT(STR_ERROR2), TranslateT("IRC error"), MB_OK|MB_ICONERROR);
+			GetDlgItemText(m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
+
+			BYTE bAdvanced = IsDlgButtonChecked(m_hwnd, IDC_RADIO1) ? 0 : 1;
+			if (bAdvanced) {
+				if (GetWindowTextLength(GetDlgItem(m_hwnd, IDC_WILDCARD)) == 0 ||
+					GetWindowTextLength(GetDlgItem(m_hwnd, IDC_USER)) == 0 ||
+					GetWindowTextLength(GetDlgItem(m_hwnd, IDC_HOST)) == 0) {
+					MessageBox(NULL, TranslateT(STR_ERROR2), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
 					return FALSE;
 				}
 
-				if ( !p->ppro->getTString( p->hContact, "Default", &dbv )) {
+				DBVARIANT dbv;
+				if (!p->ppro->getTString(p->hContact, "Default", &dbv)) {
 					CMString S = _T(STR_ERROR);
 					S += _T(" (");
 					S += dbv.ptszVal;
 					S += _T(")");
-					if (( lstrlen(temp) < 4 && lstrlen(temp)) || !WCCmp(CharLower(temp), CharLower(dbv.ptszVal))) {
-						MessageBox( NULL, TranslateTS( S.c_str()), TranslateT( "IRC error" ), MB_OK | MB_ICONERROR );
-						db_free( &dbv );
+					if ((lstrlen(temp) < 4 && lstrlen(temp)) || !WCCmp(CharLower(temp), CharLower(dbv.ptszVal))) {
+						MessageBox(NULL, TranslateTS(S.c_str()), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
+						db_free(&dbv);
 						return FALSE;
 					}
-					db_free( &dbv );
+					db_free(&dbv);
 				}
 
-				GetDlgItemText( m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
-				if ( lstrlen( GetWord(temp, 0).c_str()))
-					p->ppro->setTString( p->hContact, "UWildcard", GetWord(temp, 0).c_str());
+				GetDlgItemText(m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
+				if (lstrlen(GetWord(temp, 0).c_str()))
+					p->ppro->setTString(p->hContact, "UWildcard", GetWord(temp, 0).c_str());
 				else
-					db_unset( p->hContact, p->ppro->m_szModuleName, "UWildcard");
+					db_unset(p->hContact, p->ppro->m_szModuleName, "UWildcard");
 			}
 
-			p->ppro->setByte( p->hContact, "AdvancedMode", bAdvanced);
+			p->ppro->setByte(p->hContact, "AdvancedMode", bAdvanced);
 
-			GetDlgItemText( m_hwnd, IDC_USER, temp, SIZEOF(temp));
+			GetDlgItemText(m_hwnd, IDC_USER, temp, SIZEOF(temp));
 			if (lstrlen(GetWord(temp, 0).c_str()))
-				p->ppro->setTString( p->hContact, "UUser", GetWord(temp, 0).c_str());
+				p->ppro->setTString(p->hContact, "UUser", GetWord(temp, 0).c_str());
 			else
-				db_unset( p->hContact, p->ppro->m_szModuleName, "UUser");
+				db_unset(p->hContact, p->ppro->m_szModuleName, "UUser");
 
-			GetDlgItemText( m_hwnd, IDC_HOST, temp, SIZEOF(temp));
+			GetDlgItemText(m_hwnd, IDC_HOST, temp, SIZEOF(temp));
 			if (lstrlen(GetWord(temp, 0).c_str()))
-				p->ppro->setTString( p->hContact, "UHost", GetWord(temp, 0).c_str());
+				p->ppro->setTString(p->hContact, "UHost", GetWord(temp, 0).c_str());
 			else
-				db_unset( p->hContact, p->ppro->m_szModuleName, "UHost");
+				db_unset(p->hContact, p->ppro->m_szModuleName, "UHost");
 
-			EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), FALSE);
+			EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON), FALSE);
 		}
 
-		if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON2 ) {
-			if ( IsDlgButtonChecked( m_hwnd, IDC_RADIO2 ))
-				SetDlgItemTextA( m_hwnd, IDC_WILDCARD, "");
-			SetDlgItemTextA( m_hwnd, IDC_HOST, "" );
-			SetDlgItemTextA( m_hwnd, IDC_USER, "" );
-			db_unset( p->hContact, p->ppro->m_szModuleName, "UWildcard");
-			db_unset( p->hContact, p->ppro->m_szModuleName, "UUser");
-			db_unset( p->hContact, p->ppro->m_szModuleName, "UHost");
-			EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), FALSE );
-			EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON2), FALSE );
+		if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON2) {
+			if (IsDlgButtonChecked(m_hwnd, IDC_RADIO2))
+				SetDlgItemTextA(m_hwnd, IDC_WILDCARD, "");
+			SetDlgItemTextA(m_hwnd, IDC_HOST, "");
+			SetDlgItemTextA(m_hwnd, IDC_USER, "");
+			db_unset(p->hContact, p->ppro->m_szModuleName, "UWildcard");
+			db_unset(p->hContact, p->ppro->m_szModuleName, "UUser");
+			db_unset(p->hContact, p->ppro->m_szModuleName, "UHost");
+			EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON), FALSE);
+			EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON2), FALSE);
 		}
 
-		if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO1 ) {
-			SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));
+		if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO1) {
+			SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));
 
 			DBVARIANT dbv;
-			if ( !p->ppro->getTString( p->hContact, "Default", &dbv )) {
-				SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal );
-				db_free( &dbv );
+			if (!p->ppro->getTString(p->hContact, "Default", &dbv)) {
+				SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.ptszVal);
+				db_free(&dbv);
 			}
-			EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), FALSE );
+			EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), FALSE);
 		}
 
-		if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO2 ) {
+		if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO2) {
 			DBVARIANT dbv;
-			SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
-			if ( !p->ppro->getTString( p->hContact, "UWildcard", &dbv )) {
-				SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal );
-				db_free( &dbv );
+			SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
+			if (!p->ppro->getTString(p->hContact, "UWildcard", &dbv)) {
+				SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.ptszVal);
+				db_free(&dbv);
 			}
-			EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), true);
+			EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), true);
 		}
 		break;
 	}
@@ -190,19 +190,19 @@ int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam)
 {
 	HANDLE hContact = (HANDLE)lParam;
 	char *szProto = GetContactProto(hContact);
-	if ( !hContact || !szProto || lstrcmpiA( szProto, m_szModuleName ))
+	if (!hContact || !szProto || lstrcmpiA(szProto, m_szModuleName))
 		return 0;
 
-	if ( isChatRoom(hContact))
+	if (isChatRoom(hContact))
 		return 0;
 
-	if ( getByte( hContact, "DCC", 0) != 0)
+	if (getByte(hContact, "DCC", 0) != 0)
 		return 0;
 
 	DBVARIANT dbv;
-	if ( !getTString( hContact, "Default", &dbv )) {
-		if ( IsChannel( dbv.ptszVal )) {
-			db_free( &dbv );
+	if (!getTString(hContact, "Default", &dbv)) {
+		if (IsChannel(dbv.ptszVal)) {
+			db_free(&dbv);
 			return 0;
 		}
 		db_free(&dbv);
@@ -212,7 +212,7 @@ int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam)
 	odp.flags = ODPF_DONTTRANSLATE;
 	odp.pszTitle = m_szModuleName;
 	odp.hIcon = NULL;
-	odp.dwInitParam = ( LPARAM )this;
+	odp.dwInitParam = (LPARAM)this;
 	odp.hInstance = hInst;
 	odp.position = -1900000000;
 	odp.pfnDlgProc = UserDetailsDlgProc;
diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp
index a2973e3c99..1e4593217e 100644
--- a/protocols/IRCG/src/windows.cpp
+++ b/protocols/IRCG/src/windows.cpp
@@ -24,23 +24,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 /////////////////////////////////////////////////////////////////////////////////////////
 // Message Box
 
-CMessageBoxDlg::CMessageBoxDlg( CIrcProto* _pro, DCCINFO* _dci ) :
-	CProtoDlgBase<CIrcProto>( _pro, IDD_MESSAGEBOX, NULL ),
-	pdci( _dci ),
-	m_Ok( this, IDOK )
+CMessageBoxDlg::CMessageBoxDlg(CIrcProto* _pro, DCCINFO* _dci) :
+	CProtoDlgBase<CIrcProto>(_pro, IDD_MESSAGEBOX, NULL),
+	pdci(_dci),
+	m_Ok(this, IDOK)
 {
-	m_Ok.OnClick = Callback( this, &CMessageBoxDlg::OnOk );
+	m_Ok.OnClick = Callback(this, &CMessageBoxDlg::OnOk);
 }
 
 void CMessageBoxDlg::OnInitDialog()
 {
 }
 
-void CMessageBoxDlg::OnOk( CCtrlButton* )
+void CMessageBoxDlg::OnOk(CCtrlButton*)
 {
-	CDccSession* dcc = new CDccSession(m_proto, pdci);
+	CDccSession *dcc = new CDccSession(m_proto, pdci);
 
-	CDccSession* olddcc = m_proto->FindDCCSession(pdci->hContact);
+	CDccSession *olddcc = m_proto->FindDCCSession(pdci->hContact);
 	if (olddcc)
 		olddcc->Disconnect();
 	m_proto->AddDCCSession(pdci->hContact, dcc);
@@ -51,150 +51,150 @@ void CMessageBoxDlg::OnOk( CCtrlButton* )
 /////////////////////////////////////////////////////////////////////////////////////////
 // Whois dialog
 
-CWhoisDlg::CWhoisDlg( CIrcProto* _pro ) :
-	CCoolIrcDlg( _pro, IDD_INFO ),
-	m_InfoNick( this, IDC_INFO_NICK ),
-	m_Reply( this, IDC_REPLY ),
-	m_Caption( this, IDC_CAPTION ),
-	m_AwayTime( this, IDC_AWAYTIME ),
-	m_InfoName( this, IDC_INFO_NAME ),
-	m_InfoId( this, IDC_INFO_ID ),
-	m_InfoAddress( this, IDC_INFO_ADDRESS ),
-	m_InfoChannels( this, IDC_INFO_CHANNELS ),
-	m_InfoAuth( this, IDC_INFO_AUTH ),
-	m_InfoServer( this, IDC_INFO_SERVER ),
-	m_InfoAway2( this, IDC_INFO_AWAY2 ),
-	m_InfoOther( this, IDC_INFO_OTHER ),
-	m_Ping( this, IDC_PING ),
-	m_Version( this, IDC_VERSION ),
-	m_Time( this, IDC_TIME ),
-	m_userInfo( this, IDC_USERINFO ),
-	m_Refresh( this, ID_INFO_GO ),
-	m_Query( this, ID_INFO_QUERY )
-{
-	m_Ping.OnClick = Callback( this, &CWhoisDlg::OnPing );
-	m_Version.OnClick = Callback( this, &CWhoisDlg::OnVersion );
-	m_Time.OnClick = Callback( this, &CWhoisDlg::OnTime );
-	m_userInfo.OnClick = Callback( this, &CWhoisDlg::OnUserInfo );
-	m_Refresh.OnClick = Callback( this, &CWhoisDlg::OnGo );
-	m_Query.OnClick = Callback( this, &CWhoisDlg::OnQuery );
+CWhoisDlg::CWhoisDlg(CIrcProto* _pro) :
+	CCoolIrcDlg(_pro, IDD_INFO),
+	m_InfoNick(this, IDC_INFO_NICK),
+	m_Reply(this, IDC_REPLY),
+	m_Caption(this, IDC_CAPTION),
+	m_AwayTime(this, IDC_AWAYTIME),
+	m_InfoName(this, IDC_INFO_NAME),
+	m_InfoId(this, IDC_INFO_ID),
+	m_InfoAddress(this, IDC_INFO_ADDRESS),
+	m_InfoChannels(this, IDC_INFO_CHANNELS),
+	m_InfoAuth(this, IDC_INFO_AUTH),
+	m_InfoServer(this, IDC_INFO_SERVER),
+	m_InfoAway2(this, IDC_INFO_AWAY2),
+	m_InfoOther(this, IDC_INFO_OTHER),
+	m_Ping(this, IDC_PING),
+	m_Version(this, IDC_VERSION),
+	m_Time(this, IDC_TIME),
+	m_userInfo(this, IDC_USERINFO),
+	m_Refresh(this, ID_INFO_GO),
+	m_Query(this, ID_INFO_QUERY)
+{
+	m_Ping.OnClick = Callback(this, &CWhoisDlg::OnPing);
+	m_Version.OnClick = Callback(this, &CWhoisDlg::OnVersion);
+	m_Time.OnClick = Callback(this, &CWhoisDlg::OnTime);
+	m_userInfo.OnClick = Callback(this, &CWhoisDlg::OnUserInfo);
+	m_Refresh.OnClick = Callback(this, &CWhoisDlg::OnGo);
+	m_Query.OnClick = Callback(this, &CWhoisDlg::OnQuery);
 }
 
 void CWhoisDlg::OnInitDialog()
 {
 	LOGFONT lf;
-	HFONT hFont = ( HFONT )m_AwayTime.SendMsg( WM_GETFONT, 0, 0 );
-	GetObject( hFont, sizeof( lf ), &lf );
+	HFONT hFont = (HFONT)m_AwayTime.SendMsg(WM_GETFONT, 0, 0);
+	GetObject(hFont, sizeof(lf), &lf);
 	lf.lfWeight = FW_BOLD;
-	hFont = CreateFontIndirect( &lf );
+	hFont = CreateFontIndirect(&lf);
 	m_AwayTime.SendMsg(WM_SETFONT, (WPARAM)hFont, 0);
 
 	CCoolIrcDlg::OnInitDialog();
 
-	WindowSetIcon( m_hwnd, IDI_WHOIS );
+	WindowSetIcon(m_hwnd, IDI_WHOIS);
 }
 
 void CWhoisDlg::OnClose()
 {
-	ShowWindow( m_hwnd, SW_HIDE);
-	SendMessage( m_hwnd, WM_SETREDRAW, FALSE, 0);
+	ShowWindow(m_hwnd, SW_HIDE);
+	SendMessage(m_hwnd, WM_SETREDRAW, FALSE, 0);
 }
 
 void CWhoisDlg::OnDestroy()
 {
 	CCoolIrcDlg::OnDestroy();
 
-	HFONT hFont2=(HFONT)SendDlgItemMessage( m_hwnd,IDC_AWAYTIME,WM_GETFONT,0,0);
-	SendDlgItemMessage( m_hwnd,IDC_CAPTION,WM_SETFONT,SendDlgItemMessage( m_hwnd,IDOK,WM_GETFONT,0,0),0);
-	DeleteObject(hFont2);				
+	HFONT hFont2 = (HFONT)SendDlgItemMessage(m_hwnd, IDC_AWAYTIME, WM_GETFONT, 0, 0);
+	SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_SETFONT, SendDlgItemMessage(m_hwnd, IDOK, WM_GETFONT, 0, 0), 0);
+	DeleteObject(hFont2);
 
 	m_proto->m_whoisDlg = NULL;
 }
 
-void CWhoisDlg::OnGo( CCtrlButton* )
+void CWhoisDlg::OnGo(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_InfoNick.GetText( szTemp, SIZEOF(szTemp));
-	m_proto->PostIrcMessage( _T("/WHOIS %s %s"), szTemp, szTemp );
+	m_InfoNick.GetText(szTemp, SIZEOF(szTemp));
+	m_proto->PostIrcMessage(_T("/WHOIS %s %s"), szTemp, szTemp);
 }
 
-void CWhoisDlg::OnQuery( CCtrlButton* )
+void CWhoisDlg::OnQuery(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_InfoNick.GetText( szTemp, SIZEOF(szTemp));
-	m_proto->PostIrcMessage( _T("/QUERY %s"), szTemp );
+	m_InfoNick.GetText(szTemp, SIZEOF(szTemp));
+	m_proto->PostIrcMessage(_T("/QUERY %s"), szTemp);
 }
 
-void CWhoisDlg::OnPing( CCtrlButton* )
+void CWhoisDlg::OnPing(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_InfoNick.GetText( szTemp, SIZEOF(szTemp));
-	m_Reply.SetText( TranslateT("Please wait..."));
-	m_proto->PostIrcMessage( _T("/PRIVMSG %s \001PING %u\001"), szTemp, time(0));
+	m_InfoNick.GetText(szTemp, SIZEOF(szTemp));
+	m_Reply.SetText(TranslateT("Please wait..."));
+	m_proto->PostIrcMessage(_T("/PRIVMSG %s \001PING %u\001"), szTemp, time(0));
 }
 
-void CWhoisDlg::OnUserInfo( CCtrlButton* )
+void CWhoisDlg::OnUserInfo(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_InfoNick.GetText( szTemp, SIZEOF(szTemp));
-	m_Reply.SetText( TranslateT("Please wait..."));
-	m_proto->PostIrcMessage( _T("/PRIVMSG %s \001USERINFO\001"), szTemp);
+	m_InfoNick.GetText(szTemp, SIZEOF(szTemp));
+	m_Reply.SetText(TranslateT("Please wait..."));
+	m_proto->PostIrcMessage(_T("/PRIVMSG %s \001USERINFO\001"), szTemp);
 }
 
-void CWhoisDlg::OnTime( CCtrlButton* )
+void CWhoisDlg::OnTime(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_InfoNick.GetText( szTemp, SIZEOF(szTemp));
-	m_Reply.SetText( TranslateT("Please wait..."));
-	m_proto->PostIrcMessage( _T("/PRIVMSG %s \001TIME\001"), szTemp);
+	m_InfoNick.GetText(szTemp, SIZEOF(szTemp));
+	m_Reply.SetText(TranslateT("Please wait..."));
+	m_proto->PostIrcMessage(_T("/PRIVMSG %s \001TIME\001"), szTemp);
 }
 
-void CWhoisDlg::OnVersion( CCtrlButton* )
+void CWhoisDlg::OnVersion(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_InfoNick.GetText( szTemp, SIZEOF(szTemp));
-	m_Reply.SetText( TranslateT("Please wait..."));
-	m_proto->PostIrcMessage( _T("/PRIVMSG %s \001VERSION\001"), szTemp);
+	m_InfoNick.GetText(szTemp, SIZEOF(szTemp));
+	m_Reply.SetText(TranslateT("Please wait..."));
+	m_proto->PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), szTemp);
 }
 
 void CWhoisDlg::ShowMessage(const CIrcMessage* pmsg)
 {
-	if ( m_InfoNick.SendMsg( CB_FINDSTRINGEXACT, -1, (LPARAM) pmsg->parameters[1].c_str()) == CB_ERR)	
-		m_InfoNick.SendMsg( CB_ADDSTRING, 0, (LPARAM) pmsg->parameters[1].c_str());	
-	int i = m_InfoNick.SendMsg( CB_FINDSTRINGEXACT, -1, (LPARAM) pmsg->parameters[1].c_str());
-	m_InfoNick.SendMsg( CB_SETCURSEL, i, 0);
-	m_Caption.SetText( pmsg->parameters[1].c_str());
-	m_InfoName.SetText( pmsg->parameters[5].c_str());	
-	m_InfoAddress.SetText( pmsg->parameters[3].c_str());
-	m_InfoId.SetText( pmsg->parameters[2].c_str());
-	m_InfoChannels.SetText( _T(""));
-	m_InfoServer.SetText( _T(""));
-	m_InfoAway2.SetText( _T(""));
-	m_InfoAuth.SetText( _T(""));
-	m_InfoOther.SetText( _T(""));
-	m_Reply.SetText( _T(""));
-	SetWindowText( m_hwnd, TranslateT("User information"));
-	EnableWindow( GetDlgItem( m_hwnd, ID_INFO_QUERY), true );
-	ShowWindow( m_hwnd, SW_SHOW);
-	if ( IsIconic( m_hwnd ))
-		ShowWindow( m_hwnd, SW_SHOWNORMAL );
-	SendMessage( m_hwnd, WM_SETREDRAW, TRUE, 0);
-	InvalidateRect( m_hwnd, NULL, TRUE);
+	if (m_InfoNick.SendMsg(CB_FINDSTRINGEXACT, -1, (LPARAM)pmsg->parameters[1].c_str()) == CB_ERR)
+		m_InfoNick.SendMsg(CB_ADDSTRING, 0, (LPARAM)pmsg->parameters[1].c_str());
+	int i = m_InfoNick.SendMsg(CB_FINDSTRINGEXACT, -1, (LPARAM)pmsg->parameters[1].c_str());
+	m_InfoNick.SendMsg(CB_SETCURSEL, i, 0);
+	m_Caption.SetText(pmsg->parameters[1].c_str());
+	m_InfoName.SetText(pmsg->parameters[5].c_str());
+	m_InfoAddress.SetText(pmsg->parameters[3].c_str());
+	m_InfoId.SetText(pmsg->parameters[2].c_str());
+	m_InfoChannels.SetText(_T(""));
+	m_InfoServer.SetText(_T(""));
+	m_InfoAway2.SetText(_T(""));
+	m_InfoAuth.SetText(_T(""));
+	m_InfoOther.SetText(_T(""));
+	m_Reply.SetText(_T(""));
+	SetWindowText(m_hwnd, TranslateT("User information"));
+	EnableWindow(GetDlgItem(m_hwnd, ID_INFO_QUERY), true);
+	ShowWindow(m_hwnd, SW_SHOW);
+	if (IsIconic(m_hwnd))
+		ShowWindow(m_hwnd, SW_SHOWNORMAL);
+	SendMessage(m_hwnd, WM_SETREDRAW, TRUE, 0);
+	InvalidateRect(m_hwnd, NULL, TRUE);
 }
 
 void CWhoisDlg::ShowMessageNoUser(const CIrcMessage* pmsg)
 {
-	m_InfoNick.SetText( pmsg->parameters[2].c_str());
-	m_InfoNick.SendMsg( CB_SETEDITSEL, 0,MAKELPARAM(0,-1));
-	m_Caption.SetText( pmsg->parameters[2].c_str());	
-	m_InfoName.SetText(  _T(""));
-	m_InfoAddress.SetText(  _T(""));
-	m_InfoId.SetText(  _T(""));
-	m_InfoChannels.SetText( _T(""));
-	m_InfoServer.SetText( _T(""));
-	m_InfoAway2.SetText( _T(""));
-	m_InfoAuth.SetText( _T(""));
-	m_Reply.SetText( _T(""));
+	m_InfoNick.SetText(pmsg->parameters[2].c_str());
+	m_InfoNick.SendMsg(CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
+	m_Caption.SetText(pmsg->parameters[2].c_str());
+	m_InfoName.SetText(_T(""));
+	m_InfoAddress.SetText(_T(""));
+	m_InfoId.SetText(_T(""));
+	m_InfoChannels.SetText(_T(""));
+	m_InfoServer.SetText(_T(""));
+	m_InfoAway2.SetText(_T(""));
+	m_InfoAuth.SetText(_T(""));
+	m_Reply.SetText(_T(""));
 	EnableWindow(GetDlgItem(m_hwnd, ID_INFO_QUERY), false);
 }
 
@@ -202,26 +202,27 @@ void CWhoisDlg::ShowMessageNoUser(const CIrcMessage* pmsg)
 // 'Change nickname' dialog
 
 CNickDlg::CNickDlg(CIrcProto *_pro) :
-	CCoolIrcDlg( _pro, IDD_NICK ),
-	m_Ok( this, IDOK ),
-	m_Enick( this, IDC_ENICK )
+	CCoolIrcDlg(_pro, IDD_NICK),
+	m_Ok(this, IDOK),
+	m_Enick(this, IDC_ENICK)
 {
-	m_Ok.OnClick = Callback( this, &CNickDlg::OnOk );
+	m_Ok.OnClick = Callback(this, &CNickDlg::OnOk);
 }
 
 void CNickDlg::OnInitDialog()
 {
 	CCoolIrcDlg::OnInitDialog();
-	WindowSetIcon( m_hwnd, IDI_RENAME );
+	WindowSetIcon(m_hwnd, IDI_RENAME);
 
 	DBVARIANT dbv;
-	if ( !m_proto->getTString( "RecentNicks", &dbv)) {
-		for (int i = 0; i<10; i++)
-			if ( !GetWord( dbv.ptszVal, i).IsEmpty())
-				SendDlgItemMessage( m_hwnd, IDC_ENICK, CB_ADDSTRING, 0, (LPARAM)GetWord(dbv.ptszVal, i).c_str());
+	if (!m_proto->getTString("RecentNicks", &dbv)) {
+		for (int i = 0; i < 10; i++)
+		if (!GetWord(dbv.ptszVal, i).IsEmpty())
+			SendDlgItemMessage(m_hwnd, IDC_ENICK, CB_ADDSTRING, 0, (LPARAM)GetWord(dbv.ptszVal, i).c_str());
 
 		db_free(&dbv);
-}	}
+	}
+}
 
 void CNickDlg::OnDestroy()
 {
@@ -229,23 +230,23 @@ void CNickDlg::OnDestroy()
 	m_proto->m_nickDlg = NULL;
 }
 
-void CNickDlg::OnOk( CCtrlButton* )
+void CNickDlg::OnOk(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_Enick.GetText( szTemp, SIZEOF(szTemp));
-	m_proto->PostIrcMessage( _T("/NICK %s"), szTemp);
+	m_Enick.GetText(szTemp, SIZEOF(szTemp));
+	m_proto->PostIrcMessage(_T("/NICK %s"), szTemp);
 
-	CMString S = szTemp; 
+	CMString S = szTemp;
 	DBVARIANT dbv;
-	if ( !m_proto->getTString( "RecentNicks", &dbv )) {
-		for ( int i = 0; i<10; i++ ) {
+	if (!m_proto->getTString("RecentNicks", &dbv)) {
+		for (int i = 0; i < 10; i++) {
 			CMString s = GetWord(dbv.ptszVal, i);
-			if ( !s.IsEmpty() && s != szTemp)
+			if (!s.IsEmpty() && s != szTemp)
 				S += _T(" ") + s;
 		}
 		db_free(&dbv);
 	}
-	m_proto->setTString( "RecentNicks", S.c_str());
+	m_proto->setTString("RecentNicks", S.c_str());
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -254,64 +255,64 @@ void CNickDlg::OnOk( CCtrlButton* )
 #define LIST_TIMER 10
 
 CListDlg::CListDlg(CIrcProto *_pro) :
-	CProtoDlgBase<CIrcProto>( _pro, IDD_LIST, NULL ),
-	m_Join( this, IDC_JOIN ),
-	m_list( this, IDC_INFO_LISTVIEW ),
-	m_list2( this, IDC_INFO_LISTVIEW2 ),
-	m_status( this, IDC_TEXT ),
-	m_filter( this, IDC_FILTER_STRING )
-{
-	m_list2.OnDoubleClick = m_list.OnDoubleClick = m_Join.OnClick = Callback( this, &CListDlg::OnJoin );
-	m_list.OnColumnClick = Callback( this, &CListDlg::List_OnColumnClick );
+	CProtoDlgBase<CIrcProto>(_pro, IDD_LIST, NULL),
+	m_Join(this, IDC_JOIN),
+	m_list(this, IDC_INFO_LISTVIEW),
+	m_list2(this, IDC_INFO_LISTVIEW2),
+	m_status(this, IDC_TEXT),
+	m_filter(this, IDC_FILTER_STRING)
+{
+	m_list2.OnDoubleClick = m_list.OnDoubleClick = m_Join.OnClick = Callback(this, &CListDlg::OnJoin);
+	m_list.OnColumnClick = Callback(this, &CListDlg::List_OnColumnClick);
 }
 
 void CListDlg::OnInitDialog()
 {
 	RECT screen;
 
-	SystemParametersInfo(SPI_GETWORKAREA, 0,  &screen, 0); 
+	SystemParametersInfo(SPI_GETWORKAREA, 0, &screen, 0);
 	LVCOLUMN lvC;
-	int COLUMNS_SIZES[4] ={200, 50,50,2000};
+	int COLUMNS_SIZES[4] = { 200, 50, 50, 2000 };
 	TCHAR szBuffer[32];
 
 	lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
 	lvC.fmt = LVCFMT_LEFT;
-	for ( int index = 0; index < 4; index++ ) {
+	for (int index = 0; index < 4; index++) {
 		lvC.iSubItem = index;
 		lvC.cx = COLUMNS_SIZES[index];
 
-		switch( index ) {
-			case 0: lstrcpy( szBuffer, TranslateT("Channel")); break;
-			case 1: lstrcpy( szBuffer, _T("#"));               break;
-			case 2: lstrcpy( szBuffer, TranslateT("Mode"));    break;
-			case 3: lstrcpy( szBuffer, TranslateT("Topic"));   break;
+		switch (index) {
+			case 0: lstrcpy(szBuffer, TranslateT("Channel")); break;
+			case 1: lstrcpy(szBuffer, _T("#"));               break;
+			case 2: lstrcpy(szBuffer, TranslateT("Mode"));    break;
+			case 3: lstrcpy(szBuffer, TranslateT("Topic"));   break;
 		}
 		lvC.pszText = szBuffer;
-		m_list.InsertColumn( index, &lvC );
-		m_list2.InsertColumn( index, &lvC );
+		m_list.InsertColumn(index, &lvC);
+		m_list2.InsertColumn(index, &lvC);
 	}
-	
+
 	Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "channelList_");
 
-	m_list.SetExtendedListViewStyle( LVS_EX_FULLROWSELECT );
-	m_list2.SetExtendedListViewStyle( LVS_EX_FULLROWSELECT );
-	WindowSetIcon( m_hwnd, IDI_LIST );
-	m_status.SetText( TranslateT( "Please wait..." ));
+	m_list.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
+	m_list2.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
+	WindowSetIcon(m_hwnd, IDI_LIST);
+	m_status.SetText(TranslateT("Please wait..."));
 }
 
 INT_PTR CListDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
 {
-	if ( msg == WM_TIMER ) {
-		::KillTimer( m_hwnd, m_timer ); m_timer = 0;
+	if (msg == WM_TIMER) {
+		::KillTimer(m_hwnd, m_timer); m_timer = 0;
 
 		// Retrieve the input text
 		TCHAR strFilterText[255];
-		m_filter.GetText( strFilterText, SIZEOF(strFilterText));
+		m_filter.GetText(strFilterText, SIZEOF(strFilterText));
 
-		if ( strFilterText[0] ) {
+		if (strFilterText[0]) {
 			int itemCount = 0;
 			int j = m_list.GetItemCount();
-			if ( j <= 0 )
+			if (j <= 0)
 				return FALSE;
 
 			// Empty the filtered list
@@ -322,15 +323,14 @@ INT_PTR CListDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
 			lvm.pszText = text;	// Set buffer for texts
 			lvm.cchTextMax = 128;
 			lvm.mask = LVIF_TEXT;
-			for ( int i = 0; i < j; i++ ) {
+			for (int i = 0; i < j; i++) {
 				lvm.iSubItem = 0;	// First column
 				lvm.iItem = i;
-				m_list.GetItem( &lvm );
+				m_list.GetItem(&lvm);
 
 				// Match the text?
-				TCHAR* t = _tcsstr( lvm.pszText, strFilterText);
-				if ( t == NULL )	// If no, then Check if in the topics
-				{
+				TCHAR* t = _tcsstr(lvm.pszText, strFilterText);
+				if (t == NULL)	{ // If no, then Check if in the topics
 					LVITEM lvm2;		// To avoid to overwrite the external lvm
 					TCHAR text[300];
 					lvm2.pszText = text;	// Set buffer for texts
@@ -338,75 +338,78 @@ INT_PTR CListDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
 					lvm2.mask = LVIF_TEXT;
 					lvm2.iSubItem = 3;	// Topic column
 					lvm2.iItem = i;
-					m_list.GetItem( &lvm );
+					m_list.GetItem(&lvm);
 
 					// Match the text?
-					t = _tcsstr( lvm.pszText, strFilterText);
+					t = _tcsstr(lvm.pszText, strFilterText);
 				}
-				if ( t ) {
+
+				if (t) {
 					++itemCount;
 
 					// Column 0
 					LVITEM lvItem;
-					lvItem.iItem = m_list2.GetItemCount(); 
+					lvItem.iItem = m_list2.GetItemCount();
 					lvItem.mask = LVIF_TEXT | LVIF_PARAM;
 
 					lvItem.iSubItem = 0;
 					lvItem.pszText = lvm.pszText;
 					lvItem.lParam = lvItem.iItem;
-					lvItem.iItem = m_list2.InsertItem( &lvItem );
+					lvItem.iItem = m_list2.InsertItem(&lvItem);
 
 					// Column 2
 					lvm.mask = LVIF_TEXT;
 					lvm.iSubItem = 1;
 					lvm.iItem = i;
-					m_list.GetItem( &lvm );
+					m_list.GetItem(&lvm);
 
 					lvItem.mask = LVIF_TEXT;
 					lvItem.iSubItem = 1;
 					lvItem.pszText = lvm.pszText;
-					m_list2.SetItem( &lvItem );
+					m_list2.SetItem(&lvItem);
 
 					// Column 4
-					lvm.mask= LVIF_TEXT;
+					lvm.mask = LVIF_TEXT;
 					lvm.iSubItem = 3;
 					lvm.iItem = i;
-					m_list.GetItem( &lvm );
+					m_list.GetItem(&lvm);
 
 					lvItem.mask = LVIF_TEXT;
 					lvItem.pszText = lvm.pszText;
 					lvItem.iSubItem = 3;
-					m_list2.SetItem( &lvItem );
-			}	}	
+					m_list2.SetItem(&lvItem);
+				}
+			}
 
 			// Show the list
-			SetWindowPos( m_list2.GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
-			ShowWindow( m_list.GetHwnd(), SW_HIDE );
+			SetWindowPos(m_list2.GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
+			ShowWindow(m_list.GetHwnd(), SW_HIDE);
 
 			// New dialog title
 			TCHAR newTitle[255];
 			mir_sntprintf(newTitle, SIZEOF(newTitle), TranslateT("%s - Filtered - %d items"), m_title, itemCount);
-			SetWindowText( m_hwnd, newTitle );
+			SetWindowText(m_hwnd, newTitle);
 		}
 		else {
-			ShowWindow( m_list.GetHwnd(), SW_SHOW );
-			ShowWindow( m_list2.GetHwnd(), SW_HIDE);
-			SetWindowText( m_hwnd, m_title );
-	}	}
+			ShowWindow(m_list.GetHwnd(), SW_SHOW);
+			ShowWindow(m_list2.GetHwnd(), SW_HIDE);
+			SetWindowText(m_hwnd, m_title);
+		}
+	}
 
-	return CProtoDlgBase<CIrcProto>::DlgProc( msg, wParam, lParam );
+	return CProtoDlgBase<CIrcProto>::DlgProc(msg, wParam, lParam);
 }
 
-void CListDlg::OnChange( CCtrlBase* ctrl )
+void CListDlg::OnChange(CCtrlBase* ctrl)
 {
-	if ( ctrl->GetCtrlId() == IDC_FILTER_STRING )
-		m_timer = ::SetTimer( m_hwnd, LIST_TIMER, 200, NULL );
+	if (ctrl->GetCtrlId() == IDC_FILTER_STRING)
+		m_timer = ::SetTimer(m_hwnd, LIST_TIMER, 200, NULL);
 }
 
 void CListDlg::OnDestroy()
 {
-	if ( m_timer )
-		::KillTimer( m_hwnd, m_timer );
+	if (m_timer)
+		::KillTimer(m_hwnd, m_timer);
 	Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "channelList_");
 	m_proto->m_listDlg = NULL;
 }
@@ -419,8 +422,8 @@ struct ListViewSortParam
 
 static int CALLBACK ListViewSort(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 {
-	ListViewSortParam* param = ( ListViewSortParam* )lParamSort;
-	if ( !param->pList->GetHwnd())
+	ListViewSortParam* param = (ListViewSortParam*)lParamSort;
+	if (!param->pList->GetHwnd())
 		return 0;
 
 	TCHAR temp1[512];
@@ -431,23 +434,23 @@ static int CALLBACK ListViewSort(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo
 	lvm.iSubItem = param->iSubItem;
 	lvm.pszText = temp1;
 	lvm.cchTextMax = 511;
-	param->pList->GetItem( &lvm );
+	param->pList->GetItem(&lvm);
 	lvm.iItem = lParam2;
 	lvm.pszText = temp2;
-	param->pList->GetItem( &lvm );
-	if (param->iSubItem != 1){
-		if (lstrlen(temp1) != 0 && lstrlen(temp2) !=0)
+	param->pList->GetItem(&lvm);
+	if (param->iSubItem != 1) {
+		if (lstrlen(temp1) != 0 && lstrlen(temp2) != 0)
 			return lstrcmpi(temp1, temp2);
-		
-		return ( *temp1 == 0 ) ? 1 : -1;
+
+		return (*temp1 == 0) ? 1 : -1;
 	}
 
-	return ( StrToInt(temp1) < StrToInt(temp2)) ? 1 : -1;
+	return (StrToInt(temp1) < StrToInt(temp2)) ? 1 : -1;
 }
 
-int CListDlg::Resizer( UTILRESIZECONTROL *urc)
+int CListDlg::Resizer(UTILRESIZECONTROL *urc)
 {
-	switch( urc->wId ) {
+	switch (urc->wId) {
 	case IDC_INFO_LISTVIEW:
 	case IDC_INFO_LISTVIEW2:
 		return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORY_HEIGHT | RD_ANCHORX_WIDTH;
@@ -459,50 +462,52 @@ int CListDlg::Resizer( UTILRESIZECONTROL *urc)
 	}
 
 	return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
-}	
+}
 
-void CListDlg::List_OnColumnClick( CCtrlListView::TEventInfo* ev )
+void CListDlg::List_OnColumnClick(CCtrlListView::TEventInfo* ev)
 {
 	ListViewSortParam param = { &m_list, ev->nmlv->iSubItem };
-	m_list.SortItems( ListViewSort, (LPARAM)&param );
+	m_list.SortItems(ListViewSort, (LPARAM)&param);
 	UpdateList();
 }
 
-void CListDlg::OnJoin( CCtrlButton* )
+void CListDlg::OnJoin(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	m_filter.GetText( szTemp, SIZEOF(szTemp));
+	m_filter.GetText(szTemp, SIZEOF(szTemp));
 
-	if ( szTemp[0] )
-		m_list2.GetItemText( m_list2.GetSelectionMark(), 0, szTemp, 255 );
+	if (szTemp[0])
+		m_list2.GetItemText(m_list2.GetSelectionMark(), 0, szTemp, 255);
 	else
-		m_list.GetItemText( m_list.GetSelectionMark(), 0, szTemp, 255 );
-	m_proto->PostIrcMessage( _T("/JOIN %s"), szTemp );
+		m_list.GetItemText(m_list.GetSelectionMark(), 0, szTemp, 255);
+	m_proto->PostIrcMessage(_T("/JOIN %s"), szTemp);
 }
 
 void CListDlg::UpdateList()
 {
-	GetWindowText( m_hwnd, m_title, 128);
-	
+	GetWindowText(m_hwnd, m_title, 128);
+
 	int j = m_list.GetItemCount();
-	if ( j > 0 ) {
+	if (j > 0) {
 		LVITEM lvm;
-		lvm.mask= LVIF_PARAM;
+		lvm.mask = LVIF_PARAM;
 		lvm.iSubItem = 0;
-		for ( int i = 0; i < j; i++ ) {
+		for (int i = 0; i < j; i++) {
 			lvm.iItem = i;
 			lvm.lParam = i;
-			m_list.SetItem( &lvm );
-}	}	}
+			m_list.SetItem(&lvm);
+		}
+	}
+}
 
 /////////////////////////////////////////////////////////////////////////////////////////
 // 'Join' dialog
 
 CJoinDlg::CJoinDlg(CIrcProto *_pro) :
-	CCoolIrcDlg( _pro, IDD_NICK, NULL ),
-	m_Ok( this, IDOK )
+	CCoolIrcDlg(_pro, IDD_NICK, NULL),
+	m_Ok(this, IDOK)
 {
-	m_Ok.OnClick = Callback( this, &CJoinDlg::OnOk );
+	m_Ok.OnClick = Callback(this, &CJoinDlg::OnOk);
 }
 
 void CJoinDlg::OnInitDialog()
@@ -510,15 +515,17 @@ void CJoinDlg::OnInitDialog()
 	CCoolIrcDlg::OnInitDialog();
 
 	DBVARIANT dbv;
-	if ( !m_proto->getTString( "RecentChannels", &dbv)) {
-		for ( int i = 0; i < 20; i++ ) {
-			if ( !GetWord( dbv.ptszVal, i).IsEmpty()) {
+	if (!m_proto->getTString("RecentChannels", &dbv)) {
+		for (int i = 0; i < 20; i++) {
+			if (!GetWord(dbv.ptszVal, i).IsEmpty()) {
 				CMString S = GetWord(dbv.ptszVal, i);
-				ReplaceString( S, _T("%newl"), _T(" "));
-				SendDlgItemMessage( m_hwnd, IDC_ENICK, CB_ADDSTRING, 0, (LPARAM)S.c_str());
-		}	}
+				ReplaceString(S, _T("%newl"), _T(" "));
+				SendDlgItemMessage(m_hwnd, IDC_ENICK, CB_ADDSTRING, 0, (LPARAM)S.c_str());
+			}
+		}
 		db_free(&dbv);
-}	}
+	}
+}
 
 void CJoinDlg::OnDestroy()
 {
@@ -526,24 +533,24 @@ void CJoinDlg::OnDestroy()
 	m_proto->m_joinDlg = NULL;
 }
 
-void CJoinDlg::OnOk( CCtrlButton* )
+void CJoinDlg::OnOk(CCtrlButton*)
 {
 	TCHAR szTemp[255];
-	GetDlgItemText( m_hwnd, IDC_ENICK, szTemp, SIZEOF(szTemp));
-	if ( m_proto->IsChannel( szTemp ))
-		m_proto->PostIrcMessage( _T("/JOIN %s"), szTemp );
+	GetDlgItemText(m_hwnd, IDC_ENICK, szTemp, SIZEOF(szTemp));
+	if (m_proto->IsChannel(szTemp))
+		m_proto->PostIrcMessage(_T("/JOIN %s"), szTemp);
 	else
-		m_proto->PostIrcMessage( _T("/JOIN #%s"), szTemp );
+		m_proto->PostIrcMessage(_T("/JOIN #%s"), szTemp);
 
 	CMString S = szTemp;
-	ReplaceString( S, _T(" "), _T("%newl"));
+	ReplaceString(S, _T(" "), _T("%newl"));
 	CMString SL = S;
-	
+
 	DBVARIANT dbv;
-	if ( !m_proto->getTString( "RecentChannels", &dbv)) {
-		for (int i = 0; i < 20; i++ ) {
+	if (!m_proto->getTString("RecentChannels", &dbv)) {
+		for (int i = 0; i < 20; i++) {
 			CMString W = GetWord(dbv.ptszVal, i);
-			if ( !W.IsEmpty() && W != SL)
+			if (!W.IsEmpty() && W != SL)
 				S += _T(" ") + W;
 		}
 		db_free(&dbv);
@@ -555,101 +562,101 @@ void CJoinDlg::OnOk( CCtrlButton* )
 // 'Quick' dialog
 
 CQuickDlg::CQuickDlg(CIrcProto *_pro) :
-	CCoolIrcDlg( _pro, IDD_QUICKCONN ),
-	m_Ok( this, IDOK ),
-	m_serverCombo( this, IDC_SERVERCOMBO )
+	CCoolIrcDlg(_pro, IDD_QUICKCONN),
+	m_Ok(this, IDOK),
+	m_serverCombo(this, IDC_SERVERCOMBO)
 {
-	m_Ok.OnClick = Callback( this, &CQuickDlg::OnOk );
-	m_serverCombo.OnChange = Callback( this, &CQuickDlg::OnServerCombo );
+	m_Ok.OnClick = Callback(this, &CQuickDlg::OnOk);
+	m_serverCombo.OnChange = Callback(this, &CQuickDlg::OnServerCombo);
 }
 
 void CQuickDlg::OnInitDialog()
 {
 	CCoolIrcDlg::OnInitDialog();
 
-	if ( g_servers.getCount() > 0 ) {
-		for ( int i=0; i < g_servers.getCount(); i++ ) {
+	if (g_servers.getCount() > 0) {
+		for (int i = 0; i < g_servers.getCount(); i++) {
 			const SERVER_INFO& si = g_servers[i];
-			m_serverCombo.AddStringA( si.m_name, ( LPARAM )&si );
+			m_serverCombo.AddStringA(si.m_name, (LPARAM)&si);
 		}
 	}
-	else EnableWindow(GetDlgItem( m_hwnd, IDOK), false);
-	
+	else EnableWindow(GetDlgItem(m_hwnd, IDOK), false);
+
 	m_si = new SERVER_INFO;
-	m_si->m_group = mir_strdup( "" );
-	m_si->m_name = mir_strdup( Translate("---- Not listed server ----"));
+	m_si->m_group = mir_strdup("");
+	m_si->m_name = mir_strdup(Translate("---- Not listed server ----"));
 
 	DBVARIANT dbv;
-	if ( !m_proto->getString( "ServerName", &dbv )) {
-		m_si->m_address = mir_strdup( dbv.pszVal );
+	if (!m_proto->getString("ServerName", &dbv)) {
+		m_si->m_address = mir_strdup(dbv.pszVal);
 		db_free(&dbv);
 	}
-	else m_si->m_address = mir_strdup( Translate("Type new server address here"));
+	else m_si->m_address = mir_strdup(Translate("Type new server address here"));
 
-	if ( !m_proto->getString( "PortStart", &dbv )) {
-		m_si->m_portStart = atoi( dbv.pszVal );
+	if (!m_proto->getString("PortStart", &dbv)) {
+		m_si->m_portStart = atoi(dbv.pszVal);
 		db_free(&dbv);
 	}
 	else m_si->m_portStart = 6667;
 
-	if ( !m_proto->getString( "PortEnd", &dbv )) {
-		m_si->m_portEnd = atoi( dbv.pszVal );
+	if (!m_proto->getString("PortEnd", &dbv)) {
+		m_si->m_portEnd = atoi(dbv.pszVal);
 		db_free(&dbv);
 	}
 	else m_si->m_portEnd = 6667;
 
-	m_si->m_iSSL = m_proto->getByte( "UseSSL", 0 );
-	
-	m_serverCombo.AddStringA( m_si->m_name, ( LPARAM )m_si );
+	m_si->m_iSSL = m_proto->getByte("UseSSL", 0);
 
-	if ( m_proto->m_quickComboSelection != -1 ) {
-		m_serverCombo.SetCurSel( m_proto->m_quickComboSelection );
-		OnServerCombo( NULL );
+	m_serverCombo.AddStringA(m_si->m_name, (LPARAM)m_si);
+
+	if (m_proto->m_quickComboSelection != -1) {
+		m_serverCombo.SetCurSel(m_proto->m_quickComboSelection);
+		OnServerCombo(NULL);
 	}
-	else EnableWindow(GetDlgItem( m_hwnd, IDOK), false);
+	else EnableWindow(GetDlgItem(m_hwnd, IDOK), false);
 }
 
 void CQuickDlg::OnDestroy()
 {
 	CCoolIrcDlg::OnDestroy();
-	
+
 	delete m_si;
 	m_proto->m_quickDlg = NULL;
 }
 
-void CQuickDlg::OnOk( CCtrlButton* )
+void CQuickDlg::OnOk(CCtrlButton*)
 {
-	GetDlgItemTextA( m_hwnd, IDC_SERVER, m_proto->m_serverName, SIZEOF(m_proto->m_serverName));				 
-	GetDlgItemTextA( m_hwnd, IDC_PORT,   m_proto->m_portStart,  SIZEOF(m_proto->m_portStart));
-	GetDlgItemTextA( m_hwnd, IDC_PORT2,  m_proto->m_portEnd,    SIZEOF(m_proto->m_portEnd));
-	GetDlgItemTextA( m_hwnd, IDC_PASS,   m_proto->m_password,   SIZEOF(m_proto->m_password));
-	
+	GetDlgItemTextA(m_hwnd, IDC_SERVER, m_proto->m_serverName, SIZEOF(m_proto->m_serverName));
+	GetDlgItemTextA(m_hwnd, IDC_PORT, m_proto->m_portStart, SIZEOF(m_proto->m_portStart));
+	GetDlgItemTextA(m_hwnd, IDC_PORT2, m_proto->m_portEnd, SIZEOF(m_proto->m_portEnd));
+	GetDlgItemTextA(m_hwnd, IDC_PASS, m_proto->m_password, SIZEOF(m_proto->m_password));
+
 	int i = m_serverCombo.GetCurSel();
-	SERVER_INFO* pData = ( SERVER_INFO* )m_serverCombo.GetItemData( i );
-	if ( pData && (INT_PTR)pData != CB_ERR ) {
-		lstrcpyA( m_proto->m_network, pData->m_group ); 
+	SERVER_INFO* pData = (SERVER_INFO*)m_serverCombo.GetItemData(i);
+	if (pData && (INT_PTR)pData != CB_ERR) {
+		lstrcpyA(m_proto->m_network, pData->m_group);
 		pData->m_iSSL = 0;
-		if ( IsDlgButtonChecked( m_hwnd, IDC_SSL_ON ))
+		if (IsDlgButtonChecked(m_hwnd, IDC_SSL_ON))
 			pData->m_iSSL = 2;
-		if ( IsDlgButtonChecked( m_hwnd, IDC_SSL_AUTO ))
+		if (IsDlgButtonChecked(m_hwnd, IDC_SSL_AUTO))
 			pData->m_iSSL = 1;
 		m_proto->m_iSSL = pData->m_iSSL;
 	}
-	
+
 	TCHAR windowname[20];
-	GetWindowText( m_hwnd, windowname, 20);
-	if ( lstrcmpi(windowname, _T("Miranda IRC")) == 0 ) {
+	GetWindowText(m_hwnd, windowname, 20);
+	if (lstrcmpi(windowname, _T("Miranda IRC")) == 0) {
 		m_proto->m_serverComboSelection = m_serverCombo.GetCurSel() - 1;
-		m_proto->setDword("ServerComboSelection",m_proto->m_serverComboSelection);
-		m_proto->setString("ServerName",m_proto->m_serverName);
-		m_proto->setString("PortStart",m_proto->m_portStart);
-		m_proto->setString("PortEnd",m_proto->m_portEnd);
-		m_proto->setString("Password",m_proto->m_password);
-		m_proto->setString("Network",m_proto->m_network);
-		m_proto->setByte("UseSSL",m_proto->m_iSSL);
+		m_proto->setDword("ServerComboSelection", m_proto->m_serverComboSelection);
+		m_proto->setString("ServerName", m_proto->m_serverName);
+		m_proto->setString("PortStart", m_proto->m_portStart);
+		m_proto->setString("PortEnd", m_proto->m_portEnd);
+		m_proto->setString("Password", m_proto->m_password);
+		m_proto->setString("Network", m_proto->m_network);
+		m_proto->setByte("UseSSL", m_proto->m_iSSL);
 	}
 	m_proto->m_quickComboSelection = m_serverCombo.GetCurSel();
-	m_proto->setDword("QuickComboSelection",m_proto->m_quickComboSelection);
+	m_proto->setDword("QuickComboSelection", m_proto->m_quickComboSelection);
 	m_proto->DisconnectFromServer();
 	m_proto->ConnectToServer();
 }
@@ -657,278 +664,282 @@ void CQuickDlg::OnOk( CCtrlButton* )
 void CQuickDlg::OnServerCombo(CCtrlData*)
 {
 	int i = m_serverCombo.GetCurSel();
-	if ( i == CB_ERR )
+	if (i == CB_ERR)
 		return;
 
-	SERVER_INFO* pData = ( SERVER_INFO* )m_serverCombo.GetItemData( i );
-	SetDlgItemTextA( m_hwnd, IDC_SERVER, pData->m_address );
-	SetDlgItemTextA( m_hwnd, IDC_PASS,   "" );
-	SetDlgItemInt( m_hwnd, IDC_PORT,   pData->m_portStart, FALSE );
-	SetDlgItemInt( m_hwnd, IDC_PORT2,  pData->m_portEnd, FALSE );
+	SERVER_INFO* pData = (SERVER_INFO*)m_serverCombo.GetItemData(i);
+	SetDlgItemTextA(m_hwnd, IDC_SERVER, pData->m_address);
+	SetDlgItemTextA(m_hwnd, IDC_PASS, "");
+	SetDlgItemInt(m_hwnd, IDC_PORT, pData->m_portStart, FALSE);
+	SetDlgItemInt(m_hwnd, IDC_PORT2, pData->m_portEnd, FALSE);
 
-	if ( pData->m_iSSL == 0 ) {
-		CheckDlgButton( m_hwnd, IDC_SSL_OFF,  BST_CHECKED );
-		CheckDlgButton( m_hwnd, IDC_SSL_AUTO, BST_UNCHECKED );
-		CheckDlgButton( m_hwnd, IDC_SSL_ON,   BST_UNCHECKED );
+	if (pData->m_iSSL == 0) {
+		CheckDlgButton(m_hwnd, IDC_SSL_OFF, BST_CHECKED);
+		CheckDlgButton(m_hwnd, IDC_SSL_AUTO, BST_UNCHECKED);
+		CheckDlgButton(m_hwnd, IDC_SSL_ON, BST_UNCHECKED);
 	}
-	if ( pData->m_iSSL == 1 ) {
-		CheckDlgButton( m_hwnd, IDC_SSL_AUTO, BST_CHECKED );
-		CheckDlgButton( m_hwnd, IDC_SSL_OFF,  BST_UNCHECKED );
-		CheckDlgButton( m_hwnd, IDC_SSL_ON,   BST_UNCHECKED );
+	if (pData->m_iSSL == 1) {
+		CheckDlgButton(m_hwnd, IDC_SSL_AUTO, BST_CHECKED);
+		CheckDlgButton(m_hwnd, IDC_SSL_OFF, BST_UNCHECKED);
+		CheckDlgButton(m_hwnd, IDC_SSL_ON, BST_UNCHECKED);
 	}
-	if ( pData->m_iSSL == 2 ) {
-		CheckDlgButton( m_hwnd, IDC_SSL_ON,   BST_CHECKED );
-		CheckDlgButton( m_hwnd, IDC_SSL_OFF,  BST_UNCHECKED );
-		CheckDlgButton( m_hwnd, IDC_SSL_AUTO, BST_UNCHECKED );
+	if (pData->m_iSSL == 2) {
+		CheckDlgButton(m_hwnd, IDC_SSL_ON, BST_CHECKED);
+		CheckDlgButton(m_hwnd, IDC_SSL_OFF, BST_UNCHECKED);
+		CheckDlgButton(m_hwnd, IDC_SSL_AUTO, BST_UNCHECKED);
 	}
 
-	if ( !strcmp( pData->m_name, Translate("---- Not listed server ----" ))) {
-		SendDlgItemMessage( m_hwnd, IDC_SERVER, EM_SETREADONLY, false, 0);
-		SendDlgItemMessage( m_hwnd, IDC_PORT,   EM_SETREADONLY, false, 0);
-		SendDlgItemMessage( m_hwnd, IDC_PORT2,  EM_SETREADONLY, false, 0);
-		EnableWindow(GetDlgItem( m_hwnd, IDC_SSL_OFF), TRUE);
-		EnableWindow(GetDlgItem( m_hwnd, IDC_SSL_AUTO),TRUE);
-		EnableWindow(GetDlgItem( m_hwnd, IDC_SSL_ON),  TRUE);
+	if (!strcmp(pData->m_name, Translate("---- Not listed server ----"))) {
+		SendDlgItemMessage(m_hwnd, IDC_SERVER, EM_SETREADONLY, false, 0);
+		SendDlgItemMessage(m_hwnd, IDC_PORT, EM_SETREADONLY, false, 0);
+		SendDlgItemMessage(m_hwnd, IDC_PORT2, EM_SETREADONLY, false, 0);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_SSL_OFF), TRUE);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_SSL_AUTO), TRUE);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_SSL_ON), TRUE);
 	}
 	else {
-		SendDlgItemMessage( m_hwnd, IDC_SERVER, EM_SETREADONLY, true, 0);
-		SendDlgItemMessage( m_hwnd, IDC_PORT,   EM_SETREADONLY, true, 0);
-		SendDlgItemMessage( m_hwnd, IDC_PORT2,  EM_SETREADONLY, true, 0);
-		EnableWindow(GetDlgItem( m_hwnd, IDC_SSL_OFF), FALSE);
-		EnableWindow(GetDlgItem( m_hwnd, IDC_SSL_AUTO),FALSE);
-		EnableWindow(GetDlgItem( m_hwnd, IDC_SSL_ON),  FALSE);
+		SendDlgItemMessage(m_hwnd, IDC_SERVER, EM_SETREADONLY, true, 0);
+		SendDlgItemMessage(m_hwnd, IDC_PORT, EM_SETREADONLY, true, 0);
+		SendDlgItemMessage(m_hwnd, IDC_PORT2, EM_SETREADONLY, true, 0);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_SSL_OFF), FALSE);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_SSL_AUTO), FALSE);
+		EnableWindow(GetDlgItem(m_hwnd, IDC_SSL_ON), FALSE);
 	}
 
-	EnableWindow(GetDlgItem( m_hwnd, IDOK), true);
+	EnableWindow(GetDlgItem(m_hwnd, IDOK), true);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
 // 'Question' dialog
 
-CQuestionDlg::CQuestionDlg(CIrcProto *_pro, CManagerDlg* owner ) :
-	CCoolIrcDlg( _pro, IDD_QUESTION, ( owner == NULL ) ? NULL : owner->GetHwnd()),
-	m_Ok( this, IDOK ),
-	m_owner( owner )
+CQuestionDlg::CQuestionDlg(CIrcProto *_pro, CManagerDlg* owner) :
+	CCoolIrcDlg(_pro, IDD_QUESTION, (owner == NULL) ? NULL : owner->GetHwnd()),
+	m_Ok(this, IDOK),
+	m_owner(owner)
 {
-	m_Ok.OnClick = Callback( this, &CQuestionDlg::OnOk );
+	m_Ok.OnClick = Callback(this, &CQuestionDlg::OnOk);
 }
 
 void CQuestionDlg::OnInitDialog()
 {
 	CCoolIrcDlg::OnInitDialog();
 
-	WindowSetIcon( m_hwnd, IDI_IRCQUESTION );
+	WindowSetIcon(m_hwnd, IDI_IRCQUESTION);
 }
 
 void CQuestionDlg::OnClose()
 {
-	if ( m_owner )
+	if (m_owner)
 		m_owner->CloseQuestion();
 }
 
-void CQuestionDlg::OnOk( CCtrlButton* )
+void CQuestionDlg::OnOk(CCtrlButton*)
 {
-	int i = GetWindowTextLength( GetDlgItem( m_hwnd, IDC_EDIT ));
-	if ( i > 0 ) {
-		TCHAR* l = new TCHAR[ i+2 ];
-		GetDlgItemText( m_hwnd, IDC_EDIT, l, i+1 );
+	int i = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_EDIT));
+	if (i > 0) {
+		TCHAR* l = new TCHAR[i + 2];
+		GetDlgItemText(m_hwnd, IDC_EDIT, l, i + 1);
 
-		int j = GetWindowTextLength(GetDlgItem( m_hwnd, IDC_HIDDENEDIT));
-		TCHAR* m = new TCHAR[ j+2 ];
-		GetDlgItemText( m_hwnd, IDC_HIDDENEDIT, m, j+1 );
+		int j = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_HIDDENEDIT));
+		TCHAR* m = new TCHAR[j + 2];
+		GetDlgItemText(m_hwnd, IDC_HIDDENEDIT, m, j + 1);
 
-		TCHAR* text = _tcsstr( m, _T("%question"));
+		TCHAR* text = _tcsstr(m, _T("%question"));
 		TCHAR* p1 = text;
 		TCHAR* p2 = NULL;
-		if ( p1 ) {
+		if (p1) {
 			p1 += 9;
-			if ( *p1 == '=' && p1[1] == '\"' ) {
+			if (*p1 == '=' && p1[1] == '\"') {
 				p1 += 2;
-				for ( int k =0; k < 3; k++ ) {
-					p2 = _tcschr( p1, '\"' );
-					if ( p2 ) {
+				for (int k = 0; k < 3; k++) {
+					p2 = _tcschr(p1, '\"');
+					if (p2) {
 						p2++;
-						if ( k == 2 || (*p2 != ',' || (*p2 == ',' && p2[1] != '\"')))
-							*p2 = '\0';	
+						if (k == 2 || (*p2 != ',' || (*p2 == ',' && p2[1] != '\"')))
+							*p2 = '\0';
 						else
 							p2 += 2;
 						p1 = p2;
-				}	}
+					}
+				}
 			}
 			else *p1 = '\0';
 		}
-		
-		TCHAR* n = ( TCHAR* )alloca( sizeof( TCHAR )*( j+2 ));
-		GetDlgItemText( m_hwnd, IDC_HIDDENEDIT, n, j+1 );
-		CMString S( n );
-		ReplaceString( S, text, l );
-		m_proto->PostIrcMessageWnd( NULL, NULL, (TCHAR*)S.c_str());
 
-		delete []m;
-		delete []l;
+		TCHAR* n = (TCHAR*)alloca(sizeof(TCHAR)*(j + 2));
+		GetDlgItemText(m_hwnd, IDC_HIDDENEDIT, n, j + 1);
+		CMString S(n);
+		ReplaceString(S, text, l);
+		m_proto->PostIrcMessageWnd(NULL, NULL, (TCHAR*)S.c_str());
+
+		delete[]m;
+		delete[]l;
 
-		if ( m_owner )
+		if (m_owner)
 			m_owner->ApplyQuestion();
-}	}
+	}
+}
 
 void CQuestionDlg::Activate()
 {
-	ShowWindow( m_hwnd, SW_SHOW );
-	SetActiveWindow( m_hwnd );
+	ShowWindow(m_hwnd, SW_SHOW);
+	SetActiveWindow(m_hwnd);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
 // 'Channel Manager' dialog
 
 CManagerDlg::CManagerDlg(CIrcProto *_pro) :
-	CCoolIrcDlg( _pro, IDD_CHANMANAGER ),
-	m_list( this, IDC_LIST ),
-
-	m_check1( this, IDC_CHECK1 ),
-	m_check2( this, IDC_CHECK2 ),
-	m_check3( this, IDC_CHECK3 ),
-	m_check4( this, IDC_CHECK4 ),
-	m_check5( this, IDC_CHECK5 ),
-	m_check6( this, IDC_CHECK6 ),
-	m_check7( this, IDC_CHECK7 ),
-	m_check8( this, IDC_CHECK8 ),
-	m_check9( this, IDC_CHECK9 ),
-
-	m_key( this, IDC_KEY ),
-	m_limit( this, IDC_LIMIT ),
-	m_topic( this, IDC_TOPIC ),
-
-	m_add( this, IDC_ADD, LoadIconEx(IDI_ADD), LPGEN("Add ban/invite/exception")),
-	m_edit( this, IDC_EDIT, LoadIconEx(IDI_EDIT), LPGEN("Edit selected ban/invite/exception")),
-	m_remove( this, IDC_REMOVE, LoadIconEx(IDI_DELETE), LPGEN("Delete selected ban/invite/exception")),
-	m_applyModes( this, IDC_APPLYMODES, LoadIconEx( IDI_APPLY ), LPGEN("Set these modes for the channel")),
-	m_applyTopic( this, IDC_APPLYTOPIC, LoadIconEx( IDI_APPLY ), LPGEN("Set this topic for the channel")),
-
-	m_radio1( this, IDC_RADIO1 ),
-	m_radio2( this, IDC_RADIO2 ),
-	m_radio3( this, IDC_RADIO3 )
-{
-	m_add.OnClick = Callback( this, &CManagerDlg::OnAdd );
-	m_edit.OnClick = Callback( this, &CManagerDlg::OnEdit );
-	m_remove.OnClick = Callback( this, &CManagerDlg::OnRemove );
-
-	m_applyModes.OnClick = Callback( this, &CManagerDlg::OnApplyModes );
-	m_applyTopic.OnClick = Callback( this, &CManagerDlg::OnApplyTopic );
-
-	m_check1.OnChange = Callback( this, &CManagerDlg::OnCheck );
-	m_check2.OnChange = Callback( this, &CManagerDlg::OnCheck );
-	m_check3.OnChange = Callback( this, &CManagerDlg::OnCheck );
-	m_check4.OnChange = Callback( this, &CManagerDlg::OnCheck );
-	m_check5.OnChange = Callback( this, &CManagerDlg::OnCheck5 );
-	m_check6.OnChange = Callback( this, &CManagerDlg::OnCheck6 );
-	m_check7.OnChange = Callback( this, &CManagerDlg::OnCheck );
-	m_check8.OnChange = Callback( this, &CManagerDlg::OnCheck );
-	m_check9.OnChange = Callback( this, &CManagerDlg::OnCheck );
-
-	m_key.OnChange = Callback( this, &CManagerDlg::OnChangeModes );
-	m_limit.OnChange = Callback( this, &CManagerDlg::OnChangeModes );
-	m_topic.OnChange = Callback( this, &CManagerDlg::OnChangeTopic );
-
-	m_radio1.OnChange = Callback( this, &CManagerDlg::OnRadio );
-	m_radio2.OnChange = Callback( this, &CManagerDlg::OnRadio );
-	m_radio3.OnChange = Callback( this, &CManagerDlg::OnRadio );
-
-	m_list.OnDblClick = Callback( this, &CManagerDlg::OnListDblClick );
-	m_list.OnSelChange = Callback( this, &CManagerDlg::OnChangeList );
-}
-
-LRESULT CALLBACK MgrEditSubclassProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
-{ 
-	switch( msg ) { 
-	case WM_CHAR :
-		if ( wParam == 21 || wParam == 11 || wParam == 2 ) {
+	CCoolIrcDlg(_pro, IDD_CHANMANAGER),
+	m_list(this, IDC_LIST),
+
+	m_check1(this, IDC_CHECK1),
+	m_check2(this, IDC_CHECK2),
+	m_check3(this, IDC_CHECK3),
+	m_check4(this, IDC_CHECK4),
+	m_check5(this, IDC_CHECK5),
+	m_check6(this, IDC_CHECK6),
+	m_check7(this, IDC_CHECK7),
+	m_check8(this, IDC_CHECK8),
+	m_check9(this, IDC_CHECK9),
+
+	m_key(this, IDC_KEY),
+	m_limit(this, IDC_LIMIT),
+	m_topic(this, IDC_TOPIC),
+
+	m_add(this, IDC_ADD, LoadIconEx(IDI_ADD), LPGEN("Add ban/invite/exception")),
+	m_edit(this, IDC_EDIT, LoadIconEx(IDI_EDIT), LPGEN("Edit selected ban/invite/exception")),
+	m_remove(this, IDC_REMOVE, LoadIconEx(IDI_DELETE), LPGEN("Delete selected ban/invite/exception")),
+	m_applyModes(this, IDC_APPLYMODES, LoadIconEx(IDI_APPLY), LPGEN("Set these modes for the channel")),
+	m_applyTopic(this, IDC_APPLYTOPIC, LoadIconEx(IDI_APPLY), LPGEN("Set this topic for the channel")),
+
+	m_radio1(this, IDC_RADIO1),
+	m_radio2(this, IDC_RADIO2),
+	m_radio3(this, IDC_RADIO3)
+{
+	m_add.OnClick = Callback(this, &CManagerDlg::OnAdd);
+	m_edit.OnClick = Callback(this, &CManagerDlg::OnEdit);
+	m_remove.OnClick = Callback(this, &CManagerDlg::OnRemove);
+
+	m_applyModes.OnClick = Callback(this, &CManagerDlg::OnApplyModes);
+	m_applyTopic.OnClick = Callback(this, &CManagerDlg::OnApplyTopic);
+
+	m_check1.OnChange = Callback(this, &CManagerDlg::OnCheck);
+	m_check2.OnChange = Callback(this, &CManagerDlg::OnCheck);
+	m_check3.OnChange = Callback(this, &CManagerDlg::OnCheck);
+	m_check4.OnChange = Callback(this, &CManagerDlg::OnCheck);
+	m_check5.OnChange = Callback(this, &CManagerDlg::OnCheck5);
+	m_check6.OnChange = Callback(this, &CManagerDlg::OnCheck6);
+	m_check7.OnChange = Callback(this, &CManagerDlg::OnCheck);
+	m_check8.OnChange = Callback(this, &CManagerDlg::OnCheck);
+	m_check9.OnChange = Callback(this, &CManagerDlg::OnCheck);
+
+	m_key.OnChange = Callback(this, &CManagerDlg::OnChangeModes);
+	m_limit.OnChange = Callback(this, &CManagerDlg::OnChangeModes);
+	m_topic.OnChange = Callback(this, &CManagerDlg::OnChangeTopic);
+
+	m_radio1.OnChange = Callback(this, &CManagerDlg::OnRadio);
+	m_radio2.OnChange = Callback(this, &CManagerDlg::OnRadio);
+	m_radio3.OnChange = Callback(this, &CManagerDlg::OnRadio);
+
+	m_list.OnDblClick = Callback(this, &CManagerDlg::OnListDblClick);
+	m_list.OnSelChange = Callback(this, &CManagerDlg::OnChangeList);
+}
+
+LRESULT CALLBACK MgrEditSubclassProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	switch (msg) {
+	case WM_CHAR:
+		if (wParam == 21 || wParam == 11 || wParam == 2) {
 			char w[2];
-			if ( wParam == 11 ) {
+			if (wParam == 11) {
 				w[0] = 3;
 				w[1] = '\0';
 			}
-			if ( wParam == 2 ) {
+			if (wParam == 2) {
 				w[0] = 2;
 				w[1] = '\0';
 			}
-			if ( wParam == 21 ) {
+			if (wParam == 21) {
 				w[0] = 31;
 				w[1] = '\0';
 			}
-			SendMessage( m_hwnd, EM_REPLACESEL, false, (LPARAM) w);
-			SendMessage( m_hwnd, EM_SCROLLCARET, 0, 0 );
+			SendMessage(m_hwnd, EM_REPLACESEL, false, (LPARAM)w);
+			SendMessage(m_hwnd, EM_SCROLLCARET, 0, 0);
 			return 0;
 		}
 		break;
-	} 
+	}
 
-	return mir_callNextSubclass(m_hwnd, MgrEditSubclassProc, msg, wParam, lParam); 
-} 
+	return mir_callNextSubclass(m_hwnd, MgrEditSubclassProc, msg, wParam, lParam);
+}
 
 void CManagerDlg::OnInitDialog()
 {
 	CCoolIrcDlg::OnInitDialog();
 
 	POINT pt;
-	pt.x = 3; 
-	pt.y = 3; 
-	HWND hwndEdit = ChildWindowFromPoint( m_topic.GetHwnd(), pt); 
-	mir_subclassWindow(hwndEdit, MgrEditSubclassProc); 
-	
-	WindowSetIcon( m_hwnd, IDI_MANAGER );
+	pt.x = 3;
+	pt.y = 3;
+	HWND hwndEdit = ChildWindowFromPoint(m_topic.GetHwnd(), pt);
+	mir_subclassWindow(hwndEdit, MgrEditSubclassProc);
 
-	m_list.SendMsg( LB_SETHORIZONTALEXTENT, 750, NULL );
-	m_radio1.SetState( true );
+	WindowSetIcon(m_hwnd, IDI_MANAGER);
+
+	m_list.SendMsg(LB_SETHORIZONTALEXTENT, 750, NULL);
+	m_radio1.SetState(true);
 
 	const char* modes = m_proto->sChannelModes.c_str();
-	if ( !strchr( modes, 't')) m_check1.Disable();
-	if ( !strchr( modes, 'n')) m_check2.Disable();
-	if ( !strchr( modes, 'i')) m_check3.Disable();
-	if ( !strchr( modes, 'm')) m_check4.Disable();
-	if ( !strchr( modes, 'k')) m_check5.Disable();
-	if ( !strchr( modes, 'l')) m_check6.Disable();
-	if ( !strchr( modes, 'p')) m_check7.Disable();
-	if ( !strchr( modes, 's')) m_check8.Disable();
-	if ( !strchr( modes, 'c')) m_check9.Disable();
+	if (!strchr(modes, 't')) m_check1.Disable();
+	if (!strchr(modes, 'n')) m_check2.Disable();
+	if (!strchr(modes, 'i')) m_check3.Disable();
+	if (!strchr(modes, 'm')) m_check4.Disable();
+	if (!strchr(modes, 'k')) m_check5.Disable();
+	if (!strchr(modes, 'l')) m_check6.Disable();
+	if (!strchr(modes, 'p')) m_check7.Disable();
+	if (!strchr(modes, 's')) m_check8.Disable();
+	if (!strchr(modes, 'c')) m_check9.Disable();
 }
 
 void CManagerDlg::OnClose()
 {
-	if ( m_applyModes.Enabled() || m_applyTopic.Enabled()) {
-		int i = MessageBox( NULL, TranslateT("You have not applied all changes!\n\nApply before exiting?"), TranslateT("IRC warning"), MB_YESNOCANCEL|MB_ICONWARNING|MB_DEFBUTTON3);
-		if ( i == IDCANCEL ) {
+	if (m_applyModes.Enabled() || m_applyTopic.Enabled()) {
+		int i = MessageBox(NULL, TranslateT("You have not applied all changes!\n\nApply before exiting?"), TranslateT("IRC warning"), MB_YESNOCANCEL | MB_ICONWARNING | MB_DEFBUTTON3);
+		if (i == IDCANCEL) {
 			m_lresult = TRUE;
 			return;
 		}
 
-		if ( i == IDYES ) {
-			if ( m_applyModes.Enabled())
-				OnApplyModes( NULL );
-			if ( m_applyTopic.Enabled())
-				OnApplyTopic( NULL );
-	}	}
+		if (i == IDYES) {
+			if (m_applyModes.Enabled())
+				OnApplyModes(NULL);
+			if (m_applyTopic.Enabled())
+				OnApplyTopic(NULL);
+		}
+	}
 
 	TCHAR window[256];
-	GetDlgItemText( m_hwnd, IDC_CAPTION, window, 255 );
+	GetDlgItemText(m_hwnd, IDC_CAPTION, window, 255);
 	CMString S = _T("");
 	TCHAR temp[1000];
-	for ( int i = 0; i < 5; i++ ) {
-		if ( m_topic.SendMsg( CB_GETLBTEXT, i, (LPARAM)temp) != LB_ERR) {
+	for (int i = 0; i < 5; i++) {
+		if (m_topic.SendMsg(CB_GETLBTEXT, i, (LPARAM)temp) != LB_ERR) {
 			CMString S1 = temp;
-/* FIXME: What the hell does it mean!? GCC won't compile this on UNICODE */
+			/* FIXME: What the hell does it mean!? GCC won't compile this on UNICODE */
 #if !defined(__GNUC__) || !defined(UNICODE)
-			ReplaceString( S1, _T(" "), _T("%�"));
+			ReplaceString(S1, _T(" "), _T("%�"));
 #endif
 			S += _T(" ") + S1;
-	}	}
+		}
+	}
 
-	if ( !S.IsEmpty() && m_proto->IsConnected()) {
-		mir_sntprintf( temp, SIZEOF(temp), _T("Topic%s%s"), window, m_proto->m_info.sNetwork.c_str());
+	if (!S.IsEmpty() && m_proto->IsConnected()) {
+		mir_sntprintf(temp, SIZEOF(temp), _T("Topic%s%s"), window, m_proto->m_info.sNetwork.c_str());
 		char* p = mir_t2a(temp);
 		m_proto->setTString(p, S.c_str());
 		mir_free(p);
 	}
-	DestroyWindow( m_hwnd);
+	DestroyWindow(m_hwnd);
 }
 
 void CManagerDlg::OnDestroy()
@@ -937,66 +948,66 @@ void CManagerDlg::OnDestroy()
 	m_proto->m_managerDlg = NULL;
 }
 
-void CManagerDlg::OnAdd( CCtrlButton* )
+void CManagerDlg::OnAdd(CCtrlButton*)
 {
 	TCHAR temp[100];
 	TCHAR mode[3];
-	if ( m_radio1.GetState()) {
-		lstrcpy( mode, _T("+b"));
-		lstrcpyn( temp, TranslateT("Add ban"), 100 );
+	if (m_radio1.GetState()) {
+		lstrcpy(mode, _T("+b"));
+		lstrcpyn(temp, TranslateT("Add ban"), 100);
 	}
-	if ( m_radio2.GetState()) {
-		lstrcpy( mode, _T("+I"));
-		lstrcpyn( temp, TranslateT("Add invite"), 100 );
+	if (m_radio2.GetState()) {
+		lstrcpy(mode, _T("+I"));
+		lstrcpyn(temp, TranslateT("Add invite"), 100);
 	}
-	if ( m_radio3.GetState()) {
-		lstrcpy( mode, _T("+e"));
-		lstrcpyn( temp, TranslateT("Add exception"), 100);
+	if (m_radio3.GetState()) {
+		lstrcpy(mode, _T("+e"));
+		lstrcpyn(temp, TranslateT("Add exception"), 100);
 	}
 
 	m_add.Disable();
 	m_edit.Disable();
 	m_remove.Disable();
 
-	CQuestionDlg* dlg = new CQuestionDlg( m_proto, this );
+	CQuestionDlg* dlg = new CQuestionDlg(m_proto, this);
 	dlg->Show();
 	HWND addban_hWnd = dlg->GetHwnd();
 	SetDlgItemText(addban_hWnd, IDC_CAPTION, temp);
 	SetWindowText(GetDlgItem(addban_hWnd, IDC_TEXT), TranslateT("Please enter the hostmask (nick!user@host)"));
-	
+
 	TCHAR temp2[450];
 	TCHAR window[256];
-	GetDlgItemText( m_hwnd, IDC_CAPTION, window, SIZEOF(window));
+	GetDlgItemText(m_hwnd, IDC_CAPTION, window, SIZEOF(window));
 	mir_sntprintf(temp2, 450, _T("/MODE %s %s %s"), window, mode, _T("%question"));
 	SetDlgItemText(addban_hWnd, IDC_HIDDENEDIT, temp2);
 	dlg->Activate();
 }
 
-void CManagerDlg::OnEdit( CCtrlButton* )
+void CManagerDlg::OnEdit(CCtrlButton*)
 {
-	if ( !IsDlgButtonChecked( m_hwnd, IDC_NOTOP )) {
+	if (!IsDlgButtonChecked(m_hwnd, IDC_NOTOP)) {
 		int i = m_list.GetCurSel();
-		if ( i != LB_ERR ) {
-			TCHAR* m = m_list.GetItemText( i );
+		if (i != LB_ERR) {
+			TCHAR* m = m_list.GetItemText(i);
 			CMString user = GetWord(m, 0);
-			mir_free( m );
-			
+			mir_free(m);
+
 			TCHAR temp[100];
 			TCHAR mode[3];
-			if ( m_radio1.GetState()) {
-				lstrcpy( mode, _T("b"));
-				lstrcpyn( temp, TranslateT("Edit ban"), 100 );
+			if (m_radio1.GetState()) {
+				lstrcpy(mode, _T("b"));
+				lstrcpyn(temp, TranslateT("Edit ban"), 100);
 			}
-			if ( m_radio2.GetState()) {
-				lstrcpy( mode, _T("I"));
-				lstrcpyn( temp, TranslateT("Edit invite?"), 100 );
+			if (m_radio2.GetState()) {
+				lstrcpy(mode, _T("I"));
+				lstrcpyn(temp, TranslateT("Edit invite?"), 100);
 			}
-			if ( m_radio3.GetState()) {
-				lstrcpy( mode, _T("e"));
-				lstrcpyn( temp, TranslateT("Edit exception?"), 100 );
+			if (m_radio3.GetState()) {
+				lstrcpy(mode, _T("e"));
+				lstrcpyn(temp, TranslateT("Edit exception?"), 100);
 			}
-				
-			CQuestionDlg* dlg = new CQuestionDlg( m_proto, this );
+
+			CQuestionDlg* dlg = new CQuestionDlg(m_proto, this);
 			dlg->Show();
 			HWND addban_hWnd = dlg->GetHwnd();
 			SetDlgItemText(addban_hWnd, IDC_CAPTION, temp);
@@ -1009,57 +1020,61 @@ void CManagerDlg::OnEdit( CCtrlButton* )
 
 			TCHAR temp2[450];
 			TCHAR window[256];
-			GetDlgItemText( m_hwnd, IDC_CAPTION, window, SIZEOF(window));
+			GetDlgItemText(m_hwnd, IDC_CAPTION, window, SIZEOF(window));
 			mir_sntprintf(temp2, 450, _T("/MODE %s -%s %s%s/MODE %s +%s %s"), window, mode, user.c_str(), _T("%newl"), window, mode, _T("%question"));
 			SetDlgItemText(addban_hWnd, IDC_HIDDENEDIT, temp2);
 			dlg->Activate();
-}	}	}
+		}
+	}
+}
 
-void CManagerDlg::OnRemove( CCtrlButton* )
+void CManagerDlg::OnRemove(CCtrlButton*)
 {
 	int i = m_list.GetCurSel();
-	if ( i != LB_ERR ) {
+	if (i != LB_ERR) {
 		m_add.Disable();
 		m_edit.Disable();
 		m_remove.Disable();
 
 		TCHAR temp[100], mode[3];
-		TCHAR* m = m_list.GetItemText( i, temp, SIZEOF( temp ));
+		TCHAR* m = m_list.GetItemText(i, temp, SIZEOF(temp));
 		CMString user = GetWord(m, 0);
-		
-		if ( m_radio1.GetState()) {
+
+		if (m_radio1.GetState()) {
 			lstrcpy(mode, _T("-b"));
-			lstrcpyn(temp, TranslateT( "Remove ban?" ), 100 );
+			lstrcpyn(temp, TranslateT("Remove ban?"), 100);
 		}
-		if ( m_radio2.GetState()) {
+		if (m_radio2.GetState()) {
 			lstrcpy(mode, _T("-I"));
-			lstrcpyn(temp, TranslateT( "Remove invite?" ), 100 );
+			lstrcpyn(temp, TranslateT("Remove invite?"), 100);
 		}
-		if ( m_radio3.GetState()) {
+		if (m_radio3.GetState()) {
 			lstrcpy(mode, _T("-e"));
-			lstrcpyn(temp, TranslateT( "Remove exception?" ), 100 );
+			lstrcpyn(temp, TranslateT("Remove exception?"), 100);
 		}
-		
+
 		TCHAR window[256];
-		GetDlgItemText( m_hwnd, IDC_CAPTION, window, SIZEOF(window));
-		if ( MessageBox( m_hwnd, user.c_str(), temp, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 ) == IDYES ) {
-			m_proto->PostIrcMessage( _T("/MODE %s %s %s"), window, mode, user.c_str());
+		GetDlgItemText(m_hwnd, IDC_CAPTION, window, SIZEOF(window));
+		if (MessageBox(m_hwnd, user.c_str(), temp, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES) {
+			m_proto->PostIrcMessage(_T("/MODE %s %s %s"), window, mode, user.c_str());
 			ApplyQuestion();
 		}
 		CloseQuestion();
-}	}
+	}
+}
 
-void CManagerDlg::OnListDblClick( CCtrlListBox* )
+void CManagerDlg::OnListDblClick(CCtrlListBox*)
 {
-	OnEdit( NULL );
+	OnEdit(NULL);
 }
 
-void CManagerDlg::OnChangeList( CCtrlListBox* )
+void CManagerDlg::OnChangeList(CCtrlListBox*)
 {
-	if ( !IsDlgButtonChecked( m_hwnd, IDC_NOTOP )) {
+	if (!IsDlgButtonChecked(m_hwnd, IDC_NOTOP)) {
 		m_edit.Enable();
 		m_remove.Enable();
-}	}
+	}
+}
 
 void CManagerDlg::OnChangeModes(CCtrlData*)
 {
@@ -1071,143 +1086,146 @@ void CManagerDlg::OnChangeTopic(CCtrlData*)
 	m_applyTopic.Enable();
 }
 
-void CManagerDlg::OnApplyModes( CCtrlButton* )
+void CManagerDlg::OnApplyModes(CCtrlButton*)
 {
 	TCHAR window[256];
-	GetDlgItemText( m_hwnd, IDC_CAPTION, window, SIZEOF(window));
+	GetDlgItemText(m_hwnd, IDC_CAPTION, window, SIZEOF(window));
 	CHANNELINFO *wi = (CHANNELINFO *)m_proto->DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
-	if ( wi ) {
+	if (wi) {
 		TCHAR toadd[10]; *toadd = '\0';
 		TCHAR toremove[10]; *toremove = '\0';
 		CMString appendixadd = _T("");
 		CMString appendixremove = _T("");
-		if ( wi->pszMode && _tcschr( wi->pszMode, 't' )) {
-			if ( !m_check1.GetState())
-				lstrcat( toremove, _T("t"));
+		if (wi->pszMode && _tcschr(wi->pszMode, 't')) {
+			if (!m_check1.GetState())
+				lstrcat(toremove, _T("t"));
 		}
-		else if ( m_check1.GetState())
-			lstrcat( toadd, _T("t"));
+		else if (m_check1.GetState())
+			lstrcat(toadd, _T("t"));
 
-		if ( wi->pszMode && _tcschr( wi->pszMode, 'n' )) {
-			if ( !m_check2.GetState())
-				lstrcat( toremove, _T("n"));
+		if (wi->pszMode && _tcschr(wi->pszMode, 'n')) {
+			if (!m_check2.GetState())
+				lstrcat(toremove, _T("n"));
 		}
-		else if ( m_check2.GetState())
-			lstrcat( toadd, _T("n"));
+		else if (m_check2.GetState())
+			lstrcat(toadd, _T("n"));
 
-		if ( wi->pszMode && _tcschr( wi->pszMode, 'i' )) {
-			if ( !m_check3.GetState())
-				lstrcat( toremove, _T("i"));
+		if (wi->pszMode && _tcschr(wi->pszMode, 'i')) {
+			if (!m_check3.GetState())
+				lstrcat(toremove, _T("i"));
 		}
-		else if ( m_check3.GetState())
-			lstrcat( toadd, _T("i"));
+		else if (m_check3.GetState())
+			lstrcat(toadd, _T("i"));
 
-		if ( wi->pszMode && _tcschr( wi->pszMode, 'm' )) {
-			if ( !m_check4.GetState())
-				lstrcat( toremove, _T("m"));
+		if (wi->pszMode && _tcschr(wi->pszMode, 'm')) {
+			if (!m_check4.GetState())
+				lstrcat(toremove, _T("m"));
 		}
-		else if ( m_check4.GetState())
-			lstrcat( toadd, _T("m"));
+		else if (m_check4.GetState())
+			lstrcat(toadd, _T("m"));
 
-		if ( wi->pszMode && _tcschr( wi->pszMode, 'p' )) {
-			if ( !m_check7.GetState())
-				lstrcat( toremove, _T("p"));
+		if (wi->pszMode && _tcschr(wi->pszMode, 'p')) {
+			if (!m_check7.GetState())
+				lstrcat(toremove, _T("p"));
 		}
-		else if ( m_check7.GetState())
-			lstrcat( toadd, _T("p"));
+		else if (m_check7.GetState())
+			lstrcat(toadd, _T("p"));
 
-		if ( wi->pszMode && _tcschr( wi->pszMode, 's' )) {
-			if ( !m_check8.GetState())
-				lstrcat( toremove, _T("s"));
+		if (wi->pszMode && _tcschr(wi->pszMode, 's')) {
+			if (!m_check8.GetState())
+				lstrcat(toremove, _T("s"));
 		}
-		else if ( m_check8.GetState())
-			lstrcat( toadd, _T("s"));
+		else if (m_check8.GetState())
+			lstrcat(toadd, _T("s"));
 
-		if ( wi->pszMode && _tcschr( wi->pszMode, 'c' )) {
-			if ( !m_check9.GetState())
-				lstrcat( toremove, _T("c"));
+		if (wi->pszMode && _tcschr(wi->pszMode, 'c')) {
+			if (!m_check9.GetState())
+				lstrcat(toremove, _T("c"));
 		}
-		else if ( m_check9.GetState())
-			lstrcat( toadd, _T("c"));
+		else if (m_check9.GetState())
+			lstrcat(toadd, _T("c"));
 
 		CMString Key = _T("");
 		CMString Limit = _T("");
-		if ( wi->pszMode && wi->pszPassword && _tcschr( wi->pszMode, 'k' )) {
-			if ( !m_check5.GetState()) {
-				lstrcat( toremove, _T("k"));
+		if (wi->pszMode && wi->pszPassword && _tcschr(wi->pszMode, 'k')) {
+			if (!m_check5.GetState()) {
+				lstrcat(toremove, _T("k"));
 				appendixremove += _T(" ") + CMString(wi->pszPassword);
 			}
-			else if ( GetWindowTextLength( m_key.GetHwnd())) {
+			else if (GetWindowTextLength(m_key.GetHwnd())) {
 				TCHAR temp[400];
-				m_key.GetText( temp, 14);
+				m_key.GetText(temp, 14);
 
-				if ( Key != temp ) {
-					lstrcat( toremove, _T("k"));
-					lstrcat( toadd, _T("k"));
+				if (Key != temp) {
+					lstrcat(toremove, _T("k"));
+					lstrcat(toadd, _T("k"));
 					appendixadd += _T(" ") + CMString(temp);
 					appendixremove += _T(" ") + CMString(wi->pszPassword);
-			}	}
+				}
+			}
 		}
-		else if ( m_check5.GetState() && GetWindowTextLength( m_key.GetHwnd())) {
-			lstrcat( toadd, _T("k"));
+		else if (m_check5.GetState() && GetWindowTextLength(m_key.GetHwnd())) {
+			lstrcat(toadd, _T("k"));
 			appendixadd += _T(" ");
-			
+
 			TCHAR temp[400];
-			m_key.GetText( temp, SIZEOF(temp));
+			m_key.GetText(temp, SIZEOF(temp));
 			appendixadd += temp;
 		}
 
-		if ( _tcschr( wi->pszMode, 'l' )) {
-			if ( !m_check6.GetState())
-				lstrcat( toremove, _T("l"));
-			else if ( GetWindowTextLength( GetDlgItem( m_hwnd, IDC_LIMIT ))) {
+		if (_tcschr(wi->pszMode, 'l')) {
+			if (!m_check6.GetState())
+				lstrcat(toremove, _T("l"));
+			else if (GetWindowTextLength(GetDlgItem(m_hwnd, IDC_LIMIT))) {
 				TCHAR temp[15];
-				GetDlgItemText( m_hwnd, IDC_LIMIT, temp, SIZEOF(temp));
-				if ( wi->pszLimit && lstrcmpi( wi->pszLimit, temp )) {
-					lstrcat( toadd, _T("l"));
+				GetDlgItemText(m_hwnd, IDC_LIMIT, temp, SIZEOF(temp));
+				if (wi->pszLimit && lstrcmpi(wi->pszLimit, temp)) {
+					lstrcat(toadd, _T("l"));
 					appendixadd += _T(" ") + CMString(temp);
-			}	}
+				}
+			}
 		}
-		else if ( m_check6.GetState() && GetWindowTextLength( m_limit.GetHwnd())) {
-			lstrcat( toadd, _T("l"));
+		else if (m_check6.GetState() && GetWindowTextLength(m_limit.GetHwnd())) {
+			lstrcat(toadd, _T("l"));
 			appendixadd += _T(" ");
-			
+
 			TCHAR temp[15];
-			m_limit.GetText( temp, SIZEOF(temp));
+			m_limit.GetText(temp, SIZEOF(temp));
 			appendixadd += temp;
 		}
 
-		if ( lstrlen(toadd) || lstrlen( toremove )) {
+		if (lstrlen(toadd) || lstrlen(toremove)) {
 			TCHAR temp[500];
 			lstrcpy(temp, _T("/mode "));
 			lstrcat(temp, window);
 			lstrcat(temp, _T(" "));
-			if ( lstrlen( toremove ))
-				mir_sntprintf( temp, 499, _T("%s-%s"), temp, toremove );
-			if ( lstrlen( toadd ))
-				mir_sntprintf( temp, 499, _T("%s+%s"), temp, toadd );
+			if (lstrlen(toremove))
+				mir_sntprintf(temp, 499, _T("%s-%s"), temp, toremove);
+			if (lstrlen(toadd))
+				mir_sntprintf(temp, 499, _T("%s+%s"), temp, toadd);
 			if (!appendixremove.IsEmpty())
 				lstrcat(temp, appendixremove.c_str());
 			if (!appendixadd.IsEmpty())
 				lstrcat(temp, appendixadd.c_str());
-			m_proto->PostIrcMessage( temp);
-	}	}
+			m_proto->PostIrcMessage(temp);
+		}
+	}
 
 	m_applyModes.Disable();
 }
 
-void CManagerDlg::OnApplyTopic( CCtrlButton* )
+void CManagerDlg::OnApplyTopic(CCtrlButton*)
 {
 	TCHAR temp[470];
 	TCHAR window[256];
-	GetDlgItemText( m_hwnd, IDC_CAPTION, window, SIZEOF(window));
-	m_topic.GetText( temp, SIZEOF(temp));
-	m_proto->PostIrcMessage( _T("/TOPIC %s %s"), window, temp);
-	int i = m_topic.SendMsg( CB_FINDSTRINGEXACT, -1, (LPARAM)temp);
-	if ( i != LB_ERR )
-		m_topic.SendMsg( CB_DELETESTRING, i, 0);
-	m_topic.SendMsg( CB_INSERTSTRING, 0, (LPARAM)temp);
-	m_topic.SetText( temp );
+	GetDlgItemText(m_hwnd, IDC_CAPTION, window, SIZEOF(window));
+	m_topic.GetText(temp, SIZEOF(temp));
+	m_proto->PostIrcMessage(_T("/TOPIC %s %s"), window, temp);
+	int i = m_topic.SendMsg(CB_FINDSTRINGEXACT, -1, (LPARAM)temp);
+	if (i != LB_ERR)
+		m_topic.SendMsg(CB_DELETESTRING, i, 0);
+	m_topic.SendMsg(CB_INSERTSTRING, 0, (LPARAM)temp);
+	m_topic.SetText(temp);
 	m_applyTopic.Disable();
 }
 
@@ -1218,13 +1236,13 @@ void CManagerDlg::OnCheck(CCtrlData*)
 
 void CManagerDlg::OnCheck5(CCtrlData*)
 {
-	m_key.Enable( m_check5.GetState());
+	m_key.Enable(m_check5.GetState());
 	m_applyModes.Enable();
 }
 
 void CManagerDlg::OnCheck6(CCtrlData*)
 {
-	m_limit.Enable( m_check6.GetState());				
+	m_limit.Enable(m_check6.GetState());
 	m_applyModes.Enable();
 }
 
@@ -1236,14 +1254,14 @@ void CManagerDlg::OnRadio(CCtrlData*)
 void CManagerDlg::ApplyQuestion()
 {
 	TCHAR window[256];
-	GetDlgItemText( m_hwnd, IDC_CAPTION, window, 255);
+	GetDlgItemText(m_hwnd, IDC_CAPTION, window, 255);
 
 	TCHAR mode[3];
-	lstrcpy( mode, _T("+b"));
-	if ( m_radio2.GetState())
-		lstrcpy( mode, _T("+I"));
-	if ( m_radio3.GetState())
-		lstrcpy( mode, _T("+e"));
+	lstrcpy(mode, _T("+b"));
+	if (m_radio2.GetState())
+		lstrcpy(mode, _T("+I"));
+	if (m_radio3.GetState())
+		lstrcpy(mode, _T("+e"));
 	m_list.ResetContent();
 	m_radio1.Disable();
 	m_radio2.Disable();
@@ -1251,87 +1269,89 @@ void CManagerDlg::ApplyQuestion()
 	m_add.Disable();
 	m_edit.Disable();
 	m_remove.Disable();
-	m_proto->PostIrcMessage( _T("%s %s %s"), _T("/MODE"), window, mode); //wrong overloaded operator if three args
+	m_proto->PostIrcMessage(_T("%s %s %s"), _T("/MODE"), window, mode); //wrong overloaded operator if three args
 }
 
 void CManagerDlg::CloseQuestion()
 {
 	m_add.Enable();
-	if ( m_list.GetCurSel() != LB_ERR) {
+	if (m_list.GetCurSel() != LB_ERR) {
 		m_edit.Enable();
 		m_remove.Enable();
-}	}
+	}
+}
 
-void CManagerDlg::InitManager( int mode, const TCHAR* window )
+void CManagerDlg::InitManager(int mode, const TCHAR* window)
 {
-	SetWindowText( GetDlgItem( m_hwnd, IDC_CAPTION ), window );
+	SetWindowText(GetDlgItem(m_hwnd, IDC_CAPTION), window);
 
 	CHANNELINFO *wi = (CHANNELINFO *)m_proto->DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
-	if ( wi ) {
-		if ( m_proto->IsConnected()) {
+	if (wi) {
+		if (m_proto->IsConnected()) {
 			TCHAR temp[1000];
 			mir_sntprintf(temp, SIZEOF(temp), _T("Topic%s%s"), window, m_proto->m_info.sNetwork.c_str());
 
 			char* p = mir_t2a(temp);
-			
+
 			DBVARIANT dbv;
-			if ( !m_proto->getTString( p, &dbv )) {
-				for ( int i = 0; i<5; i++ ) {
+			if (!m_proto->getTString(p, &dbv)) {
+				for (int i = 0; i < 5; i++) {
 					CMString S = GetWord(dbv.ptszVal, i);
-					if ( !S.IsEmpty()) {
+					if (!S.IsEmpty()) {
 /* FIXME: What the hell does it mean!? GCC won't compile this on UNICODE */
 #if !defined(__GNUC__) || !defined(UNICODE)
-						ReplaceString( S, _T("%�"), _T(" "));
+						ReplaceString(S, _T("%�"), _T(" "));
 #endif
-						m_topic.SendMsg( CB_ADDSTRING, 0, (LPARAM)S.c_str());
-				}	}
+						m_topic.SendMsg(CB_ADDSTRING, 0, (LPARAM)S.c_str());
+					}
+				}
 				db_free(&dbv);
 			}
 			mir_free(p);
 		}
 
-		if ( wi->pszTopic )
-			m_topic.SetText( wi->pszTopic );
+		if (wi->pszTopic)
+			m_topic.SetText(wi->pszTopic);
 
-		if ( !IsDlgButtonChecked( m_proto->m_managerDlg->GetHwnd(), IDC_NOTOP ))
+		if (!IsDlgButtonChecked(m_proto->m_managerDlg->GetHwnd(), IDC_NOTOP))
 			m_add.Enable();
 
 		bool add = false;
-		TCHAR* p1= wi->pszMode;
-		if ( p1 ) {
-			while ( *p1 != '\0' && *p1 != ' ' ) {
+		TCHAR* p1 = wi->pszMode;
+		if (p1) {
+			while (*p1 != '\0' && *p1 != ' ') {
 				if (*p1 == '+')
 					add = true;
 				if (*p1 == '-')
 					add = false;
 				if (*p1 == 't')
-					m_check1.SetState( add );
+					m_check1.SetState(add);
 				if (*p1 == 'n')
-					m_check2.SetState( add );
+					m_check2.SetState(add);
 				if (*p1 == 'i')
-					m_check3.SetState( add );
+					m_check3.SetState(add);
 				if (*p1 == 'm')
-					m_check4.SetState( add );
+					m_check4.SetState(add);
 				if (*p1 == 'p')
-					m_check7.SetState( add );
+					m_check7.SetState(add);
 				if (*p1 == 's')
-					m_check8.SetState( add );
+					m_check8.SetState(add);
 				if (*p1 == 'c')
-					m_check9.SetState( add );
+					m_check9.SetState(add);
 				if (*p1 == 'k' && add) {
-					m_check5.SetState( add );
-					m_key.Enable( add );
-					if ( wi->pszPassword )
-						m_key.SetText( wi->pszPassword );
+					m_check5.SetState(add);
+					m_key.Enable(add);
+					if (wi->pszPassword)
+						m_key.SetText(wi->pszPassword);
 				}
 				if (*p1 == 'l' && add) {
-					m_check6.SetState( add );
-					m_limit.Enable( add );
-					if ( wi->pszLimit )
-						m_limit.SetText( wi->pszLimit );
+					m_check6.SetState(add);
+					m_limit.Enable(add);
+					if (wi->pszLimit)
+						m_limit.SetText(wi->pszLimit);
 				}
 				p1++;
-				if ( mode == 0 ) {
+				if (mode == 0) {
 					m_limit.Disable();
 					m_key.Disable();
 					m_check1.Disable();
@@ -1344,17 +1364,18 @@ void CManagerDlg::InitManager( int mode, const TCHAR* window )
 					m_check8.Disable();
 					m_check9.Disable();
 					m_add.Disable();
-					if ( m_check1.GetState())
+					if (m_check1.GetState())
 						m_topic.Disable();
-					CheckDlgButton( m_hwnd, IDC_NOTOP, BST_CHECKED);
+					CheckDlgButton(m_hwnd, IDC_NOTOP, BST_CHECKED);
 				}
-				ShowWindow( m_hwnd, SW_SHOW );
+				ShowWindow(m_hwnd, SW_SHOW);
 	}	}	}
 
-	if ( strchr( m_proto->sChannelModes.c_str(), 'b' )) {
-		m_radio1.SetState( true );
-		m_proto->PostIrcMessage( _T("/MODE %s +b"), window);
-}	}
+	if (strchr(m_proto->sChannelModes.c_str(), 'b')) {
+		m_radio1.SetState(true);
+		m_proto->PostIrcMessage(_T("/MODE %s +b"), window);
+	}
+}
 
 /////////////////////////////////////////////////////////////////////////////////////////
 // 'cool' dialog
@@ -1366,22 +1387,22 @@ CCoolIrcDlg::CCoolIrcDlg( CIrcProto* _pro, int dlgId, HWND parent ) :
 
 void CCoolIrcDlg::OnInitDialog()
 {
-	HFONT hFont;
+	HFONT hFont = (HFONT)SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_GETFONT, 0, 0);
+
 	LOGFONT lf;
-	hFont=(HFONT)SendDlgItemMessage( m_hwnd,IDC_CAPTION,WM_GETFONT,0,0);
-	GetObject(hFont,sizeof(lf),&lf);
-	lf.lfHeight=(int)(lf.lfHeight*1.2);
-	lf.lfWeight=FW_BOLD;
-	hFont=CreateFontIndirect(&lf);
-	SendDlgItemMessage( m_hwnd,IDC_CAPTION,WM_SETFONT,(WPARAM)hFont,0);
+	GetObject(hFont, sizeof(lf), &lf);
+	lf.lfHeight = (int)(lf.lfHeight*1.2);
+	lf.lfWeight = FW_BOLD;
+	hFont = CreateFontIndirect(&lf);
+	SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_SETFONT, (WPARAM)hFont, 0);
 
-	SendDlgItemMessage( m_hwnd, IDC_LOGO, STM_SETICON,(LPARAM)(HICON)LoadIconEx(IDI_LOGO), 0);
+	SendDlgItemMessage(m_hwnd, IDC_LOGO, STM_SETICON, (LPARAM)(HICON)LoadIconEx(IDI_LOGO), 0);
 }
 
 void CCoolIrcDlg::OnDestroy()
 {
-	HFONT hFont = (HFONT)SendDlgItemMessage( m_hwnd,IDC_CAPTION,WM_GETFONT,0,0);
-	SendDlgItemMessage( m_hwnd,IDC_CAPTION,WM_SETFONT,SendDlgItemMessage( m_hwnd,IDOK,WM_GETFONT,0,0),0);
+	HFONT hFont = (HFONT)SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_GETFONT, 0, 0);
+	SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_SETFONT, SendDlgItemMessage(m_hwnd, IDOK, WM_GETFONT, 0, 0), 0);
 	DeleteObject(hFont);
 
 	ReleaseIconEx((HICON)SendDlgItemMessage(m_hwnd, IDC_LOGO, STM_SETICON, 0, 0));
@@ -1390,13 +1411,14 @@ void CCoolIrcDlg::OnDestroy()
 
 INT_PTR CCoolIrcDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
 {
-	if ( msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC ) {
-		switch( GetDlgCtrlID(( HWND )lParam )) {
+	if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) {
+		switch (GetDlgCtrlID((HWND)lParam)) {
 		case IDC_WHITERECT: case IDC_TEXT: case IDC_CAPTION: case IDC_AWAYTIME: case IDC_LOGO:
-			SetTextColor((HDC)wParam,RGB(0,0,0));
-			SetBkColor((HDC)wParam,RGB(255,255,255));
+			SetTextColor((HDC)wParam, RGB(0, 0, 0));
+			SetBkColor((HDC)wParam, RGB(255, 255, 255));
 			return (INT_PTR)GetStockObject(WHITE_BRUSH);
-	}	}
+		}
+	}
 
 	return CDlgBase::DlgProc(msg, wParam, lParam);
 }
-- 
cgit v1.2.3