Rewrote batching algorithm to be simpler.
Mean of data is now calculated correctly when last batch doesn't contain the same number of images.