Suppporting unicode, escaping refs, fixed issus with added empty lines.