Major refactoring

Obvious...