Fix memory leak when updating existing nodes.