Surround \middle with OPEN and CLOSE TeXAtoms, so that the spacing will be consistent with TeX's version (e.g., \mathrel{}\middle|\mathrel{} will produce the right spacing). As a side effect, this resolves the problem with the quotes, sot this resolves issue #1023 (closed).