Refactor entities