Cleaned up email/notification code