Refactored main classes to reveal intent more clearly