Extracted the main function into a new class.