rework cleanup code and use not-in-working-set instead of non-document to short circuit