Refactor into multiple classes and views