Assorted cleanups in gfx and layout

@pcwalton r?