Fix for bad reference to freed memory.