Fixed cleanup accumulating invalid entities.

The cleanup library would continue to track entities it had already removed. It now empties an entity list after using it for cleanup.