Fixed email formatting and refactored it a bit.