dig's code, but never made it down to the mainline. These are fixes to some potential bugs Brian noticed.