Main class refactor