fix bugs introduced with the automatic search and replace