add more checks around division in rtgeom routines, code clean up