Refactored the Main Window