Taking care of some memory leaks