Separate part of the util package into math, closes #1014