Stirring the sugar while it's boiling can do that. Using corn syrup or making sure no sugar sticks to the pan's sides can help.