diff --git a/core/CronArchive.php b/core/CronArchive.php
index 89848e4c3c3b2d42d1ea1747fc3ad236bb059d3d..eff5e0277d901aa28204467a6f6bddfef179a329 100644
--- a/core/CronArchive.php
+++ b/core/CronArchive.php
@@ -857,6 +857,8 @@ class CronArchive
 
         $config->log = $log;
 
+        Log::unsetInstance();
+
         // Make sure we log at least INFO (if logger is set to DEBUG then keep it)
         $logLevel = Log::getInstance()->getLogLevel();
         if ($logLevel < Log::INFO) {
@@ -1211,7 +1213,7 @@ class CronArchive
 
         $today = end($stats);
 
-        if (empty($today)) {
+        if (empty($today['nb_visits'])) {
             return 0;
         }
 
diff --git a/plugins/API/API.php b/plugins/API/API.php
index e40aaec20eb6131850bb811333408a4c0184b2e8..e7470b2ab0c45e7070f923580d9358f900e70b7a 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -441,6 +441,10 @@ class API extends \Piwik\Plugin\API
         }
 
         $firstRow1 = $table1->getFirstRow();
+        if (empty($firstRow1)) {
+            $firstRow1 = $table1->addRow(new Row());
+        }
+
         $firstRow2 = $table2->getFirstRow();
         if ($firstRow2 instanceof Row) {
             foreach ($firstRow2->getColumns() as $metric => $value) {