fixed bug that occured when tmplCleanup gets called before MathJax's typesetting finishes