context/connection refactor