Better field names for nested tags, some refactoring

For a record tag "person":

    <person>
        <id>1</id>
        <city>
            <id>1</id>
            <name>Austin</name>
            <province>
                <id>1</id>
                <name>Texas</name>
            </province>
        </city>
    </person>

Column names should be

    id, city_id, city_name, city_province_id, city_province_name, city_province, city

and not

    id, id, name, id, name, province, city

This has now been added, along with some code cleanups and better variable names.