Mem leaks fixed