Analytics refactoring