Fix ws string reallocs

Includes guards in case realloc fails.
I know _someone_ who will say that the indendation has to be fixed here.