Tweaked error handling