Fix crashes from fixing memory leaks.