made lda.memoized more efficient
merged improved counting functions