build_db.py: Fix problems with overlapping rowspans