Entity relations refactoring