Refactor reading config files