Added errorlogging.