Possible memory leaks fixed