build_db.py: Fix several problems with rowspan and colspan