optimize xtemplate for nodejs
optimize xtemplate. Fixes #570