Fixed bugs in NGramHandler