Do bug fixes for DSC-834 and refactor EmailUtils.