Nasty bug on rank calculation.