do flattening before simpleOptPgm so evaluation "order" is not lost