backport clean_up.php from master