Fixed mem leaks