Bug in rewriteRightEnds fixed.