Refactor string functions, fix many defects.

Fair enough.

I must admit, when I was looking at it I was wondering why ResponseType returns a uint8_t rather than an enum, but I guess that's historical.