Fixing memory leak pointed out by @cpw