Update Main.cs

Many bug fixes, thanks Icy.