some merges from 2.2. Still need to merge in changes from pdb_tdb.c