More general database fixes. No idea if they'll work.