Added util file and improved error handling in generator scripts