First pass at refactoring to make more OOP.