repaired memory leaks