Switched error handling to exceptions.