added global inv. and thread spawing to cfg-iteration