Add docstrings.
Use orderd dicts for xml generation.