basis.template: fix some edge cases