Fix string replacement issues