Fix node merging to stop losing edges.