enclose all math namespaces with IIFE
minor refactoring