Bug fix to prevent hanging on error.