further refactoring of metadata handling