A few random improvements to the database layer

Yay :+1: