Reworked XML parsing