improve metadata handling