Fix timeouts

Error handling seems to work correctly now. I should probably see if the
EADDRNOTAVAIL error can be prevented. It seems to happen randomly and
then last for multiple seconds.