Many modifications to adapt it to run SVM, improved cross-validation