Fixes to error logging