Fix several bugs in WCF.Template