Gets rid of unused entities.