Database bug fix, formatting