Added emailing of errors and exception error handeling