bulk of lootsie and analytics code