Factor out math library
Factor out math library