build_db.py: Several corrections