Refactored Main class.