fix database problems due to database connection not being handled corre...

...ctly.