Refactoring attempt

Attempting to refactor code to place classes more logically. Doesn't run
at the moment.