BZ-11403, BZ-11405, BZ-11406: fix errors in math