Fixed bug in error logging