refactor MainFrame; new class for tools-related code