extract generateId function from setId
speed improvements to pushBatch