Database fixes. There's daylight now :(
Merge branch 'database'