Changed generate program so that it can output traces