Performed some micro-optimisations in the maths library