fixes for possible memory leaks