Revert previous memory leak fix - it introduced a build warning.

Opened issue #908 to discuss the best solution.