When fixing node references, index by node so that we do not need to lookup nodes multiple times.