Complete rewrite of XSLT