Major refactor to use three classes