Added more verbose error handling.