* Rewrite internals to use EmailProvider instead of raw db access * Minor changes to APIs as necessary (and scattered changes to follow) * Convert unit tests and check them