http://whatscookingamerica.net/ChocolateMelting.htm
I checked this site as I, also, have problems at times. When you melt chocolate, it cannot get above a certain temperature or it will get grainy. Did not know that! They said something about water getting in the chocolate. Did you thaw the chocolate before you melted it? Maybe add the sugar slowly?