Reorganise code

Merged Bastien Nocera requested to merge wip/hadess/reorganise-code into master

To make it a bit easier to port to meson.

Merge request reports