Modify order of config file search, add some more error checking.