Fix bug in cleanup.