Some refactorings

I didn't check the test suite for now as it's only stylistic changes.