Bug fix: free chunk after data is sent; wait > 0 so that send buffer will not be overflowed.