Modified previous memory leak fix.