Make emailed error messages configurable.

And some misc code cleanup.