Possible fix for bug #11595

I'm not 100% on this, mostly for the string stuff.
But I think it is a fix for https://issues.dlang.org/show_bug.cgi?id=11595
Need comments explaining what this block of code is doing.