MDL-43089 move lots of logic out of the renderer.