Fixes floating point rounding error and logs and exception