Refactored email system