Fixes to the maths function.