Refactoring of maths package.