Bug fixes, and better udp handling