fix several crashes