wip: fixed and simplified the toBatchXXX() methods.