Better debug info for crashes, and fixed a crash