Index: src/plugin/AdblockPlusDomTraverser.cpp
===================================================================
--- a/src/plugin/AdblockPlusDomTraverser.cpp
+++ b/src/plugin/AdblockPlusDomTraverser.cpp
@@ -12,12 +12,12 @@
 }
 
 
-bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent)
+bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const std::wstring& url, CString& indent)
 {
   CPluginClient* client = CPluginClient::GetInstance();
 
   // If src should be blocked, set style display:none on iframe
-  bool isBlocked = client->ShouldBlock(to_wstring(url), CFilter::contentTypeSubdocument, m_domain);
+  bool isBlocked = client->ShouldBlock(url, CFilter::contentTypeSubdocument, m_domain);
   if (isBlocked)
   {
     HideElement(pEl, "iframe", url, true, indent);
@@ -40,7 +40,7 @@
   cache->m_isHidden = client->IsElementHidden(to_wstring(tag), pEl, m_domain, to_wstring(indent), m_tab->m_filter.get());
   if (cache->m_isHidden)
   {
-    HideElement(pEl, tag, "", false, indent);
+    HideElement(pEl, tag, L"", false, indent);
     return false;
   }
 
@@ -51,11 +51,11 @@
 
     if (SUCCEEDED(pEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt == VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0)
     {
-      CString src = vAttr.bstrVal;
-      CPluginClient::UnescapeUrl(src);
+      std::wstring src(vAttr.bstrVal, SysStringLen(vAttr.bstrVal));
+      UnescapeUrl(src);
 
       // If src should be blocked, set style display:none on image
-      cache->m_isHidden = client->ShouldBlock(to_wstring(src), CFilter::contentTypeImage, m_domain);
+      cache->m_isHidden = client->ShouldBlock(src, CFilter::contentTypeImage, m_domain);
       if (cache->m_isHidden)
       {
         HideElement(pEl, "image", src, true, indent);
@@ -92,7 +92,7 @@
         {
           if (cache->m_isHidden)
           {
-            HideElement(pEl, "object", src, true, indent);
+            HideElement(pEl, "object", ToWstring(src), true, indent);
             return false;
           }
         }
@@ -114,7 +114,7 @@
 }
 
 
-void CPluginDomTraverser::HideElement(IHTMLElement* pEl, const CString& type, const CString& url, bool isDebug, CString& indent)
+void CPluginDomTraverser::HideElement(IHTMLElement* pEl, const CString& type, const std::wstring& url, bool isDebug, CString& indent)
 {
   CComPtr<IHTMLStyle> pStyle;
 
@@ -131,12 +131,12 @@
 
     if (SUCCEEDED(pStyle->put_display(sbstrNone)))
     {
-      DEBUG_HIDE_EL(indent + L"HideEl::Hiding " + type + L" url:" + url)
+      DEBUG_HIDE_EL(indent + L"HideEl::Hiding " + type + L" url:" + ToCString(url))
 
 #ifdef ENABLE_DEBUG_RESULT
         if (isDebug)
         {
-          CPluginDebug::DebugResultHiding(type, url, "-");
+          CPluginDebug::DebugResultHiding(type, ToCString(url), "-");
         }
 #endif // ENABLE_DEBUG_RESULT
     }
Index: src/plugin/AdblockPlusDomTraverser.h
===================================================================
--- a/src/plugin/AdblockPlusDomTraverser.h
+++ b/src/plugin/AdblockPlusDomTraverser.h
@@ -29,12 +29,12 @@
 
 protected:
 
-  bool OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent);
+  bool OnIFrame(IHTMLElement* pEl, const std::wstring& url, CString& indent);
   bool OnElement(IHTMLElement* pEl, const CString& tag, CPluginDomTraverserCache* cache, bool isDebug, CString& indent);
 
   bool IsEnabled();
 
-  void HideElement(IHTMLElement* pEl, const CString& type, const CString& url, bool isDebug, CString& indent);
+  void HideElement(IHTMLElement* pEl, const CString& type, const std::wstring& url, bool isDebug, CString& indent);
 
 };
 
Index: src/plugin/PluginClass.cpp
===================================================================
--- a/src/plugin/PluginClass.cpp
+++ b/src/plugin/PluginClass.cpp
@@ -202,26 +202,23 @@
   return browser;
 }
 
-CString CPluginClass::GetBrowserUrl() const
+std::wstring CPluginClass::GetBrowserUrl() const
 {
-  CString url;
-
+  std::wstring url;
   CComQIPtr<IWebBrowser2> browser = GetBrowser();
   if (browser)
   {
     CComBSTR bstrURL;
-
-    if (SUCCEEDED(browser->get_LocationURL(&bstrURL)))
+    if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL)
     {
-      url = bstrURL;
-      CPluginClient::UnescapeUrl(url);
+      url = std::wstring(bstrURL, SysStringLen(bstrURL));
+      UnescapeUrl(url);
     }
   }
   else
   {
     url = m_tab->GetDocumentUrl();
   }
-
   return url;
 }
 
@@ -555,13 +552,16 @@
   }
 
   // Get the URL
-  CString url;
-  vt = pDispParams->rgvarg[5].vt;
-  if (vt == VT_BYREF + VT_VARIANT)
+  std::wstring url;
+  const auto& arg = pDispParams->rgvarg[5];
+  vt = arg.vt;
+  if (vt == (VT_BYREF | VT_VARIANT) && arg.pvarVal->vt == VT_BSTR)
   {
-    url = pDispParams->rgvarg[5].pvarVal->bstrVal;
-
-    CPluginClient::UnescapeUrl(url);
+    BSTR b = arg.pvarVal->bstrVal;
+    if (b) {
+      url = std::wstring(b, SysStringLen(b));
+      UnescapeUrl(url);
+    }
   }
   else
   {
@@ -571,25 +571,25 @@
 
   // If webbrowser2 is equal to top level browser (as set in SetSite), we are navigating new page
   CPluginClient* client = CPluginClient::GetInstance();
-
-  if (url.Find(L"javascript") == 0)
+  CString urlLegacy = ToCString(url);
+  if (urlLegacy.Find(L"javascript") == 0)
   {
   }
   else if (GetBrowser().IsEqualObject(WebBrowser2Ptr))
   {
     m_tab->OnNavigate(url);
 
-    DEBUG_GENERAL(L"================================================================================\nBegin main navigation url:" + url + "\n================================================================================")
+    DEBUG_GENERAL(L"================================================================================\nBegin main navigation url:" + urlLegacy + "\n================================================================================")
 
 #ifdef ENABLE_DEBUG_RESULT
-      CPluginDebug::DebugResultDomain(url);
+      CPluginDebug::DebugResultDomain(urlLegacy);
 #endif
 
     UpdateStatusBar();
   }
   else
   {
-    DEBUG_NAVI(L"Navi::Begin navigation url:" + url)
+    DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy)
     m_tab->CacheFrame(url);
   }
 }
@@ -731,12 +731,11 @@
           CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal;
           if (pBrowser)
           {
-            CString url;
             CComBSTR bstrUrl;
-            if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && ::SysStringLen(bstrUrl) > 0)
+            if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && bstrUrl && ::SysStringLen(bstrUrl) > 0)
             {
-              url = bstrUrl;
-              CPluginClient::UnescapeUrl(url);
+              std::wstring url = std::wstring(bstrUrl, SysStringLen(bstrUrl));
+              UnescapeUrl(url);
               m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBrowser));
             }
           }
@@ -1160,7 +1159,7 @@
   return S_OK;
 }
 
-HMENU CPluginClass::CreatePluginMenu(const CString& url)
+HMENU CPluginClass::CreatePluginMenu(const std::wstring& url)
 {
   DEBUG_GENERAL("CreatePluginMenu");
   HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance();
@@ -1267,14 +1266,14 @@
   case ID_MENU_DISABLE_ON_SITE:
     {
       CPluginSettings* settings = CPluginSettings::GetInstance();
-      CString urlString = GetTab()->GetDocumentUrl();
-      if (client->IsWhitelistedUrl(to_wstring(urlString)))
+      std::wstring urlString = GetTab()->GetDocumentUrl();
+      if (client->IsWhitelistedUrl(urlString))
       {
-        settings->RemoveWhiteListedDomain(to_CString(client->GetHostFromUrl(to_wstring(urlString))));
+        settings->RemoveWhiteListedDomain(to_CString(client->GetHostFromUrl(urlString)));
       }
       else
       {
-        settings->AddWhiteListedDomain(to_CString(client->GetHostFromUrl(to_wstring(urlString))));
+        settings->AddWhiteListedDomain(to_CString(client->GetHostFromUrl(urlString)));
       }
       GetBrowser()->Refresh();
     }
@@ -1287,7 +1286,7 @@
 }
 
 
-bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url)
+bool CPluginClass::SetMenuBar(HMENU hMenu, const std::wstring& url)
 {
   DEBUG_GENERAL("SetMenuBar");
 
@@ -1307,8 +1306,8 @@
   {
     ctext = dictionary->Lookup("menu", "menu-disable-on-site");
     // Is domain in white list?
-    ReplaceString(ctext, L"?1?", client->GetHostFromUrl(to_wstring(url)));
-    if (client->IsWhitelistedUrl(to_wstring(GetTab()->GetDocumentUrl())))
+    ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url));
+    if (client->IsWhitelistedUrl(GetTab()->GetDocumentUrl()))
     {
       fmii.fState = MFS_CHECKED | MFS_ENABLED;
     }
@@ -1522,7 +1521,7 @@
 }
 
 
-HICON CPluginClass::GetStatusBarIcon(const CString& url)
+HICON CPluginClass::GetStatusBarIcon(const std::wstring& url)
 {
   // use the disable icon as defualt, if the client doesn't exists
   HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED);
@@ -1533,7 +1532,7 @@
     CPluginClient* client = CPluginClient::GetInstance();
     if (CPluginSettings::GetInstance()->IsPluginEnabled())
     {
-      if (client->IsWhitelistedUrl(ToWstring(url)))
+      if (client->IsWhitelistedUrl(url))
       {
         hIcon = GetIcon(ICON_PLUGIN_DISABLED);
       }
@@ -1651,14 +1650,14 @@
   case WM_LBUTTONUP:
   case WM_RBUTTONUP:
     {
-      CString strURL = pClass->GetBrowserUrl();
-      if (strURL != pClass->GetTab()->GetDocumentUrl())
+      std::wstring url = pClass->GetBrowserUrl();
+      if (url != pClass->GetTab()->GetDocumentUrl())
       {
-        pClass->GetTab()->SetDocumentUrl(strURL);
+        pClass->GetTab()->SetDocumentUrl(url);
       }
 
       // Create menu
-      HMENU hMenu = pClass->CreatePluginMenu(strURL);
+      HMENU hMenu = pClass->CreatePluginMenu(url);
       if (!hMenu)
       {
         return 0;
Index: src/plugin/PluginClass.h
===================================================================
--- a/src/plugin/PluginClass.h
+++ b/src/plugin/PluginClass.h
@@ -81,8 +81,8 @@
 
 private:
 
-  bool SetMenuBar(HMENU hMenu, const CString& url);
-  HMENU CreatePluginMenu(const CString& url);
+  bool SetMenuBar(HMENU hMenu, const std::wstring& url);
+  HMENU CreatePluginMenu(const std::wstring& url);
 
   void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFlags);
   bool CreateStatusBarPane();
@@ -101,15 +101,14 @@
 
 private:
 
-  CString GetBrowserUrl() const;
-
+  std::wstring GetBrowserUrl() const;
 
   static DWORD WINAPI StartInitObject(LPVOID thisPtr);
   bool InitObject(bool bBHO);
   void CloseTheme();
   void UpdateTheme();
 
-  static HICON GetStatusBarIcon(const CString& url);
+  static HICON GetStatusBarIcon(const std::wstring& url);
   static CPluginClass* FindInstance(HWND hStatusBarWnd);
   static LRESULT CALLBACK NewStatusProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
   static LRESULT CALLBACK PaneWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
Index: src/plugin/PluginClientBase.cpp
===================================================================
--- a/src/plugin/PluginClientBase.cpp
+++ b/src/plugin/PluginClientBase.cpp
@@ -39,24 +39,6 @@
 {
 }
 
-
-CString& CPluginClientBase::UnescapeUrl(CString& url)
-{
-  CString unescapedUrl;
-  DWORD cb = 2048;
-
-  if (SUCCEEDED(::UrlUnescape(url.GetBuffer(), unescapedUrl.GetBufferSetLength(cb), &cb, 0)))
-  {
-    unescapedUrl.ReleaseBuffer();
-    unescapedUrl.Truncate(cb);
-
-    url.ReleaseBuffer();
-    url = unescapedUrl;
-  }
-
-  return url;
-}
-
 void UnescapeUrl(std::wstring& url)
 {
   try
Index: src/plugin/PluginClientBase.h
===================================================================
--- a/src/plugin/PluginClientBase.h
+++ b/src/plugin/PluginClientBase.h
@@ -67,8 +67,6 @@
 
   static void SetLocalization();
 
-  static CString& UnescapeUrl(CString& url);
-
   static void LogPluginError(DWORD errorCode, int errorId, int errorSubid, const CString& description="", bool isAsync=false, DWORD dwProcessId=0, DWORD dwThreadId=0);
 
   static void PostPluginError(int errorId, int errorSubid, DWORD errorCode, const CString& errorDescription);
Index: src/plugin/PluginDebug.cpp
===================================================================
--- a/src/plugin/PluginDebug.cpp
+++ b/src/plugin/PluginDebug.cpp
@@ -183,12 +183,12 @@
 }
 
 
-void CPluginDebug::DebugResultBlocking(const CString& type, const CString& src, const std::wstring& domain)
+void CPluginDebug::DebugResultBlocking(const CString& type, const std::wstring& src, const std::wstring& domain)
 {
-  CString srcTrunc = src;
-  if (srcTrunc.GetLength() > 100)
+  CString srcTrunc = ToCString(src);
+  if (src.length() > 100)
   {
-    srcTrunc = src.Left(67) + L"..." + src.Right(30);
+    srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30);
   }
 
   CString blocking;
@@ -198,12 +198,12 @@
 }
 
 
-void CPluginDebug::DebugResultHiding(const CString& tag, const CString& src, const CString& filter)
+void CPluginDebug::DebugResultHiding(const CString& tag, const CString& id, const CString& filter)
 {
-  CString srcTrunc = src;
+  CString srcTrunc = id;
   if (srcTrunc.GetLength() > 100)
   {
-    srcTrunc = src.Left(67) + L"..." + src.Right(30);
+    srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30);
   }
 
   CString blocking;
@@ -227,12 +227,12 @@
 
 #ifdef ENABLE_DEBUG_RESULT_IGNORED
 
-void CPluginDebug::DebugResultIgnoring(const CString& type, const CString& src, const std::wstring& domain)
+void CPluginDebug::DebugResultIgnoring(const CString& type, const std::wstring& src, const std::wstring& domain)
 {
-  CString srcTrunc = src;
-  if (srcTrunc.GetLength() > 100)
+  CString srcTrunc = ToCString(src);
+  if (src.length() > 100)
   {
-    srcTrunc = src.Left(67) + L"..." + src.Right(30);
+    srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30);
   }
 
   CString blocking;
Index: src/plugin/PluginDebug.h
===================================================================
--- a/src/plugin/PluginDebug.h
+++ b/src/plugin/PluginDebug.h
@@ -17,13 +17,13 @@
 #if (defined ENABLE_DEBUG_RESULT)
   static void DebugResult(const CString& text);
   static void DebugResultDomain(const CString& domain);
-  static void DebugResultBlocking(const CString& type, const CString& src, const std::wstring& domain);
+  static void DebugResultBlocking(const CString& type, const std::wstring& src, const std::wstring& domain);
   static void DebugResultHiding(const CString& tag, const CString& id, const CString& filter);
   static void DebugResultClear();
 #endif
 
 #if (defined ENABLE_DEBUG_RESULT_IGNORED)
-  static void DebugResultIgnoring(const CString& type, const CString& src, const std::wstring& domain);
+  static void DebugResultIgnoring(const CString& type, const std::wstring& src, const std::wstring& domain);
 #endif
 };
 
Index: src/plugin/PluginDomTraverserBase.h
===================================================================
--- a/src/plugin/PluginDomTraverserBase.h
+++ b/src/plugin/PluginDomTraverserBase.h
@@ -27,14 +27,14 @@
 
   void TraverseHeader(bool isHeaderTraversed);
 
-  void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const CString& documentName);
+  void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const std::wstring& documentName);
   void TraverseSubdocument(IWebBrowser2* pBrowser, const std::wstring& domain, const CString& documentName);
 
   virtual void ClearCache();
 
 protected:
 
-  virtual bool OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent) { return true; }
+  virtual bool OnIFrame(IHTMLElement* pEl, const std::wstring& url, CString& indent) { return true; }
   virtual bool OnElement(IHTMLElement* pEl, const CString& tag, T* cache, bool isDebug, CString& indent) { return true; }
 
   virtual bool IsEnabled();
@@ -86,7 +86,7 @@
 }
 
 template <class T>
-void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const CString& documentName)
+void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const std::wstring& documentName)
 {
   m_domain = domain;
 
@@ -220,16 +220,14 @@
         CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch;
         if (pFrameBrowser)
         {
+          std::wstring src;
           CComBSTR bstrSrc;
-          CString src;
-
-          if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc)))
+          if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc)) && bstrSrc)
           {
-            src = bstrSrc;
-            CPluginClient::UnescapeUrl(src);
+            src = std::wstring(bstrSrc,SysStringLen(bstrSrc));
+            UnescapeUrl(src);
           }
-
-          if (!src.IsEmpty())
+          if (!src.empty())
           {
             TraverseDocument(pFrameBrowser, false, indent);
           }
@@ -264,22 +262,22 @@
 
           if (SUCCEEDED(pFrameEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt == VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0)
           {
-            CString src = vAttr.bstrVal;
+            CString srcLegacy = vAttr.bstrVal;
 
             // Some times, domain is missing. Should this be added on image src's as well?''
 
             // eg. gadgetzone.com.au
-            if (src.Left(2) == L"//")
+            if (srcLegacy.Left(2) == L"//")
             {
-              src = L"http:" + src;
+              srcLegacy = L"http:" + srcLegacy;
             }
             // eg. http://w3schools.com/html/html_examples.asp
-            else if (src.Left(4) != L"http" && src.Left(6) != L"res://")
+            else if (srcLegacy.Left(4) != L"http" && srcLegacy.Left(6) != L"res://")
             {
-              src = L"http://" + to_CString(m_domain) + src;
+              srcLegacy = L"http://" + to_CString(m_domain) + srcLegacy;
             }
-
-            CPluginClient::UnescapeUrl(src);
+            std::wstring src(ToWstring(srcLegacy));
+            UnescapeUrl(src);
 
             // Check if Iframe should be traversed
             if (OnIFrame(pFrameEl, src, indent))
Index: src/plugin/PluginFilter.cpp
===================================================================
--- a/src/plugin/PluginFilter.cpp
+++ b/src/plugin/PluginFilter.cpp
@@ -565,7 +565,7 @@
         {
 #ifdef ENABLE_DEBUG_RESULT
           DEBUG_HIDE_EL(indent + "HideEl::Found (tag/id) filter:" + idIt->second.m_filterText)
-            CPluginDebug::DebugResultHiding(tagCString, "id:" + id, idIt->second.m_filterText);
+            CPluginDebug::DebugResultHiding(tagCString, L"id:" + id, idIt->second.m_filterText);
 #endif
           return true;
         }
@@ -579,7 +579,7 @@
         {
 #ifdef ENABLE_DEBUG_RESULT
           DEBUG_HIDE_EL(indent + "HideEl::Found (?/id) filter:" + idIt->second.m_filterText)
-            CPluginDebug::DebugResultHiding(tagCString, "id:" + id, idIt->second.m_filterText);
+            CPluginDebug::DebugResultHiding(tagCString, L"id:" + id, idIt->second.m_filterText);
 #endif
           return true;
         }
@@ -602,7 +602,7 @@
           {
 #ifdef ENABLE_DEBUG_RESULT
             DEBUG_HIDE_EL(indent + "HideEl::Found (tag/class) filter:" + classIt->second.m_filterText)
-              CPluginDebug::DebugResultHiding(tagCString, "class:" + className, classIt->second.m_filterText);
+              CPluginDebug::DebugResultHiding(tagCString, L"class:" + className, classIt->second.m_filterText);
 #endif
             return true;
           }
@@ -705,15 +705,14 @@
 
 bool CPluginFilter::ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug) const
 {
-  CString srcCString = to_CString(src);
+  std::wstring srcTrimmed = TrimString(src);
 
   // We should not block the empty string, so all filtering does not make sense
   // Therefore we just return
-  if (srcCString.Trim().IsEmpty())
+  if (srcTrimmed.empty())
   {
     return false;
   }
-
   CPluginSettings* settings = CPluginSettings::GetInstance();
 
   CString type;
@@ -729,20 +728,20 @@
   }
 
   CPluginClient* client = CPluginClient::GetInstance();
-  if (client->Matches(to_wstring(srcCString), to_wstring(type), domain))
+  if (client->Matches(srcTrimmed, to_wstring(type), domain))
   {
     if (addDebug)
     {
       DEBUG_FILTER("Filter::ShouldBlock " + type + " YES")
 
 #ifdef ENABLE_DEBUG_RESULT
-        CPluginDebug::DebugResultBlocking(type, srcCString, domain);
+        CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain);
 #endif
     }
     return true;
   }
 #ifdef ENABLE_DEBUG_RESULT
-  CPluginDebug::DebugResultIgnoring(type, srcCString, domain);
+  CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain);
 #endif
   return false;
 }
Index: src/plugin/PluginTabBase.cpp
===================================================================
--- a/src/plugin/PluginTabBase.cpp
+++ b/src/plugin/PluginTabBase.cpp
@@ -73,7 +73,7 @@
   }
 }
 
-void CPluginTabBase::OnNavigate(const CString& url)
+void CPluginTabBase::OnNavigate(const std::wstring& url)
 {
   SetDocumentUrl(url);
   ClearFrameCache(GetDocumentDomain());
@@ -96,7 +96,7 @@
 void CPluginTabBase::InjectABP(IWebBrowser2* browser)
 {
   CriticalSection::Lock lock(m_csInject);
-  CString url = GetDocumentUrl();
+  CString url = ToCString(GetDocumentUrl());
   CString log;
   log.Format(L"InjectABP. Current URL: %s, settings URL: %s", url, UserSettingsFileUrl().c_str());
   DEBUG_GENERAL(log);
@@ -157,7 +157,7 @@
 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser)
 {
   CPluginClient* client = CPluginClient::GetInstance();
-  std::wstring url = to_wstring(GetDocumentUrl());
+  std::wstring url = GetDocumentUrl();
   if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(url))
   {
     m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl());
@@ -165,9 +165,9 @@
   InjectABP(browser);
 }
 
-void CPluginTabBase::OnDocumentComplete(IWebBrowser2* browser, const CString& url, bool isDocumentBrowser)
+void CPluginTabBase::OnDocumentComplete(IWebBrowser2* browser, const std::wstring& url, bool isDocumentBrowser)
 {
-  CString documentUrl = GetDocumentUrl();
+  std::wstring documentUrl = GetDocumentUrl();
 
   if (isDocumentBrowser)
   {
@@ -177,7 +177,8 @@
     }
     InjectABP(browser);
   }
-  if (url.Left(6) != "res://")
+  CString urlLegacy = ToCString(url);
+  if (urlLegacy.Left(6) != "res://")
   {
     // Get document
     CComPtr<IDispatch> pDocDispatch;
@@ -224,19 +225,19 @@
   return domain;
 }
 
-void CPluginTabBase::SetDocumentUrl(const CString& url)
+void CPluginTabBase::SetDocumentUrl(const std::wstring& url)
 {
   m_criticalSection.Lock();
   {
     m_documentUrl = url;
-    m_documentDomain = CAdblockPlusClient::GetInstance()->GetHostFromUrl(to_wstring(url));
+    m_documentDomain = CAdblockPlusClient::GetInstance()->GetHostFromUrl(url);
   }
   m_criticalSection.Unlock();
 }
 
-CString CPluginTabBase::GetDocumentUrl()
+std::wstring CPluginTabBase::GetDocumentUrl()
 {
-  CString url;
+  std::wstring url;
 
   m_criticalSection.Lock();
   {
@@ -251,7 +252,7 @@
 // ============================================================================
 // Frame caching
 // ============================================================================
-bool CPluginTabBase::IsFrameCached(const CString& url)
+bool CPluginTabBase::IsFrameCached(const std::wstring& url)
 {
   bool isFrame;
 
@@ -264,7 +265,7 @@
   return isFrame;
 }
 
-void CPluginTabBase::CacheFrame(const CString& url)
+void CPluginTabBase::CacheFrame(const std::wstring& url)
 {
   m_criticalSectionCache.Lock();
   {
Index: src/plugin/PluginTabBase.h
===================================================================
--- a/src/plugin/PluginTabBase.h
+++ b/src/plugin/PluginTabBase.h
@@ -23,7 +23,7 @@
   CriticalSection m_csInject;
 
   std::wstring m_documentDomain;
-  CString m_documentUrl;
+  std::wstring m_documentUrl;
   CPluginUserSettings m_pluginUserSettings;
 public:
   CPluginClass* m_plugin;
@@ -43,9 +43,9 @@
 
   void ThreadProc();
   CComAutoCriticalSection m_criticalSectionCache;
-  std::set<CString> m_cacheFrames;
+  std::set<std::wstring> m_cacheFrames;
   std::wstring m_cacheDomain;
-  void SetDocumentUrl(const CString& url);
+  void SetDocumentUrl(const std::wstring& url);
   void InjectABP(IWebBrowser2* browser);
 public:
 
@@ -53,15 +53,15 @@
   ~CPluginTabBase();
 
   std::wstring GetDocumentDomain();
-  CString GetDocumentUrl();
+  std::wstring GetDocumentUrl();
   virtual void OnActivate();
   virtual void OnUpdate();
-  virtual void OnNavigate(const CString& url);
+  virtual void OnNavigate(const std::wstring& url);
   virtual void OnDownloadComplete(IWebBrowser2* browser);
-  virtual void OnDocumentComplete(IWebBrowser2* browser, const CString& url, bool isDocumentBrowser);
+  virtual void OnDocumentComplete(IWebBrowser2* browser, const std::wstring& url, bool isDocumentBrowser);
   static DWORD WINAPI TabThreadProc(LPVOID pParam);
-  void CacheFrame(const CString& url);
-  bool IsFrameCached(const CString& url);
+  void CacheFrame(const std::wstring& url);
+  bool IsFrameCached(const std::wstring& url);
   void ClearFrameCache(const std::wstring& domain=L"");
 
 };
Index: src/plugin/PluginWbPassThrough.cpp
===================================================================
--- a/src/plugin/PluginWbPassThrough.cpp
+++ b/src/plugin/PluginWbPassThrough.cpp
@@ -109,14 +109,15 @@
   return CFilter::contentTypeAny;
 }
 
-int WBPassthruSink::GetContentTypeFromURL(const CString& src)
+int WBPassthruSink::GetContentTypeFromURL(const std::wstring& src)
 {
-  CString srcExt = src;
+  CString srcLegacy = ToCString(src);
+  CString srcExt = srcLegacy;
 
   int pos = 0;
-  if ((pos = src.Find('?')) > 0)
+  if ((pos = srcLegacy.Find('?')) > 0)
   {
-    srcExt = src.Left(pos);
+    srcExt = srcLegacy.Left(pos);
   }
 
   int lastDotIndex = srcExt.ReverseFind('.');
@@ -150,7 +151,7 @@
   return CFilter::contentTypeAny;
 }
 
-int WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const CString& src)
+int WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const std::wstring& src)
 {
   // No referer or mime type
   // BINDSTRING_XDR_ORIGIN works only for IE v8+
@@ -305,15 +306,15 @@
 
   if (tab && client)
   {
-    CString documentUrl = tab->GetDocumentUrl();
+    std::wstring documentUrl = tab->GetDocumentUrl();
     // Page is identical to document => don't block
-    if (documentUrl == ToCString(src))
+    if (documentUrl == src)
     {
       return nativeHr;
     }
-    else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhitelistedUrl(std::wstring(documentUrl)))
+    else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhitelistedUrl(documentUrl))
     {
-      if (tab->IsFrameCached(ToCString(src)))
+      if (tab->IsFrameCached(src))
       {
         m_contentType = CFilter::contentTypeSubdocument;
       }
Index: src/plugin/PluginWbPassThrough.h
===================================================================
--- a/src/plugin/PluginWbPassThrough.h
+++ b/src/plugin/PluginWbPassThrough.h
@@ -20,8 +20,8 @@
 	bool m_isCustomResponse;
 
 	int GetContentTypeFromMimeType(const CString& mimeType);
-	int GetContentTypeFromURL(const CString& src);
-	int GetContentType(const CString& mimeType, const std::wstring& domain, const CString& src);
+  int GetContentTypeFromURL(const std::wstring& src);
+  int GetContentType(const CString& mimeType, const std::wstring& domain, const std::wstring& src);
 	bool IsFlashRequest(const wchar_t* const* additionalHeaders);
 public:
 	BEGIN_COM_MAP(WBPassthruSink)
