Memory leaks fixed