Modified cleanupUnused()