Some tweaks in util.py