Refactor things into util.py.