Refactor main class.