Fix escaping in heredocs.
Merge branch 'master' into remote_home
Incorporate fixed here document escaping.