Fix the last remaining DB bugs. All tests pass.