just an idea, if it'd be worth to make a function _round() for the "((Real) ((Int) (p * 100000))) / 100000.0;" which occures on a couple of lines here?