Fix a couple edge cases in non-overlapping case.
Fix Rank, Select, and Index to work properly. Add tests.