Made math library use templates. Also added x, y, z, w for vectors.