Reimplemented cross-validation.