math library moved in, code clean up