Change things so that sending mail doesn't rely on the program underneath to close the ports. Also do some small, task-related cleanup.