Could you please move this and `do_batch` out one level so that they're methods on the object instead of inner functions?