Cleanup error handling
Factor out input parsing into separate classes for better maintainability