Fix yet another bug with weight calculation.