WIP template grammar. Added try with for closeable resources throughout. Included some previous tests.