Add utils.py and move relevant stuff there