Better name lookup when checking if a type is used