email code clean up