fix some floating point bugs