Massive code refactoring

Split up the big monolithic main class into much smaller classes.  Also
split out the "solving" logic from the Engine enum because that was
making me nauseous.