Refactor the local worker so it can also handle the batches for groups.