Fix template issues and email exception handling.