remove div by zero, possibly sped up by moving a realToFrac and multiplying instead of dividing