refactor entity and xml_payload

First of all, this is an awesome work!
While reviewing this some rafactors came up, I still have to take a look at some parts of the code, I'm not that familiar with Diaspora's federation, but I'm still learning!

I notice that there are some #TODOs in the code, I can work on them if you like, but probably I'm goning to need some help to understand what is needed to be changed.