refactor networking code to start supporting multiple backends