fixed memory bugs in ksvm