Refactored bot protocol, and fixed XML parsing vuln