better support for variable size batches
better error message