Untangle batch processing logic