Fixed issue with negative indices, optimized solve7, fixed problem with
test set being the same as training set.