Templateparser fix to merge to Sam's branch