Some memory leaks removed.