fixed how entities are cleaned