diff --git a/scp/autocron.php b/scp/autocron.php
index eabc67151374c7d28eaf4895efe409f21652e5d9..d6ff919b359791e87caedd2f9b2c04dac7a397c0 100644
--- a/scp/autocron.php
+++ b/scp/autocron.php
@@ -39,14 +39,25 @@ ob_start(); //Keep the image output clean. Hide our dirt.
 $sec=time()-$_SESSION['lastcroncall'];
 $caller = $thisstaff->getUserName();
 
-if($sec>180 && $ost && !$ost->isUpgradePending()): //user can call cron once every 3 minutes.
+// Agent can call cron once every 3 minutes.
+if ($sec < 180 || !$ost || $ost->isUpgradePending())
+    ob_end_clean();
+
 require_once(INCLUDE_DIR.'class.cron.php');
 
-$thisstaff = null; //Clear staff obj to avoid false credit internal notes & auto-assignment
-Cron::TicketMonitor(); //Age tickets: We're going to age tickets regardless of cron settings.
+// Clear staff obj to avoid false credit internal notes & auto-assignment
+$thisstaff = null;
+
+// Release the session to prevent locking a future request while this is
+// running
+$_SESSION['lastcroncall'] = time();
+session_write_close();
+
+// Age tickets: We're going to age tickets regardless of cron settings.
+Cron::TicketMonitor();
 
-// Run file purging about every 30 minutes
-if (mt_rand(1, 9) == 4)
+// Run file purging about every 20 cron runs (1h40 on a five minute cron)
+if (mt_rand(1, 20) == 4)
     Cron::CleanOrphanedFiles();
 
 if($cfg && $cfg->isAutoCronEnabled()) { //ONLY fetch tickets if autocron is enabled!
@@ -57,7 +68,5 @@ if($cfg && $cfg->isAutoCronEnabled()) { //ONLY fetch tickets if autocron is enab
 $data = array('autocron'=>true);
 Signal::send('cron', $data);
 
-$_SESSION['lastcroncall']=time();
-endif;
 ob_end_clean();
 ?>