Bug fixes and SVM cleanup