Added support for Udp devices, refactoring.