Refactoring and custom connection added