Generalize bulk_operations logic

LMS-11366

@nasthagiri @cpennington please review
can remove this `#TODO` now since it's thread local.