Better error message handling and added line breaks to email message.

Main code rev. 2016