Add support for nested structures (and associated refactor)