rearrange things slightly: add a few functions, move generally useful stuff out of timedb