Improve escape()/unescape() function