Fix the range length bugs.