several fixes on error logging