Added destructors to close db connections (not closed automatically on exceptions).