Make generator more robust against unexpected metadata.

Use the logger here