Improvements and fixes in cegqi arithmetic (#2247)