Improve support for AppleScript (fixes #168)