Refactor
Factor out functionality into standalone classes