Fix some bugs in analytics