Added smarter batchingn to training