Implement socket timeouts better