improved $cfg_fn to use local file if available. To better handle non checked in config file.
clean up Leaked Scalars, from thread