Adds xml declaration and wrapping element.

Slight refactor of params handling as well (deletes used params).
Indexing and recursive true as default in #to_xml.