#488 Reorganized utils.py and added some comments