Index: Unreal3.2.orig/include/h.h
===================================================================
--- Unreal3.2.orig.orig/include/h.h
+++ Unreal3.2.orig/include/h.h
@@ -29,6 +29,9 @@
 #ifndef NO_FDLIST
 #include "fdlist.h"
 #endif
+
+#include "splaytree.h"
+
 extern MODVAR char *extraflags;
 extern MODVAR int tainted;
 /* for the new s_err.c */
@@ -500,8 +503,8 @@ char	*Inet_ia2pNB(struct IN_ADDR *ia, in
 /*
  * CommandHash -Stskeeps
 */
-extern MODVAR aCommand *CommandHash[256];
-extern MODVAR aCommand *TokenHash[256];
+extern MODVAR SplayTree *CommandTree;
+extern MODVAR SplayTree *TokenTree;
 extern void	init_CommandHash(void);
 extern aCommand	*add_Command_backend(char *cmd, int (*func)(), unsigned char parameters, unsigned char token, int flags);
 extern void	add_Command(char *cmd, char *token, int (*func)(), unsigned char parameters);
Index: Unreal3.2.orig/src/api-command.c
===================================================================
--- Unreal3.2.orig.orig/src/api-command.c
+++ Unreal3.2.orig/src/api-command.c
@@ -30,16 +30,12 @@ int CommandExists(char *name)
 {
 	aCommand *p;
 	
-	for (p = CommandHash[toupper(*name)]; p; p = p->next)
-	{
-		if (!stricmp(p->cmd, name))
-			return 1;
-	}
-	for (p = TokenHash[*name]; p; p = p->next)
-	{
-		if (!strcmp(p->cmd, name))
-			return 1;
-	}
+	if ((p = splaytree_retrieve(CommandTree, name)) != NULL)
+		return 1;
+
+	if ((p = splaytree_retrieve(TokenTree, name)) != NULL)
+		return 1;
+
 	return 0;
 }
 
@@ -52,6 +48,7 @@ Command *CommandAdd(Module *module, char
 			module->errorcode = MODERR_EXISTS;
 		return NULL;
 	}
+
 	command = MyMallocEx(sizeof(Command));
 	command->cmd = add_Command_backend(cmd,func,params, 0, flags);
 	command->tok = NULL;
@@ -122,9 +119,10 @@ void CommandDel(Command *command) {
 		else
 			cmdstr = tmp;
 	}
-	DelListItem(command->cmd, CommandHash[toupper(*command->cmd->cmd)]);
+
+	splaytree_delete(CommandTree, command->cmd->cmd);
 	if (command->tok)
-		DelListItem(command->tok, TokenHash[*command->tok->cmd]);
+		splaytree_delete(TokenTree, command->tok->cmd);
 	if (command->cmd->owner) {
 		ModuleObject *cmdobj;
 		for (cmdobj = command->cmd->owner->objects; cmdobj; cmdobj = (ModuleObject *)cmdobj->next) {
Index: Unreal3.2.orig/src/modules.c
===================================================================
--- Unreal3.2.orig.orig/src/modules.c
+++ Unreal3.2.orig/src/modules.c
@@ -1094,7 +1094,9 @@ int  m_module(aClient *cptr, aClient *sp
 	p = tmp;
 	for (i=0; i < 256; i++)
 	{
-		for (mptr = CommandHash[i]; mptr; mptr = mptr->next)
+		SplayTreeIter iter;
+
+		SPLAYTREE_FOREACH(mptr, &iter, CommandTree)
 			if (mptr->overriders)
 			{
 				sprintf(p, "%s ", mptr->cmd);
Index: Unreal3.2.orig/src/modules/m_addline.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_addline.c
+++ Unreal3.2.orig/src/modules/m_addline.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_addline)
 
 DLLFUNC int MOD_INIT(m_addline)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_ADDLINE, TOK_ADDLINE, m_addline, 1);
+	CommandAdd(modinfo->handle, MSG_ADDLINE, TOK_ADDLINE, m_addline, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_addline)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_addline)(int module_unload)
 {
-	if (del_Command(MSG_ADDLINE, TOK_ADDLINE, m_addline) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_addline).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_addmotd.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_addmotd.c
+++ Unreal3.2.orig/src/modules/m_addmotd.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_addmotd)
 
 DLLFUNC int MOD_INIT(m_addmotd)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_ADDMOTD, TOK_ADDMOTD, m_addmotd, 1);
+	CommandAdd(modinfo->handle, MSG_ADDMOTD, TOK_ADDMOTD, m_addmotd, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_addmotd)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_addmotd)(int module_unload)
 {
-	if (del_Command(MSG_ADDMOTD, TOK_ADDMOTD, m_addmotd) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_addmotd).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_addomotd.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_addomotd.c
+++ Unreal3.2.orig/src/modules/m_addomotd.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_addomotd)
 
 DLLFUNC int MOD_INIT(m_addomotd)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_ADDOMOTD, TOK_ADDOMOTD, m_addomotd, 1);
+	CommandAdd(modinfo->handle, MSG_ADDOMOTD, TOK_ADDOMOTD, m_addomotd, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_addomotd)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_addomotd)(int module_unload)
 {
-	if (del_Command(MSG_ADDOMOTD, TOK_ADDOMOTD, m_addomotd) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_addomotd).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_admin.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_admin.c
+++ Unreal3.2.orig/src/modules/m_admin.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_admin)
 
 DLLFUNC int MOD_INIT(m_admin)(ModuleInfo *modinfo)
 {
-	add_CommandX(MSG_ADMIN, TOK_ADMIN, m_admin, MAXPARA, M_UNREGISTERED|M_USER|M_SHUN|M_VIRUS);
+	CommandAdd(modinfo->handle, MSG_ADMIN, TOK_ADMIN, m_admin, MAXPARA, M_UNREGISTERED|M_USER|M_SHUN|M_VIRUS);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_admin)(int module
 
 DLLFUNC int MOD_UNLOAD(m_admin)(int module_unload)
 {
-	if (del_Command(MSG_ADMIN, TOK_ADMIN, m_admin) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_admin).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_adminchat.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_adminchat.c
+++ Unreal3.2.orig/src/modules/m_adminchat.c
@@ -63,10 +63,7 @@ ModuleHeader MOD_HEADER(m_adminchat)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_adminchat)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_ADMINCHAT, TOK_ADMINCHAT, m_admins, 1);
+	CommandAdd(modinfo->handle, MSG_ADMINCHAT, TOK_ADMINCHAT, m_admins, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -81,11 +78,6 @@ DLLFUNC int MOD_LOAD(m_adminchat)(int mo
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_adminchat)(int module_unload)
 {
-	if (del_Command(MSG_ADMINCHAT, TOK_ADMINCHAT, m_admins) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_adminchat).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_akill.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_akill.c
+++ Unreal3.2.orig/src/modules/m_akill.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_akill)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_akill)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_AKILL, TOK_AKILL, m_akill, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_AKILL, TOK_AKILL, m_akill, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -79,11 +76,6 @@ DLLFUNC int MOD_LOAD(m_akill)(int module
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_akill)(int module_unload)
 {
-	if (del_Command(MSG_AKILL, TOK_AKILL, m_akill) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_akill).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_away.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_away.c
+++ Unreal3.2.orig/src/modules/m_away.c
@@ -62,7 +62,7 @@ DLLFUNC ModuleHeader MOD_HEADER(m_away)
 
 DLLFUNC int MOD_INIT(m_away)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_AWAY, TOK_AWAY, m_away, 1);
+	CommandAdd(modinfo->handle, MSG_AWAY, TOK_AWAY, m_away, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -74,11 +74,6 @@ DLLFUNC int MOD_LOAD(m_away)(int module_
 
 DLLFUNC int MOD_UNLOAD(m_away)(int module_unload)
 {
-	if (del_Command(MSG_AWAY, TOK_AWAY, m_away) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_away).name);
-	}
 	return MOD_SUCCESS;
 }
 /***********************************************************************
Index: Unreal3.2.orig/src/modules/m_chatops.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_chatops.c
+++ Unreal3.2.orig/src/modules/m_chatops.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_chatops)
 
 DLLFUNC int MOD_INIT(m_chatops)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_CHATOPS, TOK_CHATOPS, m_chatops, 1);
+	CommandAdd(modinfo->handle, MSG_CHATOPS, TOK_CHATOPS, m_chatops, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_chatops)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_chatops)(int module_unload)
 {
-	if (del_Command(MSG_CHATOPS, TOK_CHATOPS, m_chatops) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_chatops).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_chghost.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_chghost.c
+++ Unreal3.2.orig/src/modules/m_chghost.c
@@ -66,10 +66,7 @@ ModuleHeader MOD_HEADER(m_chghost)
 
 DLLFUNC int MOD_INIT(m_chghost)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_CHGHOST, TOK_CHGHOST, m_chghost, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_CHGHOST, TOK_CHGHOST, m_chghost, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -82,13 +79,7 @@ DLLFUNC int MOD_LOAD(m_chghost)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_chghost)(int module_unload)
 {
-	if (del_Command(MSG_CHGHOST, TOK_CHGHOST, m_chghost) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_chghost).name);
-	}
-	return MOD_SUCCESS;
-	
+	return MOD_SUCCESS;	
 }
 
 /* 
Index: Unreal3.2.orig/src/modules/m_chgident.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_chgident.c
+++ Unreal3.2.orig/src/modules/m_chgident.c
@@ -73,10 +73,7 @@ DLLFUNC int MOD_INIT(m_chgident)(ModuleI
 	   the module_load() will use this to add to the modules linked 
 	   list
 	*/
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_CHGIDENT, TOK_CHGIDENT, m_chgident, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_CHGIDENT, TOK_CHGIDENT, m_chgident, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -88,11 +85,6 @@ DLLFUNC int MOD_LOAD(m_chgident)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_chgident)(int module_unload)
 {
-	if (del_Command(MSG_CHGIDENT, TOK_CHGIDENT, m_chgident) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_chgident).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_chgname.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_chgname.c
+++ Unreal3.2.orig/src/modules/m_chgname.c
@@ -68,11 +68,8 @@ ModuleHeader MOD_HEADER(m_chgname)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_chgname)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_CHGNAME, TOK_CHGNAME, m_chgname, 2);
-	add_Command(MSG_SVSNAME, NULL, m_chgname, 2);
+	CommandAdd(modinfo->handle, MSG_CHGNAME, TOK_CHGNAME, m_chgname, 2, 0);
+	CommandAdd(modinfo->handle, MSG_SVSNAME, NULL, m_chgname, 2, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -81,25 +78,13 @@ DLLFUNC int MOD_INIT(m_chgname)(ModuleIn
 DLLFUNC int MOD_LOAD(m_chgname)(int module_load)
 {
 	return MOD_SUCCESS;
-	
 }
 
 
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_chgname)(int module_unload)
 {
-	if (del_Command(MSG_CHGNAME, TOK_CHGNAME, m_chgname) < 0)
-	{
-		sendto_realops("Failed to delete command chgname when unloading %s",
-				MOD_HEADER(m_chgname).name);
-	}
-	if (del_Command(MSG_SVSNAME, NULL, m_chgname) < 0)
-	{
-		sendto_realops("Failed to delete command svsname when unloading %s",
-				MOD_HEADER(m_chgname).name);
-	}
-	return MOD_SUCCESS;
-	
+	return MOD_SUCCESS;	
 }
 
 
Index: Unreal3.2.orig/src/modules/m_close.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_close.c
+++ Unreal3.2.orig/src/modules/m_close.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_close)
 
 DLLFUNC int MOD_INIT(m_close)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_CLOSE, TOK_CLOSE, m_close, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_CLOSE, TOK_CLOSE, m_close, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_close)(int module
 
 DLLFUNC int MOD_UNLOAD(m_close)(int module_unload)
 {
-	if (del_Command(MSG_CLOSE, TOK_CLOSE, m_close) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_close).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_connect.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_connect.c
+++ Unreal3.2.orig/src/modules/m_connect.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_connect)
 
 DLLFUNC int MOD_INIT(m_connect)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_CONNECT, TOK_CONNECT, m_connect, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_CONNECT, TOK_CONNECT, m_connect, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_connect)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_connect)(int module_unload)
 {
-	if (del_Command(MSG_CONNECT, TOK_CONNECT, m_connect) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_connect).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_cycle.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_cycle.c
+++ Unreal3.2.orig/src/modules/m_cycle.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_cycle)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_cycle)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_CYCLE, TOK_CYCLE, m_cycle, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_CYCLE, TOK_CYCLE, m_cycle, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -79,11 +76,6 @@ DLLFUNC int MOD_LOAD(m_cycle)(int module
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_cycle)(int module_unload)
 {
-	if (del_Command(MSG_CYCLE, TOK_CYCLE, m_cycle) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_cycle).name);
-	}
 	return MOD_SUCCESS;	
 }
 
Index: Unreal3.2.orig/src/modules/m_dccdeny.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_dccdeny.c
+++ Unreal3.2.orig/src/modules/m_dccdeny.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_dccdeny)
 
 DLLFUNC int MOD_INIT(m_dccdeny)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_DCCDENY, TOK_DCCDENY, m_dccdeny, 2);
+	CommandAdd(modinfo->handle, MSG_DCCDENY, TOK_DCCDENY, m_dccdeny, 2, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_dccdeny)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_dccdeny)(int module_unload)
 {
-	if (del_Command(MSG_DCCDENY, TOK_DCCDENY, m_dccdeny) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_dccdeny).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_dummy.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_dummy.c
+++ Unreal3.2.orig/src/modules/m_dummy.c
@@ -46,10 +46,7 @@ ModuleHeader MOD_HEADER(m_dummy)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_dummy)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_DUMMY, TOK_DUMMY, m_dummy, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_DUMMY, TOK_DUMMY, m_dummy, MAXPARA, 0);
 	return MOD_SUCCESS;
 }
 
@@ -63,11 +60,6 @@ DLLFUNC int MOD_LOAD(m_dummy)(int module
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_dummy)(int module_unload)
 {
-	if (del_Command(MSG_DUMMY, TOK_DUMMY, m_dummy) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_dummy).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_eos.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_eos.c
+++ Unreal3.2.orig/src/modules/m_eos.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_eos)
 
 DLLFUNC int MOD_INIT(m_eos)(ModuleInfo *modinfo)
 {
-	add_CommandX(MSG_EOS, TOK_EOS, m_eos, MAXPARA, M_SERVER);
+	CommandAdd(modinfo->handle, MSG_EOS, TOK_EOS, m_eos, MAXPARA, M_SERVER);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_eos)(int module_l
 
 DLLFUNC int MOD_UNLOAD(m_eos)(int module_unload)
 {
-	if (del_Command(MSG_EOS, TOK_EOS, m_eos) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_eos).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_globops.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_globops.c
+++ Unreal3.2.orig/src/modules/m_globops.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_globops)
 
 DLLFUNC int MOD_INIT(m_globops)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_GLOBOPS, TOK_GLOBOPS, m_globops, 1);
+	CommandAdd(modinfo->handle, MSG_GLOBOPS, TOK_GLOBOPS, m_globops, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_globops)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_globops)(int module_unload)
 {
-	if (del_Command(MSG_GLOBOPS, TOK_GLOBOPS, m_globops) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_globops).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_help.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_help.c
+++ Unreal3.2.orig/src/modules/m_help.c
@@ -61,8 +61,8 @@ ModuleHeader MOD_HEADER(m_help)
 
 DLLFUNC int MOD_INIT(m_help)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_HELP, TOK_HELP, m_help, 1);
-	add_Command(MSG_HELPOP, NULL, m_help, 1);
+	CommandAdd(modinfo->handle, MSG_HELP, TOK_HELP, m_help, 1, 0);
+	CommandAdd(modinfo->handle, MSG_HELPOP, NULL, m_help, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -74,16 +74,6 @@ DLLFUNC int MOD_LOAD(m_help)(int module_
 
 DLLFUNC int MOD_UNLOAD(m_help)(int module_unload)
 {
-	if (del_Command(MSG_HELP, TOK_HELP, m_help) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_help).name);
-	}
-	if (del_Command(MSG_HELPOP, NULL, m_help) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_help).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_htm.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_htm.c
+++ Unreal3.2.orig/src/modules/m_htm.c
@@ -71,9 +71,6 @@ ModuleHeader MOD_HEADER(m_htm)
 
 DLLFUNC int MOD_TEST(m_htm)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
 	HtmModInfo = modinfo;
 	ConfTest = HookAddEx(HtmModInfo->handle, HOOKTYPE_CONFIGTEST, htm_config_test);
 	return MOD_SUCCESS;
@@ -83,10 +80,7 @@ DLLFUNC int MOD_TEST(m_htm)(ModuleInfo *
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_htm)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_HTM, TOK_HTM, m_htm, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_HTM, TOK_HTM, m_htm, MAXPARA, 0);
 	ConfRun = HookAddEx(HtmModInfo->handle, HOOKTYPE_CONFIGRUN, htm_config_run);
 	ServerStats = HookAddEx(HtmModInfo->handle, HOOKTYPE_STATS, htm_stats);
 #ifndef NO_FDLIST
@@ -109,11 +103,6 @@ DLLFUNC int MOD_LOAD(m_htm)(int module_l
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_htm)(int module_unload)
 {
-	if (del_Command(MSG_HTM, TOK_HTM, m_htm) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_htm).name);
-	}
 #ifndef NO_FDLIST
 	LockEventSystem();
 	EventDel(e_lcf);
Index: Unreal3.2.orig/src/modules/m_invite.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_invite.c
+++ Unreal3.2.orig/src/modules/m_invite.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_invite)
 
 DLLFUNC int MOD_INIT(m_invite)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_INVITE, TOK_INVITE, m_invite, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_INVITE, TOK_INVITE, m_invite, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_invite)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_invite)(int module_unload)
 {
-	if (del_Command(MSG_INVITE, TOK_INVITE, m_invite) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_invite).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_ison.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_ison.c
+++ Unreal3.2.orig/src/modules/m_ison.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_ison)
 
 DLLFUNC int MOD_INIT(m_ison)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_ISON, TOK_ISON, m_ison, 1);
+	CommandAdd(modinfo->handle, MSG_ISON, TOK_ISON, m_ison, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_ison)(int module_
 
 DLLFUNC int MOD_UNLOAD(m_ison)(int module_unload)
 {
-	if (del_Command(MSG_ISON, TOK_ISON, m_ison) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_ison).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_kick.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_kick.c
+++ Unreal3.2.orig/src/modules/m_kick.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_kick)
 
 DLLFUNC int MOD_INIT(m_kick)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_KICK, TOK_KICK, m_kick, 3);
+	CommandAdd(modinfo->handle, MSG_KICK, TOK_KICK, m_kick, 3, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_kick)(int module_
 
 DLLFUNC int MOD_UNLOAD(m_kick)(int module_unload)
 {
-	if (del_Command(MSG_KICK, TOK_KICK, m_kick) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_kick).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_kill.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_kill.c
+++ Unreal3.2.orig/src/modules/m_kill.c
@@ -62,10 +62,7 @@ ModuleHeader MOD_HEADER(m_kill)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_kill)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_KILL, TOK_KILL, m_kill, 2);
+	CommandAdd(modinfo->handle, MSG_KILL, TOK_KILL, m_kill, 2, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -80,13 +77,7 @@ DLLFUNC int MOD_LOAD(m_kill)(int module_
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_kill)(int module_unload)
 {
-	if (del_Command(MSG_KILL, TOK_KILL, m_kill) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_kill).name);
-	}
-	return MOD_SUCCESS;
-	
+	return MOD_SUCCESS;	
 }
 
 
Index: Unreal3.2.orig/src/modules/m_lag.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_lag.c
+++ Unreal3.2.orig/src/modules/m_lag.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_lag)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_lag)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_LAG, TOK_LAG, m_lag, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_LAG, TOK_LAG, m_lag, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,13 +75,7 @@ DLLFUNC int MOD_LOAD(m_lag)(int module_l
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_lag)(int module_unload)
 {
-	if (del_Command(MSG_LAG, TOK_LAG, m_lag) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_lag).name);
-	}
 	return MOD_SUCCESS;
-	
 }
 
 /* m_lag (lag measure) - Stskeeps
Index: Unreal3.2.orig/src/modules/m_links.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_links.c
+++ Unreal3.2.orig/src/modules/m_links.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_links)
 
 DLLFUNC int MOD_INIT(m_links)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_LINKS, TOK_LINKS, m_links, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_LINKS, TOK_LINKS, m_links, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_links)(int module
 
 DLLFUNC int MOD_UNLOAD(m_links)(int module_unload)
 {
-	if (del_Command(MSG_LINKS, TOK_LINKS, m_links) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_links).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_list.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_list.c
+++ Unreal3.2.orig/src/modules/m_list.c
@@ -68,7 +68,7 @@ DLLFUNC int MOD_TEST(m_list)(ModuleInfo 
 
 DLLFUNC int MOD_INIT(m_list)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_LIST, TOK_LIST, m_list, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_LIST, TOK_LIST, m_list, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -80,11 +80,6 @@ DLLFUNC int MOD_LOAD(m_list)(int module_
 
 DLLFUNC int MOD_UNLOAD(m_list)(int module_unload)
 {
-	if (del_Command(MSG_LIST, TOK_LIST, m_list) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_list).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_locops.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_locops.c
+++ Unreal3.2.orig/src/modules/m_locops.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_locops)
 
 DLLFUNC int MOD_INIT(m_locops)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_LOCOPS, TOK_LOCOPS, m_locops, 1);
+	CommandAdd(modinfo->handle, MSG_LOCOPS, TOK_LOCOPS, m_locops, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_locops)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_locops)(int module_unload)
 {
-	if (del_Command(MSG_LOCOPS, TOK_LOCOPS, m_locops) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_locops).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_message.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_message.c
+++ Unreal3.2.orig/src/modules/m_message.c
@@ -87,14 +87,10 @@ DLLFUNC int MOD_TEST(m_message)(ModuleIn
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_message)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_CommandX(MSG_PRIVATE, TOK_PRIVATE, m_private, 2, M_USER|M_SERVER|M_RESETIDLE|M_VIRUS);
-	add_Command(MSG_NOTICE, TOK_NOTICE, m_notice, 2);
+	CommandAdd(modinfo->handle, MSG_PRIVATE, TOK_PRIVATE, m_private, 2, M_USER|M_SERVER|M_RESETIDLE|M_VIRUS);
+	CommandAdd(modinfo->handle, MSG_NOTICE, TOK_NOTICE, m_notice, 2, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
-	return MOD_SUCCESS;
-	
+	return MOD_SUCCESS;	
 }
 
 /* Is first run when server is 100% ready */
@@ -106,16 +102,6 @@ DLLFUNC int MOD_LOAD(m_message)(int modu
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_message)(int module_unload)
 {
-	if (del_Command(MSG_PRIVATE, TOK_PRIVATE, m_private) < 0)
-	{
-		sendto_realops("Failed to delete command privmsg when unloading %s",
-				MOD_HEADER(m_message).name);
-	}
-	if (del_Command(MSG_NOTICE, TOK_NOTICE, m_notice) < 0)
-	{
-		sendto_realops("Failed to delete command notice when unloading %s",
-				MOD_HEADER(m_message).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_mkpasswd.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_mkpasswd.c
+++ Unreal3.2.orig/src/modules/m_mkpasswd.c
@@ -62,7 +62,7 @@ ModuleHeader MOD_HEADER(m_mkpasswd)
 
 DLLFUNC int MOD_INIT(m_mkpasswd)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_MKPASSWD, TOK_MKPASSWD, m_mkpasswd, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_MKPASSWD, TOK_MKPASSWD, m_mkpasswd, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -74,11 +74,6 @@ DLLFUNC int MOD_LOAD(m_mkpasswd)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_mkpasswd)(int module_unload)
 {
-	if (del_Command(MSG_MKPASSWD, TOK_MKPASSWD, m_mkpasswd) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_mkpasswd).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_nachat.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_nachat.c
+++ Unreal3.2.orig/src/modules/m_nachat.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_nachat)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_nachat)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_NACHAT, TOK_NACHAT, m_nachat, 1);
+	CommandAdd(modinfo->handle, MSG_NACHAT, TOK_NACHAT, m_nachat, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,13 +75,7 @@ DLLFUNC int MOD_LOAD(m_nachat)(int modul
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_nachat)(int module_unload)
 {
-	if (del_Command(MSG_NACHAT, TOK_NACHAT, m_nachat) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_nachat).name);
-	}
-	return MOD_SUCCESS;
-	
+	return MOD_SUCCESS;	
 }
 
 /*
Index: Unreal3.2.orig/src/modules/m_netinfo.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_netinfo.c
+++ Unreal3.2.orig/src/modules/m_netinfo.c
@@ -58,7 +58,7 @@ ModuleHeader MOD_HEADER(m_netinfo)
 
 DLLFUNC int MOD_INIT(m_netinfo)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_NETINFO, TOK_NETINFO, m_netinfo, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_NETINFO, TOK_NETINFO, m_netinfo, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -70,11 +70,6 @@ DLLFUNC int MOD_LOAD(m_netinfo)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_netinfo)(int module_unload)
 {
-	if (del_Command(MSG_NETINFO, TOK_NETINFO, m_netinfo) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_netinfo).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_oper.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_oper.c
+++ Unreal3.2.orig/src/modules/m_oper.c
@@ -117,10 +117,7 @@ ModuleHeader MOD_HEADER(m_oper)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_oper)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_OPER, TOK_OPER, m_oper, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_OPER, TOK_OPER, m_oper, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -135,11 +132,6 @@ DLLFUNC int MOD_LOAD(m_oper)(int module_
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_oper)(int module_unload)
 {
-	if (del_Command(MSG_OPER, TOK_OPER, m_oper) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_oper).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_pass.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_pass.c
+++ Unreal3.2.orig/src/modules/m_pass.c
@@ -68,7 +68,7 @@ ModuleHeader MOD_HEADER(m_pass)
 
 DLLFUNC int MOD_INIT(m_pass)(ModuleInfo *modinfo)
 {
-	add_CommandX(MSG_PASS, TOK_PASS, m_pass, 1, M_UNREGISTERED|M_USER|M_SERVER);
+	CommandAdd(modinfo->handle, MSG_PASS, TOK_PASS, m_pass, 1, M_UNREGISTERED|M_USER|M_SERVER);
 	CommandAdd(modinfo->handle, MSG_WEBIRC, NULL, m_webirc, MAXPARA, M_UNREGISTERED);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
@@ -81,11 +81,6 @@ DLLFUNC int MOD_LOAD(m_pass)(int module_
 
 DLLFUNC int MOD_UNLOAD(m_pass)(int module_unload)
 {
-	if (del_Command(MSG_PASS, TOK_PASS, m_pass) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_pass).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_pingpong.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_pingpong.c
+++ Unreal3.2.orig/src/modules/m_pingpong.c
@@ -69,8 +69,8 @@ DLLFUNC int MOD_INIT(m_pingpong)(ModuleI
 	 * We call our add_Command crap here
 	*/
 	Debug((DEBUG_NOTICE, "INIT"));
-	add_Command(MSG_PING, TOK_PING, m_ping, MAXPARA);
-	add_CommandX(MSG_PONG, TOK_PONG, m_pong, MAXPARA, M_UNREGISTERED|M_USER|M_SERVER|M_SHUN|M_VIRUS);
+	CommandAdd(modinfo->handle, MSG_PING, TOK_PING, m_ping, MAXPARA, 0);
+	CommandAdd(modinfo->handle, MSG_PONG, TOK_PONG, m_pong, MAXPARA, M_UNREGISTERED|M_USER|M_SERVER|M_SHUN|M_VIRUS);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -85,16 +85,6 @@ DLLFUNC int MOD_LOAD(m_pingpong)(int mod
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_pingpong)(int module_unload)
 {
-	if (del_Command(MSG_PING, TOK_PING, m_ping) < 0)
-	{
-		sendto_realops("Failed to delete command ping when unloading %s",
-				MOD_HEADER(m_pingpong).name);
-	}
-	if (del_Command(MSG_PONG, TOK_PONG, m_pong) < 0)
-	{
-		sendto_realops("Failed to delete command pong when unloading %s",
-				MOD_HEADER(m_pingpong).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_protoctl.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_protoctl.c
+++ Unreal3.2.orig/src/modules/m_protoctl.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_protoctl)
 
 DLLFUNC int MOD_INIT(m_protoctl)(ModuleInfo *modinfo)
 {
-	add_CommandX(MSG_PROTOCTL, TOK_PROTOCTL, m_protoctl, MAXPARA, M_UNREGISTERED|M_SERVER|M_USER);
+	CommandAdd(modinfo->handle, MSG_PROTOCTL, TOK_PROTOCTL, m_protoctl, MAXPARA, M_UNREGISTERED|M_SERVER|M_USER);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_protoctl)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_protoctl)(int module_unload)
 {
-	if (del_Command(MSG_PROTOCTL, TOK_PROTOCTL, m_protoctl) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_protoctl).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_quit.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_quit.c
+++ Unreal3.2.orig/src/modules/m_quit.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_quit)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_quit)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_CommandX(MSG_QUIT, TOK_QUIT, m_quit, 1, M_UNREGISTERED|M_USER|M_VIRUS);
+	CommandAdd(modinfo->handle, MSG_QUIT, TOK_QUIT, m_quit, 1, M_UNREGISTERED|M_USER|M_VIRUS);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_quit)(int module_
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_quit)(int module_unload)
 {
-	if (del_Command(MSG_QUIT, TOK_QUIT, m_quit) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_quit).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_rakill.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_rakill.c
+++ Unreal3.2.orig/src/modules/m_rakill.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_rakill)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_rakill)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_RAKILL, TOK_RAKILL, m_rakill, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_RAKILL, TOK_RAKILL, m_rakill, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_rakill)(int modul
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_rakill)(int module_unload)
 {
-	if (del_Command(MSG_RAKILL, TOK_RAKILL, m_rakill) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_rakill).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_rping.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_rping.c
+++ Unreal3.2.orig/src/modules/m_rping.c
@@ -66,11 +66,8 @@ ModuleHeader MOD_HEADER(m_rping)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_rping)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_RPING, TOK_RPING, m_rping, MAXPARA);
-	add_Command(MSG_RPONG, TOK_RPONG, m_rpong, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_RPING, TOK_RPING, m_rping, MAXPARA, 0);
+	CommandAdd(modinfo->handle, MSG_RPONG, TOK_RPONG, m_rpong, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -85,16 +82,6 @@ DLLFUNC int MOD_LOAD(m_rping)(int module
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_rping)(int module_unload)
 {
-	if (del_Command(MSG_RPING, TOK_RPING, m_rping) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_rping).name);
-	}
-	if (del_Command(MSG_RPONG, TOK_RPONG, m_rpong) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_rping).name);
-	}
 	return MOD_SUCCESS;	
 }
 
Index: Unreal3.2.orig/src/modules/m_rules.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_rules.c
+++ Unreal3.2.orig/src/modules/m_rules.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_rules)
 
 DLLFUNC int MOD_INIT(m_rules)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_RULES, TOK_RULES, m_rules, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_RULES, TOK_RULES, m_rules, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_rules)(int module
 
 DLLFUNC int MOD_UNLOAD(m_rules)(int module_unload)
 {
-	if (del_Command(MSG_RULES, TOK_RULES, m_rules) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_rules).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sajoin.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sajoin.c
+++ Unreal3.2.orig/src/modules/m_sajoin.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_sajoin)
 
 DLLFUNC int MOD_INIT(m_sajoin)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SAJOIN, TOK_SAJOIN, m_sajoin, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SAJOIN, TOK_SAJOIN, m_sajoin, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_sajoin)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_sajoin)(int module_unload)
 {
-	if (del_Command(MSG_SAJOIN, TOK_SAJOIN, m_sajoin) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_sajoin).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_samode.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_samode.c
+++ Unreal3.2.orig/src/modules/m_samode.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_samode)
 
 DLLFUNC int MOD_INIT(m_samode)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SAMODE, TOK_SAMODE, m_samode, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SAMODE, TOK_SAMODE, m_samode, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_samode)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_samode)(int module_unload)
 {
-	if (del_Command(MSG_SAMODE, TOK_SAMODE, m_samode) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_samode).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sapart.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sapart.c
+++ Unreal3.2.orig/src/modules/m_sapart.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_sapart)
 
 DLLFUNC int MOD_INIT(m_sapart)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SAPART, TOK_SAPART, m_sapart, 3);
+	CommandAdd(modinfo->handle, MSG_SAPART, TOK_SAPART, m_sapart, 3, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_sapart)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_sapart)(int module_unload)
 {
-	if (del_Command(MSG_SAPART, TOK_SAPART, m_sapart) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_sapart).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sdesc.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sdesc.c
+++ Unreal3.2.orig/src/modules/m_sdesc.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_sdesc)
 
 DLLFUNC int MOD_INIT(m_sdesc)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SDESC, TOK_SDESC, m_sdesc, 1);
+	CommandAdd(modinfo->handle, MSG_SDESC, TOK_SDESC, m_sdesc, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -76,11 +73,6 @@ DLLFUNC int MOD_LOAD(m_sdesc)(int module
 
 DLLFUNC int MOD_UNLOAD(m_sdesc)(int module_unload)
 {
-	if (del_Command(MSG_SDESC, TOK_SDESC, m_sdesc) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_sdesc).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sendsno.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sendsno.c
+++ Unreal3.2.orig/src/modules/m_sendsno.c
@@ -61,7 +61,7 @@ ModuleHeader MOD_HEADER(m_sendsno)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_sendsno)(ModuleInfo *modinfo)
 {
-	add_CommandX(MSG_SENDSNO, TOK_SENDSNO, m_sendsno, MAXPARA, M_SERVER);
+	CommandAdd(modinfo->handle, MSG_SENDSNO, TOK_SENDSNO, m_sendsno, MAXPARA, M_SERVER);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -75,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_sendsno)(int modu
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_sendsno)(int module_unload)
 {
-	if (del_Command(MSG_SENDSNO, TOK_SENDSNO, m_sendsno) < 0)
-	{
-		sendto_realops("Failed to delete command sendsno when unloading %s",
-				MOD_HEADER(m_sendsno).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sendumode.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sendumode.c
+++ Unreal3.2.orig/src/modules/m_sendumode.c
@@ -63,11 +63,8 @@ ModuleHeader MOD_HEADER(m_sendumode)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_sendumode)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SENDUMODE, TOK_SENDUMODE, m_sendumode, MAXPARA);
-	add_Command(MSG_SMO, TOK_SMO, m_sendumode, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SENDUMODE, TOK_SENDUMODE, m_sendumode, MAXPARA, 0);
+	CommandAdd(modinfo->handle, MSG_SMO, TOK_SMO, m_sendumode, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -81,19 +78,7 @@ DLLFUNC int MOD_LOAD(m_sendumode)(int mo
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_sendumode)(int module_unload)
 {
-	if (del_Command(MSG_SENDUMODE, TOK_SENDUMODE, m_sendumode) < 0)
-	{
-		sendto_realops("Failed to delete command sendumode when unloading %s",
-				MOD_HEADER(m_sendumode).name);
-	}
-	if (del_Command(MSG_SMO, TOK_SMO, m_sendumode) < 0)
-	{
-		sendto_realops("Failed to delete command smo when unloading %s",
-				MOD_HEADER(m_sendumode).name);
-	}
 	return MOD_SUCCESS;
-	
-
 }
 
 /*
Index: Unreal3.2.orig/src/modules/m_server.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_server.c
+++ Unreal3.2.orig/src/modules/m_server.c
@@ -64,7 +64,7 @@ ModuleHeader MOD_HEADER(m_server)
 
 DLLFUNC int MOD_INIT(m_server)(ModuleInfo *modinfo)
 {
-	add_CommandX(MSG_SERVER, TOK_SERVER, m_server, MAXPARA, M_UNREGISTERED|M_SERVER);
+	CommandAdd(modinfo->handle, MSG_SERVER, TOK_SERVER, m_server, MAXPARA, M_UNREGISTERED|M_SERVER);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -76,11 +76,6 @@ DLLFUNC int MOD_LOAD(m_server)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_server)(int module_unload)
 {
-	if (del_Command(MSG_SERVER, TOK_SERVER, m_server) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_server).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sethost.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sethost.c
+++ Unreal3.2.orig/src/modules/m_sethost.c
@@ -62,10 +62,7 @@ ModuleHeader MOD_HEADER(m_sethost)
 
 DLLFUNC int MOD_INIT(m_sethost)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SETHOST, TOK_SETHOST, m_sethost, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SETHOST, TOK_SETHOST, m_sethost, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -77,11 +74,6 @@ DLLFUNC int MOD_LOAD(m_sethost)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_sethost)(int module_unload)
 {
-	if (del_Command(MSG_SETHOST, TOK_SETHOST, m_sethost) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_sethost).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_setident.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_setident.c
+++ Unreal3.2.orig/src/modules/m_setident.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_setident)
 
 DLLFUNC int MOD_INIT(m_setident)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SETIDENT, TOK_SETIDENT, m_setident, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SETIDENT, TOK_SETIDENT, m_setident, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -76,11 +73,6 @@ DLLFUNC int MOD_LOAD(m_setident)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_setident)(int module_unload)
 {
-	if (del_Command(MSG_SETIDENT, TOK_SETIDENT, m_setident) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_setident).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_setname.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_setname.c
+++ Unreal3.2.orig/src/modules/m_setname.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_setname)
 
 DLLFUNC int MOD_INIT(m_setname)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SETNAME, TOK_SETNAME, m_setname, 1);
+	CommandAdd(modinfo->handle, MSG_SETNAME, TOK_SETNAME, m_setname, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -76,11 +73,6 @@ DLLFUNC int MOD_LOAD(m_setname)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_setname)(int module_unload)
 {
-	if (del_Command(MSG_SETNAME, TOK_SETNAME, m_setname) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_setname).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_silence.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_silence.c
+++ Unreal3.2.orig/src/modules/m_silence.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_silence)
 
 DLLFUNC int MOD_INIT(m_silence)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SILENCE, TOK_SILENCE, m_silence, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SILENCE, TOK_SILENCE, m_silence, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_silence)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_silence)(int module_unload)
 {
-	if (del_Command(MSG_SILENCE, TOK_SILENCE, m_silence) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_silence).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sjoin.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sjoin.c
+++ Unreal3.2.orig/src/modules/m_sjoin.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_sjoin)
 
 DLLFUNC int MOD_INIT(m_sjoin)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SJOIN, TOK_SJOIN, m_sjoin, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SJOIN, TOK_SJOIN, m_sjoin, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_sjoin)(int module
 
 DLLFUNC int MOD_UNLOAD(m_sjoin)(int module_unload)
 {
-	if (del_Command(MSG_SJOIN, TOK_SJOIN, m_sjoin) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_sjoin).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_sqline.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_sqline.c
+++ Unreal3.2.orig/src/modules/m_sqline.c
@@ -63,10 +63,7 @@ ModuleHeader MOD_HEADER(m_sqline)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_sqline)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SQLINE, TOK_SQLINE, m_sqline, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SQLINE, TOK_SQLINE, m_sqline, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -81,11 +78,6 @@ DLLFUNC int MOD_LOAD(m_sqline)(int modul
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_sqline)(int module_unload)
 {
-	if (del_Command(MSG_SQLINE, TOK_SQLINE, m_sqline) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_sqline).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_squit.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_squit.c
+++ Unreal3.2.orig/src/modules/m_squit.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_squit)
 
 DLLFUNC int MOD_INIT(m_squit)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SQUIT, TOK_SQUIT, m_squit, 2);
+	CommandAdd(modinfo->handle, MSG_SQUIT, TOK_SQUIT, m_squit, 2, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_squit)(int module
 
 DLLFUNC int MOD_UNLOAD(m_squit)(int module_unload)
 {
-	if (del_Command(MSG_SQUIT, TOK_SQUIT, m_squit) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_squit).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_stats.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_stats.c
+++ Unreal3.2.orig/src/modules/m_stats.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_stats)
 
 DLLFUNC int MOD_INIT(m_stats)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_STATS, TOK_STATS, m_stats, 3);
+	CommandAdd(modinfo->handle, MSG_STATS, TOK_STATS, m_stats, 3, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_stats)(int module
 
 DLLFUNC int MOD_UNLOAD(m_stats)(int module_unload)
 {
-	if (del_Command(MSG_STATS, TOK_STATS, m_stats) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_stats).name);
-	}
 	return MOD_SUCCESS;
 }
 
@@ -604,9 +599,10 @@ int stats_command(aClient *sptr, char *p
 {
 	int i;
 	aCommand *mptr;
-	for (i = 0; i < 256; i++)
-		for (mptr = CommandHash[i]; mptr; mptr = mptr->next)
-			if (mptr->count)
+	SplayTreeIter iter;
+
+	SPLAYTREE_FOREACH(mptr, &iter, CommandTree)
+		if (mptr->count)
 #ifndef DEBUGMODE
 			sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS),
 				me.name, sptr->name, mptr->cmd,
@@ -618,9 +614,9 @@ int stats_command(aClient *sptr, char *p
 				mptr->lticks, mptr->lticks / CLOCKS_PER_SEC,
 				mptr->rticks, mptr->rticks / CLOCKS_PER_SEC);
 #endif
-	for (i = 0; i < 256; i++)
-		for (mptr = TokenHash[i]; mptr; mptr = mptr->next)
-			if (mptr->count)
+
+	SPLAYTREE_FOREACH(mptr, &iter, TokenTree)
+		if (mptr->count)
 #ifndef DEBUGMODE
 			sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS),
 				me.name, sptr->name, mptr->cmd,
Index: Unreal3.2.orig/src/modules/m_svsfline.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsfline.c
+++ Unreal3.2.orig/src/modules/m_svsfline.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_svsfline)
 
 DLLFUNC int MOD_INIT(m_svsfline)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSFLINE, TOK_SVSFLINE, m_svsfline, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSFLINE, TOK_SVSFLINE, m_svsfline, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_svsfline)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_svsfline)(int module_unload)
 {
-	if (del_Command(MSG_SVSFLINE, TOK_SVSFLINE, m_svsfline) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_svsfline).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_svsjoin.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsjoin.c
+++ Unreal3.2.orig/src/modules/m_svsjoin.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_svsjoin)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_svsjoin)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SVSJOIN, TOK_SVSJOIN, m_svsjoin, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSJOIN, TOK_SVSJOIN, m_svsjoin, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_svsjoin)(int modu
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_svsjoin)(int module_unload)
 {
-	if (del_Command(MSG_SVSJOIN, TOK_SVSJOIN, m_svsjoin) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svsjoin).name);
-	}
 	return MOD_SUCCESS;	
 }
 
Index: Unreal3.2.orig/src/modules/m_svskill.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svskill.c
+++ Unreal3.2.orig/src/modules/m_svskill.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_svskill)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_svskill)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SVSKILL, TOK_SVSKILL, m_svskill, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSKILL, TOK_SVSKILL, m_svskill, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -79,11 +76,6 @@ DLLFUNC int MOD_LOAD(m_svskill)(int modu
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_svskill)(int module_unload)
 {
-	if (del_Command(MSG_SVSKILL, TOK_SVSKILL, m_svskill) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svskill).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_svslusers.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svslusers.c
+++ Unreal3.2.orig/src/modules/m_svslusers.c
@@ -61,7 +61,7 @@ ModuleHeader MOD_HEADER(m_svslusers)
 
 DLLFUNC int MOD_INIT(m_svslusers)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSLUSERS, TOK_SVSLUSERS, m_svslusers, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSLUSERS, TOK_SVSLUSERS, m_svslusers, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -73,11 +73,6 @@ DLLFUNC int MOD_LOAD(m_svslusers)(int mo
 
 DLLFUNC int MOD_UNLOAD(m_svslusers)(int module_unload)
 {
-	if (del_Command(MSG_SVSLUSERS, TOK_SVSLUSERS, m_svslusers) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svslusers).name);
-	}
 	return MOD_SUCCESS;
 }
 /*
Index: Unreal3.2.orig/src/modules/m_svsmode.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsmode.c
+++ Unreal3.2.orig/src/modules/m_svsmode.c
@@ -66,8 +66,8 @@ ModuleHeader MOD_HEADER(m_svsmode)
 
 DLLFUNC int MOD_INIT(m_svsmode)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSMODE, TOK_SVSMODE, m_svsmode, MAXPARA);
-	add_Command(MSG_SVS2MODE, TOK_SVS2MODE, m_svs2mode, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSMODE, TOK_SVSMODE, m_svsmode, MAXPARA, 0);
+	CommandAdd(modinfo->handle, MSG_SVS2MODE, TOK_SVS2MODE, m_svs2mode, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -79,11 +79,6 @@ DLLFUNC int MOD_LOAD(m_svsmode)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_svsmode)(int module_unload)
 {
-	if (del_Command(MSG_SVSMODE, TOK_SVSMODE, m_svsmode) < 0 || del_Command(MSG_SVS2MODE, TOK_SVS2MODE, m_svs2mode) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svsmode).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_svsmotd.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsmotd.c
+++ Unreal3.2.orig/src/modules/m_svsmotd.c
@@ -63,7 +63,7 @@ ModuleHeader MOD_HEADER(m_svsmotd)
 
 DLLFUNC int MOD_INIT(m_svsmotd)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSMOTD, TOK_SVSMOTD, m_svsmotd, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSMOTD, TOK_SVSMOTD, m_svsmotd, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -75,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_svsmotd)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_svsmotd)(int module_unload)
 {
-	if (del_Command(MSG_SVSMOTD, TOK_SVSMOTD, m_svsmotd) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svsmotd).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_svsnick.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsnick.c
+++ Unreal3.2.orig/src/modules/m_svsnick.c
@@ -62,7 +62,7 @@ ModuleHeader MOD_HEADER(m_svsnick)
 
 DLLFUNC int MOD_INIT(m_svsnick)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSNICK, TOK_SVSNICK, m_svsnick, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSNICK, TOK_SVSNICK, m_svsnick, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -74,11 +74,6 @@ DLLFUNC int MOD_LOAD(m_svsnick)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_svsnick)(int module_unload)
 {
-	if (del_Command(MSG_SVSNICK, TOK_SVSNICK, m_svsnick) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svsnick).name);
-	}
 	return MOD_SUCCESS;
 }
 /*
Index: Unreal3.2.orig/src/modules/m_svsnline.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsnline.c
+++ Unreal3.2.orig/src/modules/m_svsnline.c
@@ -64,10 +64,7 @@ ModuleHeader MOD_HEADER(m_svsnline)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_svsnline)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SVSNLINE, TOK_SVSNLINE, m_svsnline, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSNLINE, TOK_SVSNLINE, m_svsnline, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -81,11 +78,6 @@ DLLFUNC int MOD_LOAD(m_svsnline)(int mod
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_svsnline)(int module_unload)
 {
-	if (del_Command(MSG_SVSNLINE, TOK_SVSNLINE, m_svsnline) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svsnline).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_svsnolag.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsnolag.c
+++ Unreal3.2.orig/src/modules/m_svsnolag.c
@@ -62,8 +62,8 @@ ModuleHeader MOD_HEADER(m_svsnolag)
 
 DLLFUNC int MOD_INIT(m_svsnolag)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSNOLAG, TOK_SVSNOLAG, m_svsnolag, MAXPARA);
-	add_Command(MSG_SVS2NOLAG, TOK_SVS2NOLAG, m_svs2nolag, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSNOLAG, TOK_SVSNOLAG, m_svsnolag, MAXPARA, 0);
+	CommandAdd(modinfo->handle, MSG_SVS2NOLAG, TOK_SVS2NOLAG, m_svs2nolag, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -75,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_svsnolag)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_svsnolag)(int module_unload)
 {
-	if (del_Command(MSG_SVSNOLAG, TOK_SVSNOLAG, m_svsnolag) < 0 || del_Command(MSG_SVS2NOLAG, TOK_SVS2NOLAG, m_svs2nolag) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svsnolag).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_svsnoop.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svsnoop.c
+++ Unreal3.2.orig/src/modules/m_svsnoop.c
@@ -63,7 +63,7 @@ ModuleHeader MOD_HEADER(m_svsnoop)
 
 DLLFUNC int MOD_INIT(m_svsnoop)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSNOOP, TOK_SVSNOOP, m_svsnoop, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSNOOP, TOK_SVSNOOP, m_svsnoop, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -75,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_svsnoop)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_svsnoop)(int module_unload)
 {
-	if (del_Command(MSG_SVSNOOP, TOK_SVSNOOP, m_svsnoop) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svsnoop).name);
-	}
 	return MOD_SUCCESS;
 }
 int m_svsnoop(aClient *cptr, aClient *sptr, int parc, char *parv[])
Index: Unreal3.2.orig/src/modules/m_svso.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svso.c
+++ Unreal3.2.orig/src/modules/m_svso.c
@@ -99,7 +99,7 @@ ModuleHeader MOD_HEADER(m_svso)
 
 DLLFUNC int MOD_INIT(m_svso)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSO, TOK_SVSO, m_svso, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSO, TOK_SVSO, m_svso, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -111,11 +111,6 @@ DLLFUNC int MOD_LOAD(m_svso)(int module_
 
 DLLFUNC int MOD_UNLOAD(m_svso)(int module_unload)
 {
-	if (del_Command(MSG_SVSO, TOK_SVSO, m_svso) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svso).name);
-	}
 	return MOD_SUCCESS;
 }
 /*
Index: Unreal3.2.orig/src/modules/m_svspart.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svspart.c
+++ Unreal3.2.orig/src/modules/m_svspart.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_svspart)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_svspart)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SVSPART, TOK_SVSPART, m_svspart, 3);
+	CommandAdd(modinfo->handle, MSG_SVSPART, TOK_SVSPART, m_svspart, 3, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_svspart)(int modu
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_svspart)(int module_unload)
 {
-	if (del_Command(MSG_SVSPART, TOK_SVSPART, m_svspart) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svspart).name);
-	}
 	return MOD_SUCCESS;	
 }
 
Index: Unreal3.2.orig/src/modules/m_svssilence.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svssilence.c
+++ Unreal3.2.orig/src/modules/m_svssilence.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_svssilence)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_svssilence)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SVSSILENCE, TOK_SVSSILENCE, m_svssilence, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSSILENCE, TOK_SVSSILENCE, m_svssilence, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_svssilence)(int m
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_svssilence)(int module_unload)
 {
-	if (del_Command(MSG_SVSSILENCE, TOK_SVSSILENCE, m_svssilence) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svssilence).name);
-	}
 	return MOD_SUCCESS;	
 }
 
Index: Unreal3.2.orig/src/modules/m_svssno.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svssno.c
+++ Unreal3.2.orig/src/modules/m_svssno.c
@@ -63,8 +63,8 @@ ModuleHeader MOD_HEADER(m_svssno)
 
 DLLFUNC int MOD_INIT(m_svssno)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SVSSNO, TOK_SVSSNO, m_svssno, MAXPARA);
-	add_Command(MSG_SVS2SNO, TOK_SVS2SNO, m_svs2sno, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSSNO, TOK_SVSSNO, m_svssno, MAXPARA, 0);
+	CommandAdd(modinfo->handle, MSG_SVS2SNO, TOK_SVS2SNO, m_svs2sno, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -76,11 +76,6 @@ DLLFUNC int MOD_LOAD(m_svssno)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_svssno)(int module_unload)
 {
-	if (del_Command(MSG_SVSSNO, TOK_SVSSNO, m_svssno) < 0 || del_Command(MSG_SVS2SNO, TOK_SVS2SNO, m_svs2sno) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svssno).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_svswatch.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_svswatch.c
+++ Unreal3.2.orig/src/modules/m_svswatch.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_svswatch)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_svswatch)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_SVSWATCH, TOK_SVSWATCH, m_svswatch, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SVSWATCH, TOK_SVSWATCH, m_svswatch, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -79,11 +76,6 @@ DLLFUNC int MOD_LOAD(m_svswatch)(int mod
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_svswatch)(int module_unload)
 {
-	if (del_Command(MSG_SVSWATCH, TOK_SVSWATCH, m_svswatch) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_svswatch).name);
-	}
 	return MOD_SUCCESS;	
 }
 
Index: Unreal3.2.orig/src/modules/m_swhois.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_swhois.c
+++ Unreal3.2.orig/src/modules/m_swhois.c
@@ -62,7 +62,7 @@ ModuleHeader MOD_HEADER(m_swhois)
 
 DLLFUNC int MOD_INIT(m_swhois)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_SWHOIS, TOK_SWHOIS, m_swhois, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_SWHOIS, TOK_SWHOIS, m_swhois, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -74,11 +74,6 @@ DLLFUNC int MOD_LOAD(m_swhois)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_swhois)(int module_unload)
 {
-	if (del_Command(MSG_SWHOIS, TOK_SWHOIS, m_swhois) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_swhois).name);
-	}
 	return MOD_SUCCESS;
 }
 /*
Index: Unreal3.2.orig/src/modules/m_time.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_time.c
+++ Unreal3.2.orig/src/modules/m_time.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_time)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_time)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_TIME, TOK_TIME, m_time, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_TIME, TOK_TIME, m_time, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -79,11 +76,6 @@ DLLFUNC int MOD_LOAD(m_time)(int module_
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_time)(int module_unload)
 {
-	if (del_Command(MSG_TIME, TOK_TIME, m_time) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_time).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_tkl.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_tkl.c
+++ Unreal3.2.orig/src/modules/m_tkl.c
@@ -161,14 +161,14 @@ DLLFUNC int MOD_INIT(m_tkl)(ModuleInfo *
 	/*
 	 * We call our add_Command crap here
 	*/
-	add_Command(MSG_GLINE, TOK_GLINE, m_gline, 3);
-	add_Command(MSG_SHUN, TOK_SHUN, m_shun, 3);
-	add_Command(MSG_TEMPSHUN, TOK_TEMPSHUN, m_tempshun, 2);
-	add_Command(MSG_ZLINE, TOK_NONE, m_tzline, 3);
-	add_Command(MSG_KLINE, TOK_NONE, m_tkline, 3);
-	add_Command(MSG_GZLINE, TOK_NONE, m_gzline, 3);
-	add_Command(MSG_SPAMFILTER, TOK_NONE, m_spamfilter, 6);
-	add_Command(MSG_TKL, TOK_TKL, _m_tkl, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_GLINE, TOK_GLINE, m_gline, 3, 0);
+	CommandAdd(modinfo->handle, MSG_SHUN, TOK_SHUN, m_shun, 3, 0);
+	CommandAdd(modinfo->handle, MSG_TEMPSHUN, TOK_TEMPSHUN, m_tempshun, 2, 0);
+	CommandAdd(modinfo->handle, MSG_ZLINE, TOK_NONE, m_tzline, 3, 0);
+	CommandAdd(modinfo->handle, MSG_KLINE, TOK_NONE, m_tkline, 3, 0);
+	CommandAdd(modinfo->handle, MSG_GZLINE, TOK_NONE, m_gzline, 3, 0);
+	CommandAdd(modinfo->handle, MSG_SPAMFILTER, TOK_NONE, m_spamfilter, 6, 0);
+	CommandAdd(modinfo->handle, MSG_TKL, TOK_TKL, _m_tkl, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -183,19 +183,6 @@ DLLFUNC int MOD_LOAD(m_tkl)(int module_l
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_tkl)(int module_unload)
 {
-	if ((del_Command(MSG_GLINE, TOK_GLINE, m_gline) < 0) ||
-	    (del_Command(MSG_SHUN, TOK_SHUN, m_shun) < 0 ) ||
-	    (del_Command(MSG_ZLINE, TOK_NONE, m_tzline) < 0) ||
-	    (del_Command(MSG_GZLINE, TOK_NONE, m_gzline) < 0) ||
-	    (del_Command(MSG_KLINE, TOK_NONE, m_tkline) < 0) ||
-	    (del_Command(MSG_SPAMFILTER, TOK_NONE, m_spamfilter) < 0) ||
-	    (del_Command(MSG_TEMPSHUN, TOK_TEMPSHUN, m_tempshun) < 0) ||
-	    (del_Command(MSG_TKL, TOK_TKL, _m_tkl) < 0))
-
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_tkl).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_topic.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_topic.c
+++ Unreal3.2.orig/src/modules/m_topic.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_topic)
 
 DLLFUNC int MOD_INIT(m_topic)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_TOPIC, TOK_TOPIC, m_topic, 4);
+	CommandAdd(modinfo->handle, MSG_TOPIC, TOK_TOPIC, m_topic, 4, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_topic)(int module
 
 DLLFUNC int MOD_UNLOAD(m_topic)(int module_unload)
 {
-	if (del_Command(MSG_TOPIC, TOK_TOPIC, m_topic) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_topic).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_trace.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_trace.c
+++ Unreal3.2.orig/src/modules/m_trace.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_trace)
 
 DLLFUNC int MOD_INIT(m_trace)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_TRACE, TOK_TRACE, m_trace, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_TRACE, TOK_TRACE, m_trace, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_trace)(int module
 
 DLLFUNC int MOD_UNLOAD(m_trace)(int module_unload)
 {
-	if (del_Command(MSG_TRACE, TOK_TRACE, m_trace) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_trace).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_tsctl.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_tsctl.c
+++ Unreal3.2.orig/src/modules/m_tsctl.c
@@ -64,7 +64,7 @@ DLLFUNC int MOD_INIT(m_tsctl)(ModuleInfo
 	/*
 	 * We call our add_Command crap here
 	*/
-	add_Command(MSG_TSCTL, TOK_TSCTL, m_tsctl, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_TSCTL, TOK_TSCTL, m_tsctl, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +78,6 @@ DLLFUNC int MOD_LOAD(m_tsctl)(int module
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_tsctl)(int module_unload)
 {
-	if (del_Command(MSG_TSCTL, TOK_TSCTL, m_tsctl) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_tsctl).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_umode2.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_umode2.c
+++ Unreal3.2.orig/src/modules/m_umode2.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_umode2)
 
 DLLFUNC int MOD_INIT(m_umode2)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_UMODE2, TOK_UMODE2, m_umode2, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_UMODE2, TOK_UMODE2, m_umode2, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_umode2)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_umode2)(int module_unload)
 {
-	if (del_Command(MSG_UMODE2, TOK_UMODE2, m_umode2) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_umode2).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_undccdeny.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_undccdeny.c
+++ Unreal3.2.orig/src/modules/m_undccdeny.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_undccdeny)
 
 DLLFUNC int MOD_INIT(m_undccdeny)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_UNDCCDENY, TOK_UNDCCDENY, m_undccdeny, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_UNDCCDENY, TOK_UNDCCDENY, m_undccdeny, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_undccdeny)(int mo
 
 DLLFUNC int MOD_UNLOAD(m_undccdeny)(int module_unload)
 {
-	if (del_Command(MSG_UNDCCDENY, TOK_UNDCCDENY, m_undccdeny) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_undccdeny).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_unkline.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_unkline.c
+++ Unreal3.2.orig/src/modules/m_unkline.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_unkline)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_unkline)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_UNKLINE, TOK_UNKLINE, m_unkline, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_UNKLINE, TOK_UNKLINE, m_unkline, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_unkline)(int modu
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_unkline)(int module_unload)
 {
-	if (del_Command(MSG_UNKLINE, TOK_UNKLINE, m_unkline) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_unkline).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_unsqline.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_unsqline.c
+++ Unreal3.2.orig/src/modules/m_unsqline.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_unsqline)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_unsqline)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_UNSQLINE, TOK_UNSQLINE, m_unsqline, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_UNSQLINE, TOK_UNSQLINE, m_unsqline, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_unsqline)(int mod
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_unsqline)(int module_unload)
 {
-	if (del_Command(MSG_UNSQLINE, TOK_UNSQLINE, m_unsqline) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_unsqline).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_unzline.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_unzline.c
+++ Unreal3.2.orig/src/modules/m_unzline.c
@@ -61,10 +61,7 @@ ModuleHeader MOD_HEADER(m_unzline)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_unzline)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_UNZLINE, TOK_UNZLINE, m_unzline, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_UNZLINE, TOK_UNZLINE, m_unzline, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -78,11 +75,6 @@ DLLFUNC int MOD_LOAD(m_unzline)(int modu
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_unzline)(int module_unload)
 {
-	if (del_Command(MSG_UNZLINE, TOK_UNZLINE, m_unzline) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_unzline).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_userhost.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_userhost.c
+++ Unreal3.2.orig/src/modules/m_userhost.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_userhost)
 
 DLLFUNC int MOD_INIT(m_userhost)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_USERHOST, TOK_USERHOST, m_userhost, 1);
+	CommandAdd(modinfo->handle, MSG_USERHOST, TOK_USERHOST, m_userhost, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_userhost)(int mod
 
 DLLFUNC int MOD_UNLOAD(m_userhost)(int module_unload)
 {
-	if (del_Command(MSG_USERHOST, TOK_USERHOST, m_userhost) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_userhost).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_vhost.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_vhost.c
+++ Unreal3.2.orig/src/modules/m_vhost.c
@@ -62,10 +62,7 @@ ModuleHeader MOD_HEADER(m_vhost)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_vhost)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_VHOST, TOK_VHOST, m_vhost, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_VHOST, TOK_VHOST, m_vhost, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -80,11 +77,6 @@ DLLFUNC int MOD_LOAD(m_vhost)(int module
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_vhost)(int module_unload)
 {
-	if (del_Command(MSG_VHOST, TOK_VHOST, m_vhost) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_vhost).name);
-	}
 	return MOD_SUCCESS;	
 }
 
Index: Unreal3.2.orig/src/modules/m_wallops.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_wallops.c
+++ Unreal3.2.orig/src/modules/m_wallops.c
@@ -60,7 +60,7 @@ ModuleHeader MOD_HEADER(m_wallops)
 
 DLLFUNC int MOD_INIT(m_wallops)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_WALLOPS, TOK_WALLOPS, m_wallops, 1);
+	CommandAdd(modinfo->handle, MSG_WALLOPS, TOK_WALLOPS, m_wallops, 1, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -72,11 +72,6 @@ DLLFUNC int MOD_LOAD(m_wallops)(int modu
 
 DLLFUNC int MOD_UNLOAD(m_wallops)(int module_unload)
 {
-	if (del_Command(MSG_WALLOPS, TOK_WALLOPS, m_wallops) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_wallops).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_who.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_who.c
+++ Unreal3.2.orig/src/modules/m_who.c
@@ -68,10 +68,7 @@ ModuleHeader MOD_HEADER(m_who)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_who)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_WHO, TOK_WHO, m_who, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_WHO, TOK_WHO, m_who, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -86,11 +83,6 @@ DLLFUNC int MOD_LOAD(m_who)(int module_l
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_who)(int module_unload)
 {
-	if (del_Command(MSG_WHO, TOK_WHO, m_who) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_who).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_whois.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_whois.c
+++ Unreal3.2.orig/src/modules/m_whois.c
@@ -63,10 +63,7 @@ ModuleHeader MOD_HEADER(m_whois)
 /* This is called on module init, before Server Ready */
 DLLFUNC int MOD_INIT(m_whois)(ModuleInfo *modinfo)
 {
-	/*
-	 * We call our add_Command crap here
-	*/
-	add_Command(MSG_WHOIS, TOK_WHOIS, m_whois, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_WHOIS, TOK_WHOIS, m_whois, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -80,11 +77,6 @@ DLLFUNC int MOD_LOAD(m_whois)(int module
 /* Called when module is unloaded */
 DLLFUNC int MOD_UNLOAD(m_whois)(int module_unload)
 {
-	if (del_Command(MSG_WHOIS, TOK_WHOIS, m_whois) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-				MOD_HEADER(m_whois).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/modules/m_whowas.c
===================================================================
--- Unreal3.2.orig.orig/src/modules/m_whowas.c
+++ Unreal3.2.orig/src/modules/m_whowas.c
@@ -61,7 +61,7 @@ ModuleHeader MOD_HEADER(m_whowas)
 
 DLLFUNC int MOD_INIT(m_whowas)(ModuleInfo *modinfo)
 {
-	add_Command(MSG_WHOWAS, TOK_WHOWAS, m_whowas, MAXPARA);
+	CommandAdd(modinfo->handle, MSG_WHOWAS, TOK_WHOWAS, m_whowas, MAXPARA, 0);
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -73,11 +73,6 @@ DLLFUNC int MOD_LOAD(m_whowas)(int modul
 
 DLLFUNC int MOD_UNLOAD(m_whowas)(int module_unload)
 {
-	if (del_Command(MSG_WHOWAS, TOK_WHOWAS, m_whowas) < 0)
-	{
-		sendto_realops("Failed to delete commands when unloading %s",
-			MOD_HEADER(m_whowas).name);
-	}
 	return MOD_SUCCESS;
 }
 
Index: Unreal3.2.orig/src/packet.c
===================================================================
--- Unreal3.2.orig.orig/src/packet.c
+++ Unreal3.2.orig/src/packet.c
@@ -23,13 +23,14 @@
 #include "sys.h"
 #include "msg.h"
 #include "h.h"
+#include "splaytree.h"
 #include <string.h>
 ID_Copyright
     ("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen");
 ID_Notes("2.12 1/30/94");
 
-aCommand	*CommandHash[256]; /* one per letter */
-aCommand	*TokenHash[256]; 
+SplayTree	*CommandTree = NULL;
+SplayTree	*TokenTree = NULL;
 
 /*
 ** dopacket
@@ -212,14 +213,9 @@ int  dopacket(aClient *cptr, char *buffe
 
 void	init_CommandHash(void)
 {
-#ifdef DEVELOP_DEBUG
-	aCommand	 *p;
-	int		 i;
-	long		chainlength;
-#endif
-	
-	bzero(CommandHash, sizeof(CommandHash));
-	bzero(TokenHash, sizeof(TokenHash));
+	CommandTree = splaytree_create(stricmp);
+	TokenTree = splaytree_create(stricmp);
+
 	add_CommandX(MSG_ERROR, TOK_ERROR, m_error, MAXPARA, M_UNREGISTERED|M_SERVER);
 	add_CommandX(MSG_VERSION, TOK_VERSION, m_version, MAXPARA, M_UNREGISTERED|M_USER|M_SERVER);
 	add_Command(MSG_SUMMON, NULL, m_summon, 1);
@@ -233,28 +229,6 @@ void	init_CommandHash(void)
 	add_Command(MSG_CREDITS, TOK_CREDITS, m_credits, MAXPARA);
 	add_Command(MSG_LICENSE, TOK_LICENSE, m_license, MAXPARA);
 	add_Command(MSG_MODULE, TOK_MODULE, m_module, MAXPARA);	
-		
-#ifdef DEVELOP_DEBUG
-	for (i = 0; i <= 255; i++)
-	{
-		chainlength = 0;
-		for (p = CommandHash[i]; p; p = p->next)
-			chainlength++;
-		if (chainlength)
-			fprintf(stderr, "%c chainlength = %i\r\n",
-					i, chainlength);
-	}				
-	fprintf(stderr, "Tokens:\n");
-	for (i = 0; i <= 255; i++)
-	{
-		chainlength = 0;
-		for (p = TokenHash[i]; p; p = p->next)
-			chainlength++;
-		if (chainlength)
-			fprintf(stderr, "%c chainlength = %i\r\n",
-					i, chainlength);
-	}				
-#endif
 }
 
 aCommand *add_Command_backend(char *cmd, int (*func)(), unsigned char parameters, unsigned char token, int flags)
@@ -268,11 +242,11 @@ aCommand *add_Command_backend(char *cmd,
 	newcmd->func = func;
 	newcmd->flags = flags;
 	
-	/* Add in hash with hash value = first byte */
 	if (!token)
-		AddListItem(newcmd, CommandHash[toupper(*cmd)]);
+		splaytree_add(CommandTree, cmd, newcmd);
 	else
-		AddListItem(newcmd, TokenHash[*cmd]);
+		splaytree_add(TokenTree, cmd, newcmd);
+
 	return newcmd;
 }
 
@@ -310,14 +284,15 @@ inline aCommand *find_CommandEx(char *cm
 	
 	if (!token)
 	{
-		for (p = CommandHash[toupper(*cmd)]; p; p = p->next)
-			if (!stricmp(p->cmd, cmd) && p->func == func)
-				return p;
+		if ((p = splaytree_retrieve(CommandTree, cmd)) != NULL)
+			return p;
+
 		return NULL;
 	}
-	for (p = TokenHash[*cmd]; p; p = p->next)
-		if (!strcmp(p->cmd, cmd) && p->func == func)
-			return p;
+
+	if ((p = splaytree_retrieve(TokenTree, cmd)) != NULL)
+		return p;
+
 	return NULL;
 	
 }
@@ -332,7 +307,7 @@ int del_Command(char *cmd, char *token, 
 	else
 	{
 		Cmdoverride *ovr, *ovrnext;
-		DelListItem(p, CommandHash[toupper(*cmd)]);
+		splaytree_delete(CommandTree, cmd);
 		for (ovr = p->overriders; ovr; ovr = ovrnext)
 		{
 			ovrnext = ovr->next;
@@ -349,7 +324,7 @@ int del_Command(char *cmd, char *token, 
 			i--;
 		else
 		{
-			DelListItem(p, TokenHash[*token]);
+			splaytree_delete(TokenTree, token);
 			if (p->cmd)
 				MyFree(p->cmd);
 			MyFree(p);
@@ -363,36 +338,47 @@ static inline aCommand *find_Token(char 
 {
 	aCommand *p;
 
-	for (p = TokenHash[*cmd]; p; p = p->next) {
+	if ((p = splaytree_retrieve(TokenTree, cmd)) != NULL)
+	{
 		if ((flags & M_UNREGISTERED) && !(p->flags & M_UNREGISTERED))
-			continue;
+			return NULL;
+
 		if ((flags & M_SHUN) && !(p->flags & M_SHUN))
-			continue;
+			return NULL;
+
 		if ((flags & M_VIRUS) && !(p->flags & M_VIRUS))
-			continue;
+			return NULL;
+
 		if ((flags & M_ALIAS) && !(p->flags & M_ALIAS))
-			continue;
-		if (!strcmp(p->cmd, cmd))
-			return p;
+			return NULL;
+
+		return p;
 	}
+
 	return NULL;
 }
 
 static inline aCommand *find_Cmd(char *cmd, int flags)
 {
 	aCommand *p;
-	for (p = CommandHash[toupper(*cmd)]; p; p = p->next) {
+
+	if ((p = splaytree_retrieve(CommandTree, cmd)) != NULL)
+	{
 		if ((flags & M_UNREGISTERED) && !(p->flags & M_UNREGISTERED))
-			continue;
+			return NULL;
+
 		if ((flags & M_SHUN) && !(p->flags & M_SHUN))
-			continue;
+			return NULL;
+
 		if ((flags & M_VIRUS) && !(p->flags & M_VIRUS))
-			continue;
+			return NULL;
+
 		if ((flags & M_ALIAS) && !(p->flags & M_ALIAS))
-			continue;
-		if (!stricmp(p->cmd, cmd))
-			return p;
+			return NULL;
+
+		return p;
 	}
+
 	return NULL;
 }
 
@@ -421,15 +407,9 @@ aCommand *find_Command_simple(char *cmd)
 {
 	aCommand	*p;
 	
-	for (p = CommandHash[toupper(*cmd)]; p; p = p->next) {
-		if (!stricmp(p->cmd, cmd))
-				return (p);
-	}
+	if ((p = splaytree_retrieve(CommandTree, cmd)) != NULL)
+		return p;
 
-	for (p = TokenHash[*cmd]; p; p = p->next) {
-		if (!strcmp(p->cmd, cmd))
-				return p;
-	}
 	return NULL;
 }
 
