Refactoring of entity processing