Improved parsing of maths