Bugs in db handling