Some minor refactoring and additions to support composite entity retrieval