fix for batch processing and some cleanup