Fixed some issues in ngrams.