Reimplemented reading and writing to both esp and xml. 100% verified.