Modifications to speed up the RangeIndex creation.

Two major changes:
- use foldLeft instead of foldRight
- using the new ReferenceFolding framework, in order to lower the
  pressure put on garbage collection by the large number of extra
  objects that were being created.