Fixed genMainProg to work properly