updates for tdbsam code to help make merge into head easier; needs a bit more testing...