Fix some memory leaks.