Refactor device connections