diff --git a/codec.m b/codec.m
index 02d5077cf6a22597d8947495c09db8eb42d399f6..df22f690a6ffe65dcf98580d1012b4fee5320931 100644
--- a/codec.m
+++ b/codec.m
@@ -55,7 +55,7 @@ if encode
     HEVCp.addParameter('QP'                 ,'30'      ,@ischar);
     HEVCp.addParameter('WarnUnknowParameter','0'       ,@ischar);
     if decode
-        HEVCp.addParameter('ReconFile'          ,'rec.yuv' ,@ischar);
+        HEVCp.addParameter('ReconFile'      ,'rec.yuv' ,@ischar);
     end
 elseif decode
     HEVCp.addParameter('BitstreamFile'      ,'bit.hevc',@ischar);
@@ -70,27 +70,19 @@ HEVCp.parse(codecp.Unmatched);
 HEVCParams = HEVCp.Results;
 extraHEVCParams = HEVCp.Unmatched;
 
-% Make sure ConfigFile is the first parameter to set default values
-if encode
-    perm = 1:numel(HEVCp.Parameters);
-    indconf = find(strcmp('ConfigFile',HEVCp.Parameters));
-    perm(1) = indconf; perm(indconf) = 1;
-    HEVCParams = orderfields(HEVCParams,perm);
-end
-
 % Make sure to create output folders before running executable
-[folder,~,~] = fileparts(HEVCp.Results.BitstreamFile);
+[folder,~,~] = fileparts(HEVCParams.BitstreamFile);
 if ~exist(folder,'dir')
     mkdir(folder);
 end
 if decode
-    [folder,~,~] = fileparts(HEVCp.Results.ReconFile);
+    [folder,~,~] = fileparts(HEVCParams.ReconFile);
     if ~exist(folder,'dir')
         mkdir(folder);
     end
 end
 
-[LogFolder,LogName,~] = fileparts(HEVCp.Results.BitstreamFile);
+[LogFolder,LogName,~] = fileparts(HEVCParams.BitstreamFile);
 LogFileEnc = fullfile(LogFolder,[LogName,'_enc.rtf']);
 LogFileDec = fullfile(LogFolder,[LogName,'_dec.rtf']);
 
@@ -98,12 +90,14 @@ LogFileDec = fullfile(LogFolder,[LogName,'_dec.rtf']);
 HEVCArgList = paramToArgList(HEVCParams);
 extraHEVCArgList = paramToArgList(extraHEVCParams);
 
+% Prompt in terminal and write in log file
 if ispc
     redirect = @(logfile) ['> "',logfile,'" | type "' logfile, '"'];
 elseif isunix
     redirect = @(logfile) ['| tee ' ,LogFile];
 end
 
+% Execute command
 if encode
     command = ['"' TApp,'" ',HEVCArgList,' ',extraHEVCArgList,' ',redirect(LogFileEnc)];
 elseif decode
@@ -113,6 +107,7 @@ end
 disp(command)
 status = system(command);
 
+% Try without extra HEVC parameters if HEVC error
 if status
     if encode
         command = ['"' TApp,'" ',HEVCArgList,' ',redirect(LogFileEnc)];
@@ -126,6 +121,7 @@ if status
     end
 end
 
+% Read compression statistics from log file
 try
     [nbBits,peaksnr] = HEVC.parseLog(LogFileEnc);
 catch
@@ -135,10 +131,25 @@ end
 end
 
 function argList = paramToArgList(Params)
+
+% Get parameters and arguments
 parameters = fieldnames (Params);
 values     = struct2cell(Params);
 
+% Deal with '-c' being the single command line parameter for configuration file 
+indcfg = strcmp(parameters,'ConfigFile');
+
+if any(indcfg)
+    argcfg = ['-c "',values{indcfg},'"'];
+else
+    argcfg = '';
+end
+
+parameters = parameters(~indcfg);
+values     = values    (~indcfg);
+
+% Build command line argument list
 argList = cellfun(@(param,val) ['--',param,'="',val,'"'],parameters,values,'UniformOutput',false);
 
-argList = strjoin(argList(:));
+argList = strjoin([argcfg;argList(:)]);
 end
\ No newline at end of file