Use URI.encode instead of CGI::escape everywhere