Refactoring, add a RecordIndexer, more indexing logic, ping @mdarse