Refactorings in minor updates in math module