Optimization code for indexing removed since it causes a memory overhead