Class Abstraction and General Refactoring

A ton of refactoring.