what is the best way to heal sore cracked and bleeding nipples while breastfeeding?

Also is there any way to prevent this from happening?