Added (somewhat) graceful bug recovery.