fixed some mem leaks