Added template handling.