Log/error handling refactoring for xrefgen.