Refactor main classes