Added more sophisticated and user-controller error handling.