Database bug fix