Refactor MainPanel