even more refacture and rename to make it work with metamodels (not tested yet)