Update Main.cs

Many bug fixes.
Merge pull request #2 from XGhozt00/patch-2

Many bug fixes, thanks Icy.