fixed some crashes in destructors