Reworking connection class to work smoothly with the DI