Message deduplication.

It also fixes a hidden bug that was rendering the multipart mime
interface useless.