Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -140,24 +140,25 @@
   JsEnginePtr result(new JsEngine(isolate, std::move(timer)));
 
   const v8::Locker locker(result->GetIsolate());
   const v8::Isolate::Scope isolateScope(result->GetIsolate());
   const v8::HandleScope handleScope(result->GetIsolate());
 
   result->context.reset(new v8::Persistent<v8::Context>(result->GetIsolate(),
     v8::Context::New(result->GetIsolate())));
-  AdblockPlus::GlobalJsObject::Setup(*result, appInfo, result->GetGlobalObject());
+  auto global = result->GetGlobalObject();
+  AdblockPlus::GlobalJsObject::Setup(*result, appInfo, global);
   return result;
 }
 
-AdblockPlus::JsValuePtr AdblockPlus::JsEngine::GetGlobalObject()
+AdblockPlus::JsValue AdblockPlus::JsEngine::GetGlobalObject()
 {
   JsContext context(shared_from_this());
-  return JsValuePtr(new JsValue(shared_from_this(), context.GetV8Context()->Global()));
+  return JsValue(shared_from_this(), context.GetV8Context()->Global());
 }
 
 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& source,
     const std::string& filename)
 {
   const JsContext context(shared_from_this());
   const v8::TryCatch tryCatch;
   const v8::Handle<v8::Script> script = CompileScript(GetIsolate(), source,
@@ -321,15 +322,13 @@
   if (!val)
     throw std::runtime_error("LogSystem cannot be null");
 
   logSystem = val;
 }
 
 
 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
-                                              const AdblockPlus::JsValuePtr& value)
+                                              const AdblockPlus::JsValue& value)
 {
   auto global = GetGlobalObject();
-  if (!global)
-    throw std::runtime_error("Global object cannot be null");
-  global->SetProperty(name, value);
+  global.SetProperty(name, value);
 }
