MergeFiles: code cleanup and fixes