Cleaned up code in MainForm