Memory leaks solved