Enhanced the divmod function inside polytools.py