An unpleasant grainy texture is caused by crystalizing sugar during heating. This can occur from uneven heating or heating that is too high. Crystalizing sugar can also occur on the sides of the pan and are stirred down into the toffee where they cause further crystalizing. To prevent crystalizing, heat the mixture at medium-low, stirring slowly and gently. Try to avoid splashing the sides of the pan. If some of the sugar mixture does get on the sides, use a pastry brush dipped in water to wash the sugar back into the pan. Adding a tablespoon of corn syrup to the sugar and butter, before heating, can also help prevent crystallization.