Added a quick fix that collects all #replace tag information before modifying the input files.