Add XML output to API and add missing requirement to setup.py
Clean up the module, fixing docstrings and organizing code