Added primary templates and fixed bugs