Optimization: in-place splitting of training set