Improved batch processing, plus bugfix on statistics generation