static void Main(string[] args)
        {
            if (IsMono)
                Environment.CurrentDirectory = Path.GetDirectoryName(typeof(StarryboundServer).Assembly.Location);

            try
            {
                Process [] proc = Process.GetProcessesByName("starbound_server");
                proc[0].Kill();
            }
            catch (Exception) { }

            startTime = Utils.getTimestamp();

            serverState = ServerState.Starting;

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(ProcessExit);

            monitorThread = new Thread(new ThreadStart(StarryboundServer.crashMonitor));
            monitorThread.Start();

            Config.SetupConfig();
            ServerConfig.SetupConfig();
            Groups.SetupGroups();
            Users.SetupUsers();
            #if DEBUG
            StarryboundServer.config.logLevel = LogType.Debug;
            logDebug("Init", "This was compiled in DEBUG, forcing debug logging!");
            #endif
            serverConfig.maxPlayers = config.maxClients + 10;
            serverConfig.Write(ServerConfig.ConfigPath);

            writeLog("", LogType.FileOnly);
            writeLog("-- Log Start: " + DateTime.Now + " --", LogType.FileOnly);

            logInfo("##############################################");
            logInfo("####   Avilance Ltd. StarryBound Server   ####");
            logInfo("####   Copyright (c) Avilance Ltd. 2013   ####");
            logInfo("####       Licensed under the GPLv3       ####");
            logInfo("##############################################");
            logInfo("Version: " + VersionNum + " (" + ProtocolVersion + ")");
            #if !DEBUG
            if (config.logLevel == LogType.Debug)
            {
                logWarn("The logLevel in your config is currently set to DEBUG. This **WILL** flood your console and log file, if you do not want this please edit your config logLevel to INFO");
                logWarn("Launch will proceed in 5 seconds.");
                System.Threading.Thread.Sleep(5000);
            }
            #endif
            #if !NOSERVER
            if(config.proxyPort == config.serverPort)
            {
                logFatal("You cannot have the serverPort and proxyPort on the same port!");
                logFatal("Press any key to continue...");
                Console.ReadKey(true);
                Environment.Exit(0);
            }
            #endif
            //Precompute for global position search
            foreach(string sector in config.sectors)
            {
                sectors.Add(Encoding.UTF8.GetBytes(sector));
            }

            Bans.readBansFromFile();
            #if !NOSERVER
            sbServer = new ServerThread();
            sbServerThread = new Thread(new ThreadStart(sbServer.run));
            sbServerThread.Start();

            logInfo("Starting Starbound Server - This may take a few moments...");
            while (serverState != ServerState.StartingProxy) { if (serverState == ServerState.Crashed) return; }
            #endif
            logInfo("Starbound server is ready. Starting proxy wrapper.");

            ListenerThread listener = new ListenerThread();

            listenerThread = new Thread(new ThreadStart(listener.run));
            listenerThread.Start();
        }
        static void Main(string[] args)
        {
#if DEBUG
            config.logLevel = LogType.Debug;
#endif
            startTime = Utils.getTimestamp();
            changeState(ServerState.Starting, "StarryboundServer::Main");
            Console.Title = "Loading... Starrybound Server (" + VersionNum + ") (" + ProtocolVersion + ")";

            try
            {
                int     processId = Convert.ToInt32(File.ReadAllText("starbound_server.pid"));
                Process proc      = Process.GetProcessById(processId);
                proc.Kill();
                File.Delete("starbound_server.pid");
            }
            catch (Exception) { }

            monitorThread = new Thread(new ThreadStart(crashMonitor));
            monitorThread.Start();

            if (IsMono)
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(typeof(StarryboundServer).Assembly.Location);
            }

            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(ProcessExit);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);

            if (!IsMono)
            {
                NativeMethods.SetConsoleCtrlHandler(new NativeMethods.HandlerRoutine(ConsoleCtrlCheck), true);
            }

            BootstrapConfig.SetupConfig();

            writeLog("", LogType.FileOnly);
            writeLog("-- Log Start: " + DateTime.Now + " --", LogType.FileOnly);

            logInfo("##############################################");
            logInfo("####   Avilance Ltd. Starrybound Server   ####");
            logInfo("####   Copyright (c) Avilance Ltd. 2013   ####");
            logInfo("####       Licensed under the GPLv3       ####");
            logInfo("##############################################");
            logInfo("Version: " + VersionNum + " (" + ProtocolVersion + ")");
            logInfo("Loading Starrybound Server...");

            Config.SetupConfig();
            ServerConfig.SetupConfig();
            Groups.SetupGroups();
            Users.SetupUsers();
#if !DEBUG
            if (config.logLevel == LogType.Debug)
            {
                logWarn("The logLevel in your config is currently set to DEBUG. This **WILL** flood your console and log file, if you do not want this please edit your config logLevel to INFO");
                logWarn("Launch will proceed in 5 seconds.");
                System.Threading.Thread.Sleep(5000);
            }
#endif
#if !NOSERVER
            if (config.proxyPort == config.serverPort)
            {
                logFatal("You cannot have the serverPort and proxyPort on the same port!");
                Thread.Sleep(5000);
                Environment.Exit(3);
            }
#endif
            var geoippath = Path.Combine(SavePath, "GeoIP.dat");
            if (config.enableGeoIP && File.Exists(geoippath))
            {
                Geo = new GeoIPCountry(geoippath);
            }

            foreach (string sector in config.sectors)
            {
                byte[] sectorBytes = Encoding.UTF8.GetBytes(sector);
                byte[] buffer      = new byte[sectorBytes.Length + 1];
                buffer[0] = (byte)sectorBytes.Length;
                Buffer.BlockCopy(sectorBytes, 0, buffer, 1, sectorBytes.Length);
                sectors.Add(sectorBytes);
            }
            Bans.ProcessBans();
            Claims.LoadClaims();

            logInfo("Starrybound Server initialization complete.");

            listener       = new ListenerThread();
            listenerThread = new Thread(new ThreadStart(listener.runTcp));
            listenerThread.Start();

            udpThread = new Thread(new ThreadStart(listener.runUdp));
            udpThread.Start();

            while (serverState != ServerState.ListenerReady)
            {
            }
            if ((int)serverState > 3)
            {
                return;
            }

            Console.Title = "Starting... Starrybound Server (" + VersionNum + ") (" + ProtocolVersion + ")";
#if !NOSERVER
            logInfo("Starting parent Starbound server - This may take a few moments...");
            sbServer       = new ServerThread();
            sbServerThread = new Thread(new ThreadStart(sbServer.run));
            sbServerThread.Start();
            while (serverState != ServerState.StarboundReady)
            {
            }
            if ((int)serverState > 3)
            {
                return;
            }
#endif
            logInfo("Parent Starbound server is ready. Starrybound Server now accepting connections.");
            changeState(ServerState.Running, "StarryboundServer::Main");
        }
        static void Main(string[] args)
        {
            #if DEBUG
            config.logLevel = LogType.Debug;
            #endif
            startTime = Utils.getTimestamp();
            changeState(ServerState.Starting, "StarryboundServer::Main");
            Console.Title = "Loading... Starrybound Server (" + VersionNum + ") (" + ProtocolVersion + ")";

            try
            {
                int processId = Convert.ToInt32(File.ReadAllText("starbound_server.pid"));
                Process proc = Process.GetProcessById(processId);
                proc.Kill();
                File.Delete("starbound_server.pid");
            }
            catch (Exception) { }

            monitorThread = new Thread(new ThreadStart(crashMonitor));
            monitorThread.Start();

            if (IsMono)
                Environment.CurrentDirectory = Path.GetDirectoryName(typeof(StarryboundServer).Assembly.Location);

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(ProcessExit);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);

            if (!IsMono)
                NativeMethods.SetConsoleCtrlHandler(new NativeMethods.HandlerRoutine(ConsoleCtrlCheck), true);

            BootstrapConfig.SetupConfig();

            writeLog("", LogType.FileOnly);
            writeLog("-- Log Start: " + DateTime.Now + " --", LogType.FileOnly);

            logInfo("##############################################");
            logInfo("####   Avilance Ltd. Starrybound Server   ####");
            logInfo("####   Copyright (c) Avilance Ltd. 2013   ####");
            logInfo("####       Licensed under the GPLv3       ####");
            logInfo("##############################################");
            logInfo("Version: " + VersionNum + " (" + ProtocolVersion + ")");
            logInfo("Loading Starrybound Server...");

            Config.SetupConfig();
            ServerConfig.SetupConfig();
            Groups.SetupGroups();
            Users.SetupUsers();
            #if !DEBUG
            if (config.logLevel == LogType.Debug)
            {
                logWarn("The logLevel in your config is currently set to DEBUG. This **WILL** flood your console and log file, if you do not want this please edit your config logLevel to INFO");
                logWarn("Launch will proceed in 5 seconds.");
                System.Threading.Thread.Sleep(5000);
            }
            #endif
            #if !NOSERVER
            if(config.proxyPort == config.serverPort)
            {
                logFatal("You cannot have the serverPort and proxyPort on the same port!");
                Thread.Sleep(5000);
                Environment.Exit(3);
            }
            #endif
            var geoippath = Path.Combine(SavePath, "GeoIP.dat");
            if (config.enableGeoIP && File.Exists(geoippath))
                Geo = new GeoIPCountry(geoippath);

            foreach(string sector in config.sectors)
            {
                byte[] sectorBytes = Encoding.UTF8.GetBytes(sector);
                byte[] buffer = new byte[sectorBytes.Length + 1];
                buffer[0] = (byte)sectorBytes.Length;
                Buffer.BlockCopy(sectorBytes, 0, buffer, 1, sectorBytes.Length);
                sectors.Add(sectorBytes);
            }
            Bans.ProcessBans();

            logInfo("Starrybound Server initialization complete.");

            listener = new ListenerThread();
            listenerThread = new Thread(new ThreadStart(listener.runTcp));
            listenerThread.Start();

            udpThread = new Thread(new ThreadStart(listener.runUdp));
            udpThread.Start();

            while (serverState != ServerState.ListenerReady) { }
            if ((int)serverState > 3) return;

            Console.Title = "Starting... Starrybound Server (" + VersionNum + ") (" + ProtocolVersion + ")";
            #if !NOSERVER
            logInfo("Starting parent Starbound server - This may take a few moments...");
            sbServer = new ServerThread();
            sbServerThread = new Thread(new ThreadStart(sbServer.run));
            sbServerThread.Start();
            while (serverState != ServerState.StarboundReady) { }
            if ((int)serverState > 3) return;
            #endif
            logInfo("Parent Starbound server is ready. Starrybound Server now accepting connections.");
            changeState(ServerState.Running, "StarryboundServer::Main");
        }