Include Peter's changes ; update the doc ; refactor the code to prepare for 'make toMathJax'.