Added global namespace to SimpleXMLElement calls, and some other minor refactors.