Refactor analytic module