Fix some issues and add xml_to_bas.pl