refactoring config and other fixes