public static void Main(string[] args)
        {
            if (args.Length == 1 && args[0].ToLower() == "setup" || !File.Exists(Application.ExecutablePath + "Configuration.ini"))
            {
                ChannelServerSetup.Run();
            }

            int port = 0;

start:
            ChannelServer.Clients = new List <ChannelClientHandler>();

            Log.Entitle("Channel Server v.{0}.{1}", Application.MapleVersion, Application.PatchVersion);

            try
            {
                if (port == 0)
                {
                    try
                    {
                        port = int.Parse(args[0]);
                    }
                    catch
                    {
                        port = Log.Input("Port: ", 7575);
                    }
                }

                Settings.Initialize();
                Shortcuts.Apply();

                ChannelServer.AutoRestartTime = Settings.GetInt("Server/AutoRestartTime");
                Log.Inform("Automatic restart time set to {0} seconds.", ChannelServer.AutoRestartTime);

                Database.Test();
                Database.Analyze(true);

                ChannelServer.LoggedIn = new List <int>(Settings.GetInt("Server/MaxUsers"));
                Log.Inform("Maximum of {0} simultaneous online users.", ChannelServer.LoggedIn.Capacity);

                ChannelServer.RemoteEndPoint = new IPEndPoint(Settings.GetIPAddress("Server/ExternalIP"), port);

                ChannelData.Initialize();

                ChannelServer.Listener = new TcpListener(IPAddress.Any, ChannelServer.RemoteEndPoint.Port);
                ChannelServer.Listener.Start();
                Log.Inform("Initialized clients listener on {0}.", ChannelServer.Listener.LocalEndpoint);

                ChannelServer.IsAlive = true;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            if (ChannelServer.IsAlive)
            {
                Log.Success("Channel server started.");

                new Thread(new ThreadStart(InteroperabilityClient.Main)).Start();
            }
            else
            {
                Log.Inform("Could not start server because of errors.");
            }

            while (ChannelServer.IsAlive)
            {
                ChannelServer.AcceptDone.Reset();

                ChannelServer.Listener.BeginAcceptSocket(new AsyncCallback(ChannelServer.OnAcceptSocket), null);

                ChannelServer.AcceptDone.WaitOne();
            }

            ChannelClientHandler[] remainingClients = ChannelServer.Clients.ToArray();

            foreach (ChannelClientHandler client in remainingClients)
            {
                client.Stop();
            }

            ChannelServer.Dispose();

            Log.Warn("Server stopped.");

            if (ChannelServer.AutoRestartTime > 0)
            {
                Log.Inform("Attempting auto-restart in {0} seconds.", ChannelServer.AutoRestartTime);
                Thread.Sleep(ChannelServer.AutoRestartTime * 1000);
                goto start;
            }
            else
            {
                Console.Read();
            }
        }