Fixed up the db code, got all the tests passing again.