Small fixes to template parser