More ad-hoc handling of metadata.

Fixes I found in production. I'll refactor this comprehensively over the
weekend.

Change-Id: Ie37a8cdb8912bfa07fbdeadd214fb4df3a4a7222