Revert reference generation to avoid premature freeing of resources