Minor refactoring: Extract common logic and move classes
13 files changed