Fix and improve analytics