Move connection code to src/