Improved error-handling.