Fixed unsent buffer length logic.