Im guessing that the engine is crashing because you are freeing the entities and the engines list of entities still has these dangling pointers to the entities that you freed.
Instead of "freeing" them, use pfnRemoveEntity in engine functions. (Thats same as REMOVE_ENTITY(edict_t*) ). That will allow the engine to do what it needs to ensure the edict you removed is not valid anymore.
