Indexing performance

Fixing the problem with getting very small batches to index and other minor fixes.