If grainy then look again at the dissolving stage for the sugar, make sure that you have no lumps left that can burn or seed later.
Second, the early stages of gentle agitaion during cooling are also important. I knead mine to get a uniform paste, if you pour direct to a mould you'll also get a...