Improve still crap builddb script