Refactor email preferences

Based on Craig's work here: #625

I've just done a tiny bit of cleanup (and squashed the commits).