fixed memory leaks