Makes xml_to_bas.pl more robust