move common stuff into metadata_utils