Simplified class hierarchy; cleaned up solution