Check empty string invariants, instead of assuming all strings are allocated. And reset strings when they are freed.