Refactoring config, introducing database support