Most of the DOM manipulations can be done before doing the AJAX call. This leaves just the insertion of the MathML nodes in the mrow for the AJAX callback function. Also, make the stroke-width for the connector tool default to 2.