Fix flushing of sockets, causing random sync errors