Clean up template code to be more consistent