Add code to rebuild_database.py to recompute segment metadata.