fix metadata handling