Fixed an issue with DB connection handling