Refactor into better classes