Refactor metadata to new structure.