Fixed some bugs in analytics