improved math detection. Now escaped dollar signs are ignored