Refactor utils/py/collect