Generating classes for nested types