More tweaks to email function