Rewrite and simplify output handlers.