modified configuration load code, now more generic and efficient