Value escaping, and json length fixes