Fix upstream detection