Some minor refactorings

- _ is used where you don't need to save a value
- I've extracted socket to a private method so we don't create multiple
  UDPSocket instances.