HeaderDB: directly use hashes as indices, and other improvements