Fix handling of recursive templates in ProxyMetadata