made xpath reference a little more stable for this version (as it would not bundle otherwise)
wrapped Regexp.new around Regexp.escape to avoid obscure double escaping behavior
backport from master (with a few tests)