Reduce duplication in metadata creation.
Reduce duplication in metadata handling.