Refactoring networking classes