Refactor: extract classes, methods