Fix issue with indexing, check for working right in single and multithread