Added analytics and fixed bugs