Clean up code a bit, add missing notifications

This really should have been a series of commits, but I got a bit
carried away implementing the missing notification emails and
ended up doing the supporting refactorings as I went along.