Database improvements/fixes