Major refactoring

Now much more object-oriented