Refactor config

bug fix (details in comment mssgs)