Fix replacement bug

For example BLAH__(upcase "blah")__BLAH is replaced by BLAH"BLAH"BLAH.
Also, turn replacement errors into simple messages.