Improve error reporting for bad target references.