Improve speed of FpsToIdx and FpsScan