Fix buffer flushing. Prevent from forgetting not sent messages.