What are you going to use this syrup for? How does it taste?
Texture is insignificant if you're using it in beer. It all dissolves, and whatever break is left, will either float or sink.
If you put it in the boil or add to a fermentor, it can be runny, as long as it has the flavor and color you want. It's actually preferred to have it well pourable and warm, it dissolves faster too that way.
For long term, unrefrigerated storage the moisture content should be very low, less than 5-10%, IIRC, or mold may form over time. I've stored syrups in the fridge or freezer for years.
Working the syrup at the "wrong" time can turn it into fudge-like consistency. If you've ever made fudge, the hard part is to know, while it's cooling down, at what exact point to start beating the heck out of it.
Excessive foaming means there's still a lot of water left (of course, it's thin), and you're heating it too fast. Just let it simmer slowly and it will evaporate, slowly. Turn the hood fan on for faster evaporation, or aim a fan over the pot. The trick is to keep the temp consistent. If you add more heat than the pot loses, the temps will go up, so find the balance where it stays put.
The first batch I made turned into one acrid dark brown mess from heating a little too and high too quickly, it had started to pyrolyze (burn). I learned that making sugar syrups takes time and patience, a watchful eye and some experience, recognizing tell tales of the process.
You can easily make D-1 (clear), D-5, or D-45 like syrups. D-90 is a lot harder, but doable, although you will end up with a different tasting product, not necessarily worse, it can be very yummy. Anything higher is about impossible. The factories uses special equipment and processes to prevent acrid flavors from developing. Perhaps under reduced pressure and in an oxygen free environment.