Small refactoring again with metadata gathering.