Very big refactor networking