Refactored LDA module (first working version).