Refactored utils, and added comments in the  needed places