Main class refactored one more time.