Refactored logging and emailing for IoC.