The code by H.T.U was nearly right
just vice versa.
First FreeEntity
Then Delete
if you delete the type first, you can not access it to get the entity
just vice versa.
First FreeEntity
Then Delete
if you delete the type first, you can not access it to get the entity