Fixed crash when removing entities