reworked XML document creation so that it actually works! Also some code for writing species to xml