build_db.py: Rewrite parsing of units