Some work on the email system.

Still needs lots of love.