Restructuring : moved templates out of the main code.