Still a bit sloppy (v2)
Quick hack to make it export to XML + Refactored the library to a class.