fixed some memory leaks (not all)