Trying to fix the memory corruption in the entity creation.