fix threaded crashes