Update to latest xzing and re-factor code