Early refacto

Here is a first step.