Fixes a tags bug and makes #to_xml more efficient.