Statelessify mathjaxutils

First step toward fixing #3596.

The code in this part of javascript would really need to be looked at.

 - [x] cleanup unused variables
 - [x] patch headercell with new version.