fix a heisenbug, index survived unit tests
use Matcher.quoteReplacement() in String.replaceAll(). Changed in .sge so changing here too, for consistency