Refactor into classes