Inv gen

Merging for upward instantiation code so that it can be rewriten to work with condacts.