removed some memory leaks