Organize template code