Moved loops to template files.