fixed lots of small bugs, added more support for XML