Fixed bug in batchsd for uneven batches