fix cleaning of receiving buffer