fixes for memory leaks