builds out most of reindex code.