Refactoring to allow linking math library