Fix escaping and quote characters