Fix compilation

And small refactoring