Some global variables moved to global infrastructure, minor cleanup in MainFrame.