fixed up memory leaks