Make a important update. Encapsulate functions into lda class. Fix some bugs.