Fixed bug in applyTemplate() - outer HTML was lost