Fix some escaping issues (thanks @gregwebs)