Reworked entity handling.

Now entites don't know anything about how they are persisted or deleted.
Everything about this is moved to an accessor interface. Example updated
accordingly.