Refactor configuration
Some other refactorings