Removed some memory leaks