support XML

add XML support, and other performace changes.