Config/Env setup. Some refactoring.