Naive Bayes memory leak fix

This is a quite important memory leak fix, found with valgrind.