Redesigned timecollect finction. Various optimization of indexing function

Redesigned timecollect finction
Various optimization of indexing function