Main class refactored