Cleanup and additions to math.fs