Separated utility functions to util.py.