Fixed a bug with training set generation