bunch of changes for N-gram topic model