Fix memory leak in loadConfig