Improved flag handling, added version number, escaping single-quotes in strings