diff --git a/core/ArchiveProcessor/Parameters.php b/core/ArchiveProcessor/Parameters.php
index 70bb06e0ecede1dc210ff6688ab33f48accd27e2..49729a4da72212fb2a4c88bb9309a1158c450a22 100644
--- a/core/ArchiveProcessor/Parameters.php
+++ b/core/ArchiveProcessor/Parameters.php
@@ -170,7 +170,7 @@ class Parameters
             $temporary = 'temporary archive';
         }
         Log::verbose(
-            "'%s, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]",
+            "%s archive, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]",
             $this->getPeriod()->getLabel(),
             $this->getSite()->getId(),
             $temporary,
diff --git a/core/FrontController.php b/core/FrontController.php
index e86aceff7899f21517503f186cdb5ba5b71d2a5a..bd010eb93608aed160d97f88ea78dbf27ec91e36 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -275,9 +275,6 @@ class FrontController extends Singleton
             Filechecks::dieIfDirectoriesNotWritable($directoriesToCheck);
             self::assignCliParametersToRequest();
 
-            if(!empty($_GET['xhprof'])) {
-                Profiler::setupProfilerXHProf($mainRun = false);
-            }
 
             Translate::loadEnglishTranslation();
 
@@ -289,6 +286,7 @@ class FrontController extends Singleton
 
             $this->handleMaintenanceMode();
             $this->handleSSLRedirection();
+            $this->handleProfiler();
 
             $pluginsManager = \Piwik\Plugin\Manager::getInstance();
             $pluginsToLoad = Config::getInstance()->Plugins['Plugins'];
@@ -492,6 +490,14 @@ class FrontController extends Singleton
             }
         }
     }
+
+    private function handleProfiler()
+    {
+        if (!empty($_GET['xhprof'])) {
+            $mainRun = $_GET['xhprof'] == 1; // archive.php sets xhprof=2
+            Profiler::setupProfilerXHProf($mainRun);
+        }
+    }
 }
 
 /**
diff --git a/core/Profiler.php b/core/Profiler.php
index 7a0f2b0d399f02587a05d652f8e842f8656bddae..ec48788471cf388189b6bb35e6857b878985becb 100644
--- a/core/Profiler.php
+++ b/core/Profiler.php
@@ -227,7 +227,7 @@ class Profiler
             if($mainRun) {
                 $runIds = implode(',', $runs);
                 $out = "\n\nHere is the profiler URL aggregating all runs triggered from this process: ";
-                $baseUrl = "http://" . $_SERVER['HTTP_HOST'] . "/" . $_SERVER['REQUEST_URI'];
+                $baseUrl = "http://" . @$_SERVER['HTTP_HOST'] . "/" . @$_SERVER['REQUEST_URI'];
                 $baseUrlStored = SettingsPiwik::getPiwikUrl();
                 if(strlen($baseUrlStored) > strlen($baseUrl)) {
                     $baseUrl = $baseUrlStored;
@@ -237,7 +237,7 @@ class Profiler
                 $out .= $baseUrl . "$runIds\n\n";
                 $out .= "Main run profile:";
                 $out .= $baseUrl . "$runId\n\n";
-                Log::info($out);
+                echo ($out);
             } else {
                 self::setProfilingRunIds($runs);
             }
@@ -247,7 +247,7 @@ class Profiler
     private static function setProfilingRunIds($ids)
     {
         file_put_contents( self::getPathToXHProfRunIds(), json_encode($ids) );
-        chmod(self::getPathToXHProfRunIds(), 0777);
+        @chmod(self::getPathToXHProfRunIds(), 0777);
     }
 
     private static function getProfilingRunIds()
diff --git a/misc/cron/archive.php b/misc/cron/archive.php
index dbc947eb4b812e3d96e6260fbb46c926ca1ce7c5..8dc70bd0eee581d1b9befd643669a4f05ebf7d6d 100644
--- a/misc/cron/archive.php
+++ b/misc/cron/archive.php
@@ -632,7 +632,7 @@ class CronArchive
         $url = $this->piwikUrl . $url . self::APPEND_TO_API_REQUEST;
 
         if($this->shouldStartProfiler) {
-            $url .= "&xhprof=1";
+            $url .= "&xhprof=2";
         }
 
         //$this->log($url);