entity management refactoring