Improves handling of database connections