Fix node index calculation.