Code cleanup
Preparation for splitting configuration management
Split configuration management into default, external and database
Refactor configuration
Some other refactorings