Database fixes & improvements