public void TerminateCore()
 {
     if (Core != null)
     {
         Core.Disconnect();
         Core = null;
         if (ModuleManage != null)
         {
             foreach (BlackLight.Services.Modules.BlackLightModule tModule in ModuleManage.Modules)
             {
                 tModule.ModUnload();
             }
             while (ModuleManage.Modules.Count > 0)
             {
                 ModuleManage.Modules[0] = null;
                 ModuleManage.Modules.RemoveAt(0);
             }
             ModuleManage = null;
         }
         if (timerController != null)
         {
             timerController.Dispose();
             timerController = null;
         }
         if (_timerChecker != null)
         {
             _timerChecker.Abort();
             _timerChecker = null;
         }
         if (ConfigManager != null&& ConfigManager.Configuration != null)
         {
             ConfigManager.Configuration.Clear();
             ConfigManager.Configuration = null;
         }
         if (ConfigManager != null)
         {
             ConfigManager = null;
         }
         Core_LogMessage("ServicesDaemon", "TerminateCore()", BlackLight.Services.Error.Errors.DEBUG, "Core Terminated", "", "", "");
     }
     else
     {
         Core_LogMessage("ServicesDaemon", "TerminateCore()", BlackLight.Services.Error.Errors.DEBUG, "Core already terminated", "", "", "");
     }
 }
            /// -----------------------------------------------------------------------------
            /// <summary>
            /// Initiates entire services
            /// </summary>
            /// <remarks>
            /// Begins by loading all modules,continues by starting timers,
            /// and finishes by beginning the connection to the remote server
            /// </remarks>
            /// <history>
            /// 	[Caleb]	6/18/2005	Created
            /// </history>
            /// -----------------------------------------------------------------------------
            public void Begin()
            {
                try
                {
                    AddText("Begining" + "\r\n");
                    BlackLight.Services.Config.ConfigurationReturn configReturn = ConfigManager.Load("services.conf");
                    //Exit Sub
                    foreach (string tReturn in configReturn.Data)
                    {
                AddText("Config: " + tReturn + "\r\n");
                    }
                    if (configReturn.Loaded == true)
                    {
                        AddText("Configuration loaded" + "\r\n");
                    }
                    else
                    {
                        AddText("Configuration failed to load" + "\r\n");
                        return;
                    }

                    AddText("Config Items" + "\r\n");

                    foreach (string tItem2 in ConfigManager.Configuration.Keys)
                    {
                        AddText(tItem2 + "\r\n");
                        foreach (string tItem3 in ((BlackLight.Services.Config.OptionsList) ConfigManager.Configuration[tItem2]).Keys)
                        {
                            AddText(tItem2 + "::" + tItem3 + "->" +((BlackLight.Services.Config.OptionsList) ConfigManager.Configuration[tItem2])[tItem3] + "\r\n");
                        }
                    }

                    //After we load the config the FIRST thing we need todo is try and set the IRCd protocol
                    //The core will auto initialize with a default of unreal, we can change that from a config property
                    string remotehost = "";
                    string remoteport;
                    if (ConfigManager.Configuration.ContainsKey("services"))
                    {
                        BlackLight.Services.Config.OptionsList myConfig = ConfigManager.Configuration["services"];
                        if (myConfig.ContainsKey("protocol"))
                        {
                            Core.MyIRCd.SetProtocol(myConfig["protocol"]);
                        }
                        if (myConfig.ContainsKey("remote-host"))
                        {
                            remotehost = myConfig["remote-host"].Trim();
                        }
                        else
                        {
                            Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.FATAL, "Missing directive: remote-host", "", "", "");
                            return;
                        }
                        if (myConfig.ContainsKey("remote-port"))
                        {
                            remoteport = myConfig["remote-port"].Trim();
                        }
                        else
                        {
                            Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.FATAL, "Missing directive: remote-port", "", "", "");
                            return;
                        }
                    }
                    else
                    {
                        Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.FATAL, "Failed to find services configuration block", "", "", "");
                        return;
                    }
                    if (!Core.MyIRCd.LoadProtocol())
                    {
                        AddText("Failed to load Protocol\r\n");
                       // return;
                    }
                    //Timer Stuff
                    timerController = new BlackLight.Services.Timers.TimerController(this);
                    _timerChecker = new System.Threading.Thread(new System.Threading.ThreadStart(timerController.Begin));
                    _timerChecker.Start();
                    //End Timer Stuff

                    ArrayList tModules = new ArrayList();
                    ArrayList tDataDriver = new ArrayList();
                    foreach (BlackLight.Services.Config.OptionsList tItem in ConfigManager.Configuration.GetSet("modules"))
                    {
                        foreach (string tOption in tItem.GetSet("loadmodule"))
                        {
                            tModules.Add(tOption);
                        }
                    }
                    foreach (BlackLight.Services.Config.OptionsList tItem in ConfigManager.Configuration.GetSet("modules"))
                    {
                        foreach (string tOption in tItem.GetSet("loaddatadriver"))
                        {
                            tDataDriver.Add(tOption);
                        }
                    }
                    ModuleManage = new ModuleManagement(this);

                    //Module Stuff
                    //Dim tModules As String() = {"NickServ.dll", "ChanServ.dll", "DebugServ.dll", "FloodServ.dll", "Help.dll"}
                    if (tDataDriver.Count > 1)
                    {
                        Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Configuration contains multiple loads for datadriver", "Using first in list", "", "");
                        ModuleManage.LoadDataDriver(System.Convert.ToString(tDataDriver[0]));
                    }
                    else if (tDataDriver.Count == 0)
                    {
                        Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Configuration contains no load for datadriver", "", "", "");
                    }
                    else
                    {
                        ModuleManage.LoadDataDriver(System.Convert.ToString(tDataDriver[0]));
                    }
                    tDataDriver = null;
                    DataDriver = ((BlackLight.Services.DB.DataDriver) ModuleManage.Modules[ModuleManage.DataDriver]);
                    ModuleManage.LoadModules((string[]) tModules.ToArray(typeof(string)));
                    int tIndex;
                    for (tIndex = 0; tIndex <= ModuleManage.Modules.Count - 1; tIndex++)
                    {
                        AddText(ModuleManage.Modules[tIndex].Name + "\r\n");
                    }
                AddText("DataDriver: " + DataDriver.Name + "\r\n");
                    //End Module Stuff
                    tModules = null;

                    //Table1.newcol
                    //Dim Table2 As New Table
                    //Dim DataBase As New DataBase
                    //Table1.NewColumn("id", GetType(Integer))
                    //Table1.Columns("id").AutoIncrement = True
                    //Table1.Columns("id").AutoIncrementSeed = 1
                    //Table1.NewColumn("host", GetType(String))

                    //Table1.NewColumn("nickname", GetType(String))
                    //Table1.NewColumn("host", GetType(String))
                    //Table1.NewColumn("registered", GetType(Int32))

                    //DataBase.AddTable(Table1)
                    //DataBase.AddTable(Table2)

                    //AddText(DataBase.Tables.Count & vbCrLf)
                    //DataDriver.SaveDB("test.xml", DataBase)
                    //Exit Sub

                    if (remotehost == "")
                    {
                        Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.FATAL, "Directive contains invalid data: remote-port", "", "", "");
                        return;
                    }
                    if (remoteport == "")
                    {
                        Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.FATAL, "Directive contains invalid data: remote-port", "", "", "");
                        return;
                    }
                    else
                    {
                        try
                        {
                            int.Parse(remoteport);
                        }
                        catch (Exception ex)
                        {
                            Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.FATAL, "Directive contains invalid data: remote-port", "", ex.Message, ex.StackTrace);
                            return;
                        }
                    }
                    Core.Connect(remotehost, int.Parse(remoteport));
                }
                catch (Exception ex)
                {
                    Core_LogMessage("ServicesDaemon", "Begin()", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.FATAL, "Unable to complete startup rutine", "", ex.Message, ex.StackTrace);
                }
            }