Fixed some bugs caused by find-replace