Refactor connections