You really shouldn’t blame your B on the teacher. Plenty of students have poor teachers and find a way to make it work.
You need to worry less about what “they will see” and more about meeting your goals and getting a solid education.
Being a legacy doesn’t help much at Stanford. Thousands of legacies are denied every year.