Added batching and a few other changes.