Re-writing code for CAD+SVM.