Clean up main frame and move common functionality to MainFrameCommon