Implement entity creation and querying, plus some helper functions.