Fixing error handling.