Rearranging a bit, and adding some light templating.