PIM-3244 : re-work memory leak fix to ensure backward compatibility