More rewrites, and output-mode fixed (we should documentate this)