Fixing some memory leaks.