Small refactor to batch api.