Fix memory leaks.