Further improvements to quoting and escaping