Refactoring MainWindow and eliminating it from the globals

Change-Id: Iba40a5b26d51c6e1ac2c4659d3bb5ae8dd36a4e6