Refactor main class