fixes to database class and debugging