ENH: Attempt to rewrite the index parsing.

Some optimizations still missing.