Implement batch processing
many bugfixes