analytics events, code cleanup