Misc cleanups preparing for templating.