Refactor IQDB and convert to Python 3.