Refactor generated code a little
Add support for substitutionGroups for elements