fixing mem leaks