improved handling of expandable forms (reference numbers)
improved expandable forms in templates