Major rework of the system

This is a major rework of the system to support a more modular architecture.
This is a first commit so I can do some testing.