Refactor Math packages