tools.py None and integer comparison removed for Python3 compatibility