Memory leaks problem solved