Fix freed memory reference