For all zeros input, the result was <1,0,0,0> but we were producing <0,0,0,.5> because the first branch was taken. Fixed. We forgot to take the square root when calculating the magnitude of the quaternion while normalizing. Fixed. Use qnz instead of special casing.