several crash fixes