Code cleanup in masterWindow()