improved cleanup