Generalized a lot of reading and the WriteXML command
Fixed plugins not reading to the end