small fix to the entity clean up code