Changed error handling.