Add UDP and refactor network