This commit refactors named types to be created lazily. Instead of defining all types in advance, do it only when necessary.