stats.php code cleanup