Some refactoring of the Entity class