Yes, code accidently placed within code does often cause some odd behavior. I was stepping through the template and it looks clean (with the noted exception), so it was a puzzling "mystery". I was going to run a test, but that observation would certainly explain that unexpected result with FIND & REPLACE.
Hope you can sort it out.
Danno