Fixing up error logging