Tweaked error handling.