More work on document template insertion