Improve shell character escaping in various situations. Fixes #18, #22