More database fixes