Added xml decoding
Now capable of writing to back-end
Reformatted a lot of code.