Analytics refactoring

Change-Id: I90bc963d51a3898fade2852497ef5b7bcf0af851