Corrected some memory leaks