Main infrastructure and first tests
Minor refactoring + documentation