Added some more fixes and functions to database handler