working on some memory leaks