BuildMainWindow() refactor