Moved some of the HTML generation into the js api