new cleanup functions moved to core.php