Smarter escape string

Implements a fix for #114; use single or double quotes for string escaping depending on the context