Fix Bugs in Database class