Fix several name reference rules.