Memory leaks fix #1