Conversion to templating; completed commenting