Various template bug fixes, defra example looking reasonably complete