Fixing memory leak in config loading and moving config loading to use file utils.