Naive Bayes memory leak fix

Please merge.