Remove repeated code
Remove CLI logic from classes
Fix multiple bugs in XML parser