Corrected memory leaks