Mask mode: Escape fixes. Some things were lost by recent commits,
others were not really good to begin with: We must never look
backwards for detecting escapes, only forward. See #776 for older
discussion.