Smarter cleanup