Use element for charts api loading. Additional code cleanup