There are many theories about what causes cramps. Some say that calcium, magnesium, potassium, salt, hydration etc. may help. If your bodyfat is below 7-8% some say that cramps are unavoidable because there is not optimal insulation of neurons. From what I've read lately, it seems that electrolyte imbalance is not considered anymore the main reason for cramps. It is more probable that cramps have something to do with a neural mechanism related to fatigue.
My personal experience has been that below a certain bf level cramps become more often when I'm tired. Avoiding overtraining and getting good rest has eliminated cramps for me.