/// <summary>
        /// Will unload from memory the domain that was created.
        /// </summary>
        /// <param name="msg"></param>
        private void unloadDomain(string msg)
        {
            try {
                if (domain != null) {
                    cont = false;
                    Util.Wake(this);
                    AppDomain.Unload(domain);
                    domain = null;
                    proxy = null;

                    listening.Clear();
                    DB.Print("Domain unloaded and listeners removed (" + msg + ")", Levels.SCRIPTS);
                }
            } catch (Exception e) {
                DB.Exception(e, "Exception unloading domain", Levels.SCRIPTS);
            }
        }
        private void init()
        {
            baseFolder = loadConfigValues(configFile);
            if (baseFolder == null)
                return;

            AppDomain rootDomain = AppDomain.CurrentDomain;

            try {
                if (domain == null) {
                    AppDomainSetup domainSetup = new AppDomainSetup();

                    domainSetup.ConfigurationFile = Path.GetFullPath(configFile);
                    domainSetup.ApplicationBase = baseFolder;
                    domainSetup.ShadowCopyFiles = "true";

                    string name = configFile.Replace(".config", "");
                    name = name.Substring(name.LastIndexOf('/') + 1);

                    domain = AppDomain.CreateDomain(name, null, domainSetup);
                }

                string assembly = GetType().Assembly.Location;
                Object[] args = new Object[] { rootDomain };
                DB.Print("Creating root", Levels.SCRIPTS);

                proxy = (Root)domain.CreateInstanceFromAndUnwrap(assembly, "scripts.Root", false, BindingFlags.CreateInstance, null, args, null, null, null);
                if (proxy.Shutdown)
                    unloadDomain("Shutdown flagged after creating root");
                else
                    DB.Print("Root created", Levels.SCRIPTS);
            } catch (Exception e) {
                DB.Exception(e, "Problem creating root", Levels.SCRIPTS);
                unloadDomain("Exception creating root");
            }
        }