Add topic analysis. Refactoring code.