Moved the functions out, and made it an XML doc.