adds statistics reporting on errors