Simplify some maths and document them too