Misc bug fixes in analytics