Improve math library build process